Skip to content

Commit 3b02326

Browse files
jag250thatch
authored andcommitted
git, url, path dependencies. Skip url and path for now
1 parent 53f683f commit 3b02326

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

metadata_please/source_checkout.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,27 @@ def from_poetry_checkout(path: Path) -> bytes:
233233
optional = False
234234

235235
if not version:
236-
# e.g. git, path or url dependencies, skip for now
236+
# e.g. git, path or url dependencies
237+
if "git" in v:
238+
git_link = f"git+{v['git']}"
239+
240+
# from both poetry and pypa docs, seems like only one of the following should be specified
241+
revision = v.get("rev") or v.get("tag") or v.get("branch")
242+
if revision:
243+
git_link += f"@{revision}"
244+
245+
if "subdirectory" in v:
246+
git_link += f"#subdirectory={v['subdirectory']}"
247+
248+
buf.append(f"Requires-Dist: {k} @ {git_link}\n")
249+
250+
# Still not sure about the PEP-508 form that these are supposed to take
251+
# elif "path" in v:
252+
# buf.append(f"Requires-Dist: {v['path']}\n")
253+
#
254+
# elif "url" in v:
255+
# buf.append(f"Requires-Dist: {v['url']}\n")
256+
#
237257
continue
238258

239259
# https://python-poetry.org/docs/dependency-specification/#version-constraints

metadata_please/tests/source_checkout.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def test_poetry_full(self) -> None:
111111
c3 = "~1"
112112
d = {version="2", python="<3.11"}
113113
e = {version="2", markers="sys_platform == 'darwin'"}
114-
skipped = {git = "..."}
114+
skipped = {git = "...", tag = "12345"}
115+
my-url-package = { url = "https://example.com/my-package-0.1.0.tar.gz" }
116+
my-path-package = { path = "../my-package/dist/my-other-package-0.1.0.tar.gz" }
115117
complex = {extras=["bar", "baz"], version="2"}
116118
opt = { version = "^2.9", optional = true}
117119
unused-extra = { version = "2", optional = true }
@@ -133,6 +135,7 @@ def test_poetry_full(self) -> None:
133135
"c3>=1,<2",
134136
"d==2 ; python_version < '3.11'",
135137
"e==2 ; sys_platform == 'darwin'",
138+
"skipped @ git+...@12345",
136139
"complex[bar,baz]==2",
137140
'opt>=2.9,<3.0 ; extra == "foo"',
138141
],

0 commit comments

Comments
 (0)