Skip to content

Commit 619b257

Browse files
committed
Add failing tests for issue 10573
1 parent ddfeaae commit 619b257

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

tests/functional/test_install.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,26 @@ def test_editable_install__local_dir_no_setup_py_with_pyproject(script):
687687
assert "cannot be installed in editable mode" in msg
688688

689689

690+
def test_editable_install__local_dir_setup_requires_with_pyproject(script, shared_data):
691+
"""
692+
Test installing in editable mode from a local directory with a setup.py
693+
that has setup_requires and a pyproject.toml.
694+
695+
https://github.com/pypa/pip/issues/10573
696+
"""
697+
local_dir = script.scratch_path.joinpath("temp")
698+
local_dir.mkdir()
699+
pyproject_path = local_dir.joinpath("pyproject.toml")
700+
pyproject_path.write_text("")
701+
setup_py_path = local_dir.joinpath("setup.py")
702+
setup_py_path.write_text(
703+
"from setuptools import setup\n"
704+
"setup(name='dummy', setup_requires=['simplewheel'])\n"
705+
)
706+
707+
script.pip("install", "--find-links", shared_data.find_links, "-e", local_dir)
708+
709+
690710
@pytest.mark.network
691711
def test_upgrade_argparse_shadowed(script):
692712
# If argparse is installed - even if shadowed for imported - we support

tests/functional/test_pep660.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,22 @@ def build_editable(wheel_directory, config_settings=None, metadata_directory=Non
5959
# fmt: on
6060

6161

62-
def _make_project(tmpdir, backend_code, with_setup_py):
62+
def _make_project(tmpdir, backend_code, with_setup_py, with_pyproject=True):
6363
project_dir = tmpdir / "project"
6464
project_dir.mkdir()
6565
project_dir.joinpath("setup.cfg").write_text(SETUP_CFG)
6666
if with_setup_py:
6767
project_dir.joinpath("setup.py").write_text(SETUP_PY)
6868
if backend_code:
69+
assert with_pyproject
6970
buildsys = {"requires": ["setuptools", "wheel"]}
7071
buildsys["build-backend"] = "test_backend"
7172
buildsys["backend-path"] = ["."]
7273
data = tomli_w.dumps({"build-system": buildsys})
7374
project_dir.joinpath("pyproject.toml").write_text(data)
7475
project_dir.joinpath("test_backend.py").write_text(backend_code)
76+
elif with_pyproject:
77+
project_dir.joinpath("pyproject.toml").touch()
7578
project_dir.joinpath("log.txt").touch()
7679
return project_dir
7780

@@ -124,7 +127,8 @@ def test_install_pep660_basic(tmpdir, script, with_wheel):
124127
def test_install_no_pep660_setup_py_fallback(tmpdir, script, with_wheel):
125128
"""
126129
Test that we fall back to setuptools develop when using a backend that
127-
does not support build_editable .
130+
does not support build_editable. Since there is a pyproject.toml,
131+
the prepare_metadata_for_build_wheel hook is called.
128132
"""
129133
project_dir = _make_project(tmpdir, BACKEND_WITHOUT_PEP660, with_setup_py=True)
130134
result = script.pip(
@@ -135,6 +139,7 @@ def test_install_no_pep660_setup_py_fallback(tmpdir, script, with_wheel):
135139
project_dir,
136140
allow_stderr_warning=False,
137141
)
142+
_assert_hook_called(project_dir, "prepare_metadata_for_build_wheel")
138143
assert (
139144
result.test_env.site_packages.joinpath("project.egg-link")
140145
in result.files_created
@@ -144,7 +149,8 @@ def test_install_no_pep660_setup_py_fallback(tmpdir, script, with_wheel):
144149
def test_install_no_pep660_setup_cfg_fallback(tmpdir, script, with_wheel):
145150
"""
146151
Test that we fall back to setuptools develop when using a backend that
147-
does not support build_editable .
152+
does not support build_editable. Since there is a pyproject.toml,
153+
the prepare_metadata_for_build_wheel hook is called.
148154
"""
149155
project_dir = _make_project(tmpdir, BACKEND_WITHOUT_PEP660, with_setup_py=False)
150156
result = script.pip(
@@ -156,6 +162,7 @@ def test_install_no_pep660_setup_cfg_fallback(tmpdir, script, with_wheel):
156162
allow_stderr_warning=False,
157163
)
158164
print(result.stdout, result.stderr)
165+
_assert_hook_called(project_dir, "prepare_metadata_for_build_wheel")
159166
assert (
160167
result.test_env.site_packages.joinpath("project.egg-link")
161168
in result.files_created

0 commit comments

Comments
 (0)