From 4b3d598a7b58f97600d2aabcca4962b7ec53f925 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Fri, 17 Nov 2023 19:17:00 +0000 Subject: [PATCH] fix package info for sdist Fixes #8682 --- src/poetry/inspection/info.py | 2 ++ .../distributions/demo_no_pkg_info-0.1.0.tar.gz | Bin 0 -> 594 bytes tests/inspection/test_info.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/fixtures/distributions/demo_no_pkg_info-0.1.0.tar.gz diff --git a/src/poetry/inspection/info.py b/src/poetry/inspection/info.py index 545eed25adf..2bcbacc8fcf 100644 --- a/src/poetry/inspection/info.py +++ b/src/poetry/inspection/info.py @@ -313,6 +313,8 @@ def _from_sdist_file(cls, path: Path) -> PackageInfo: # now this is an unpacked directory we know how to deal with new_info = cls.from_directory(path=sdist_dir) + new_info._source_type = "file" + new_info._source_url = path.resolve().as_posix() if not info: return new_info diff --git a/tests/fixtures/distributions/demo_no_pkg_info-0.1.0.tar.gz b/tests/fixtures/distributions/demo_no_pkg_info-0.1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..9b9c20ace8c2c5cb0ddfceff93a0e54d97069f3a GIT binary patch literal 594 zcmV-Y08UFMBGxkO3TB?#Uv_!bu3E2JHRRQN>@BG)oG}STB z{m2XFp9VoVe*Y6ntj{V|g7bd{UZc4;N2$tWxw%4(SfBcc}-Auh0$l@antk%F-@(o--{zH&XBZ zT!}Jk@}@u+*GuY0estLmCB7NW>(M(5cFT1)o>4`)Tx%08FHhXt8&ApxeuxoLzXw@PPOIXk3WCh z^4dsIqWA3%O9h^Im?*f+TW2i><2%tCeYq>H(fM?Oam}qdhSN;9?2p;*=ioS8dh0rr z2Iq9$t#2xfGv3=5DffrN*UP|P%+RZ4=o8=T13Cu57=*rOU(j}`Z_|b6?YHX^K0W{d g000000000000000000000Pv^$0yo*H+5jj30Bo}+FaQ7m literal 0 HcmV?d00001 diff --git a/tests/inspection/test_info.py b/tests/inspection/test_info.py index c52c026bfa8..5c1a757bcaf 100644 --- a/tests/inspection/test_info.py +++ b/tests/inspection/test_info.py @@ -114,16 +114,30 @@ def demo_check_info(info: PackageInfo, requires_dist: set[str] | None = None) -> def test_info_from_sdist(demo_sdist: Path) -> None: info = PackageInfo.from_sdist(demo_sdist) demo_check_info(info) + assert info._source_type == "file" + assert info._source_url == demo_sdist.resolve().as_posix() + + +def test_info_from_sdist_no_pkg_info(fixture_dir: FixtureDirGetter) -> None: + path = fixture_dir("distributions") / "demo_no_pkg_info-0.1.0.tar.gz" + info = PackageInfo.from_sdist(path) + demo_check_info(info) + assert info._source_type == "file" + assert info._source_url == path.resolve().as_posix() def test_info_from_wheel(demo_wheel: Path) -> None: info = PackageInfo.from_wheel(demo_wheel) demo_check_info(info) + assert info._source_type == "file" + assert info._source_url == demo_wheel.resolve().as_posix() def test_info_from_bdist(demo_wheel: Path) -> None: info = PackageInfo.from_bdist(demo_wheel) demo_check_info(info) + assert info._source_type == "file" + assert info._source_url == demo_wheel.resolve().as_posix() def test_info_from_poetry_directory(fixture_dir: FixtureDirGetter) -> None: