From 238e6bd7299ba7bbd55ffb236e6784a758b55900 Mon Sep 17 00:00:00 2001 From: Jadon Gaertner Date: Thu, 5 Dec 2024 16:28:50 -0800 Subject: [PATCH] git, url, path dependencies. Skip url and path for now --- metadata_please/source_checkout.py | 22 +++++++++++++++++++++- metadata_please/tests/source_checkout.py | 5 ++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/metadata_please/source_checkout.py b/metadata_please/source_checkout.py index 48837ea..92da2d5 100644 --- a/metadata_please/source_checkout.py +++ b/metadata_please/source_checkout.py @@ -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 diff --git a/metadata_please/tests/source_checkout.py b/metadata_please/tests/source_checkout.py index bedebc8..19d4e27 100644 --- a/metadata_please/tests/source_checkout.py +++ b/metadata_please/tests/source_checkout.py @@ -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 } @@ -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"', ],