Skip to content

Commit 459ec54

Browse files
dimblebyabn
authored andcommitted
Trust the setup reader when it finds no requirements
1 parent e6910f3 commit 459ec54

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/poetry/inspection/info.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -369,17 +369,10 @@ def from_setup_files(cls, path: Path) -> PackageInfo:
369369
name=result.get("name"),
370370
version=result.get("version"),
371371
summary=result.get("description", ""),
372-
requires_dist=requirements or None,
372+
requires_dist=requirements,
373373
requires_python=python_requires,
374374
)
375375

376-
if not (info.name and info.version) and not info.requires_dist:
377-
# there is nothing useful here
378-
raise PackageInfoError(
379-
path,
380-
"No core metadata (name, version, requires-dist) could be retrieved.",
381-
)
382-
383376
return info
384377

385378
@staticmethod
@@ -582,7 +575,7 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
582575

583576
with contextlib.suppress(PackageInfoError):
584577
info = PackageInfo.from_setup_files(path)
585-
if all([info.version, info.name, info.requires_dist]):
578+
if all(x is not None for x in (info.version, info.name, info.requires_dist)):
586579
return info
587580

588581
with ephemeral_environment(

tests/inspection/test_info.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@ def test_info_setup_complex_calls_script(demo_setup_complex_calls_script: Path)
318318

319319

320320
@pytest.mark.network
321-
@pytest.mark.parametrize("missing", ["version", "name", "install_requires"])
321+
@pytest.mark.parametrize("missing", ["version", "name"])
322322
def test_info_setup_missing_mandatory_should_trigger_pep517(
323323
mocker: MockerFixture, source_dir: Path, missing: str
324324
) -> None:
325325
setup = "from setuptools import setup; "
326326
setup += "setup("
327327
setup += 'name="demo", ' if missing != "name" else ""
328328
setup += 'version="0.1.0", ' if missing != "version" else ""
329-
setup += 'install_requires=["package"]' if missing != "install_requires" else ""
329+
setup += 'install_requires=["package"]'
330330
setup += ")"
331331

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

339339

340+
@pytest.mark.network
341+
def test_info_setup_missing_install_requires_is_fine(
342+
mocker: MockerFixture, source_dir: Path
343+
) -> None:
344+
setup = "from setuptools import setup; "
345+
setup += "setup("
346+
setup += 'name="demo", '
347+
setup += 'version="0.1.0", '
348+
setup += ")"
349+
350+
setup_py = source_dir / "setup.py"
351+
setup_py.write_text(setup)
352+
353+
spy = mocker.spy(VirtualEnv, "run")
354+
_ = PackageInfo.from_directory(source_dir)
355+
assert spy.call_count == 0
356+
357+
340358
def test_info_prefer_poetry_config_over_egg_info(fixture_dir: FixtureDirGetter) -> None:
341359
info = PackageInfo.from_directory(
342360
fixture_dir("inspection") / "demo_with_obsolete_egg_info"

0 commit comments

Comments
 (0)