Skip to content

Commit

Permalink
git, url, path dependencies. Skip url and path for now
Browse files Browse the repository at this point in the history
  • Loading branch information
jag250 committed Dec 6, 2024
1 parent 53f683f commit 238e6bd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 21 additions & 1 deletion metadata_please/source_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,27 @@ def from_poetry_checkout(path: Path) -> bytes:
optional = False

if not version:
# e.g. git, path or url dependencies, skip for now
# e.g. git, path or url dependencies
if "git" in v:
git_link = f"git+{v['git']}"

# from both poetry and pypa docs, seems like only one of the following should be specified
revision = v.get("rev") or v.get("tag") or v.get("branch")
if revision:
git_link += f"@{revision}"

if "subdirectory" in v:
git_link += f"#subdirectory={v['subdirectory']}"

buf.append(f"Requires-Dist: {k} @ {git_link}\n")

# Still not sure about the PEP-508 form that these are supposed to take
# elif "path" in v:
# buf.append(f"Requires-Dist: {v['path']}\n")
#
# elif "url" in v:
# buf.append(f"Requires-Dist: {v['url']}\n")
#
continue

# https://python-poetry.org/docs/dependency-specification/#version-constraints
Expand Down
5 changes: 4 additions & 1 deletion metadata_please/tests/source_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def test_poetry_full(self) -> None:
c3 = "~1"
d = {version="2", python="<3.11"}
e = {version="2", markers="sys_platform == 'darwin'"}
skipped = {git = "..."}
skipped = {git = "...", tag = "12345"}
my-url-package = { url = "https://example.com/my-package-0.1.0.tar.gz" }
my-path-package = { path = "../my-package/dist/my-other-package-0.1.0.tar.gz" }
complex = {extras=["bar", "baz"], version="2"}
opt = { version = "^2.9", optional = true}
unused-extra = { version = "2", optional = true }
Expand All @@ -133,6 +135,7 @@ def test_poetry_full(self) -> None:
"c3>=1,<2",
"d==2 ; python_version < '3.11'",
"e==2 ; sys_platform == 'darwin'",
"skipped @ git+...@12345",
"complex[bar,baz]==2",
'opt>=2.9,<3.0 ; extra == "foo"',
],
Expand Down

0 comments on commit 238e6bd

Please sign in to comment.