diff --git a/src/poetry/inspection/info.py b/src/poetry/inspection/info.py index 3edb225c8b5..8ca3e2fe975 100644 --- a/src/poetry/inspection/info.py +++ b/src/poetry/inspection/info.py @@ -44,10 +44,8 @@ dest = '{dest}' with build.env.DefaultIsolatedEnv() as env: - builder = build.ProjectBuilder( - source_dir=source, - python_executable=env.python_executable, - runner=pyproject_hooks.quiet_subprocess_runner, + builder = build.ProjectBuilder.from_isolated_env( + env, source, runner=pyproject_hooks.quiet_subprocess_runner ) env.install(builder.build_system_requires) env.install(builder.get_requires_for_build('wheel')) diff --git a/tests/inspection/test_info.py b/tests/inspection/test_info.py index 5c1a757bcaf..dfa0f1dafc8 100644 --- a/tests/inspection/test_info.py +++ b/tests/inspection/test_info.py @@ -1,5 +1,7 @@ from __future__ import annotations +import shutil + from subprocess import CalledProcessError from typing import TYPE_CHECKING @@ -87,6 +89,33 @@ def demo_setup_complex_pep517_legacy(demo_setup_complex: Path) -> Path: return demo_setup_complex +@pytest.fixture +def demo_setup_complex_calls_script( + fixture_dir: FixtureDirGetter, source_dir: Path, tmp_path: Path +) -> Path: + # make sure the scripts project is on the same drive (for Windows tests in CI) + scripts_dir = tmp_path / "scripts" + shutil.copytree(fixture_dir("scripts"), scripts_dir) + + pyproject = source_dir / "pyproject.toml" + pyproject.write_text(f"""\ + [build-system] + requires = ["setuptools", "scripts @ {scripts_dir.as_uri()}"] + build-backend = "setuptools.build_meta:__legacy__" +""") + + setup_py = source_dir / "setup.py" + setup_py.write_text("""\ +import subprocess +from setuptools import setup +if subprocess.call(["exit-code"]) != 42: + raise RuntimeError("Wrong exit code.") +setup(name="demo", version="0.1.0", install_requires=[i for i in ["package"]]) +""") + + return source_dir + + def demo_check_info(info: PackageInfo, requires_dist: set[str] | None = None) -> None: assert info.name == "demo" assert info.version == "0.1.0" @@ -245,6 +274,13 @@ def test_info_setup_complex_disable_build( assert info.requires_dist is None +@pytest.mark.network +def test_info_setup_complex_calls_script(demo_setup_complex_calls_script: Path) -> None: + """Building the project requires calling a script from its build_requires.""" + info = PackageInfo.from_directory(demo_setup_complex_calls_script) + demo_check_info(info, requires_dist={"package"}) + + @pytest.mark.network @pytest.mark.parametrize("missing", ["version", "name", "install_requires"]) def test_info_setup_missing_mandatory_should_trigger_pep517(