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 00000000000..9b9c20ace8c Binary files /dev/null and b/tests/fixtures/distributions/demo_no_pkg_info-0.1.0.tar.gz differ 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: