Skip to content

Commit 199be25

Browse files
committed
fixed poetry git, url, path deps to pass tests
1 parent 7220241 commit 199be25

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

metadata_please/source_checkout.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,26 @@ def from_poetry_checkout(path: Path) -> bytes:
213213
optional = False
214214

215215
if not version:
216-
# e.g. git, path or url dependencies, skip for now
216+
# e.g. git, path or url dependencies
217+
if "path" in v:
218+
buf.append(f"Requires-Dist: {v['path']}\n")
219+
220+
elif "url" in v:
221+
buf.append(f"Requires-Dist: {v['url']}\n")
222+
223+
elif "git" in v:
224+
git_link = f"git+{v['git']}"
225+
226+
# from both poetry and pypa docs, seems like only one of the following should be specified
227+
revision = v.get("rev") or v.get("tag") or v.get("branch")
228+
if revision:
229+
git_link += f"@{revision}"
230+
231+
if "subdirectory" in v:
232+
git_link += f"#subdirectory={v['subdirectory']}"
233+
234+
buf.append(f"Requires-Dist: {k} @ {git_link}\n")
235+
217236
continue
218237

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

metadata_please/tests/source_checkout.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ def test_poetry_full(self) -> None:
110110
c3 = "~1"
111111
d = {version="2", python="<3.11"}
112112
e = {version="2", markers="sys_platform == 'darwin'"}
113-
skipped = {git = "..."}
113+
skipped = {git = "...", tag = "12345"}
114+
my-package = { url = "https://example.com/my-package-0.1.0.tar.gz" }
115+
my-other-package = { path = "../my-package/dist/my-other-package-0.1.0.tar.gz" }
114116
complex = {extras=["bar", "baz"], version="2"}
115117
opt = { version = "^2.9", optional = true}
116118
unused-extra = { version = "2", optional = true }
@@ -131,6 +133,9 @@ def test_poetry_full(self) -> None:
131133
"c3>=1,<2",
132134
"d==2 ; python_version < '3.11'",
133135
"e==2 ; sys_platform == 'darwin'",
136+
"skipped @ git+...@12345",
137+
"https://example.com/my-package-0.1.0.tar.gz",
138+
"../my-package/dist/my-other-package-0.1.0.tar.gz",
134139
"complex[bar,baz]==2",
135140
'opt>=2.9,<3 ; extra == "foo"',
136141
],

0 commit comments

Comments
 (0)