Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,10 @@ def from_setup_files(cls, path: Path) -> PackageInfo:
name=result.get("name"),
version=result.get("version"),
summary=result.get("description", ""),
requires_dist=requirements or None,
requires_dist=requirements,
Comment thread
abn marked this conversation as resolved.
requires_python=python_requires,
)

if not (info.name and info.version) and not info.requires_dist:
# there is nothing useful here
raise PackageInfoError(
path,
"No core metadata (name, version, requires-dist) could be retrieved.",
)

return info

@staticmethod
Expand Down Expand Up @@ -582,7 +575,7 @@ def get_pep517_metadata(path: Path) -> PackageInfo:

with contextlib.suppress(PackageInfoError):
info = PackageInfo.from_setup_files(path)
if all([info.version, info.name, info.requires_dist]):
if all(x is not None for x in (info.version, info.name, info.requires_dist)):
return info

with ephemeral_environment(
Expand Down
22 changes: 20 additions & 2 deletions tests/inspection/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ def test_info_setup_complex_calls_script(demo_setup_complex_calls_script: Path)


@pytest.mark.network
@pytest.mark.parametrize("missing", ["version", "name", "install_requires"])
@pytest.mark.parametrize("missing", ["version", "name"])
def test_info_setup_missing_mandatory_should_trigger_pep517(
mocker: MockerFixture, source_dir: Path, missing: str
) -> None:
setup = "from setuptools import setup; "
setup += "setup("
setup += 'name="demo", ' if missing != "name" else ""
setup += 'version="0.1.0", ' if missing != "version" else ""
setup += 'install_requires=["package"]' if missing != "install_requires" else ""
setup += 'install_requires=["package"]'
setup += ")"

setup_py = source_dir / "setup.py"
Expand All @@ -337,6 +337,24 @@ def test_info_setup_missing_mandatory_should_trigger_pep517(
assert spy.call_count == 1


@pytest.mark.network
def test_info_setup_missing_install_requires_is_fine(
mocker: MockerFixture, source_dir: Path
) -> None:
setup = "from setuptools import setup; "
setup += "setup("
setup += 'name="demo", '
setup += 'version="0.1.0", '
setup += ")"

setup_py = source_dir / "setup.py"
setup_py.write_text(setup)

spy = mocker.spy(VirtualEnv, "run")
_ = PackageInfo.from_directory(source_dir)
assert spy.call_count == 0


def test_info_prefer_poetry_config_over_egg_info(fixture_dir: FixtureDirGetter) -> None:
info = PackageInfo.from_directory(
fixture_dir("inspection") / "demo_with_obsolete_egg_info"
Expand Down