Skip to content

Commit 08f61a9

Browse files
authored
Do not attempt setup.py clean for failed pep517 builds (#7477)
2 parents a71086e + 8d1d20d commit 08f61a9

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

news/6642.bugfix

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Do not attempt to run ``setup.py clean`` after a ``pep517`` build error,
2+
since a ``setup.py`` may not exist in that case.

src/pip/_internal/wheel_builder.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,12 @@ def _build_one_inside_env(
231231
req.name, e,
232232
)
233233
# Ignore return, we can't do anything else useful.
234-
_clean_one(req, global_options)
234+
if not req.use_pep517:
235+
_clean_one_legacy(req, global_options)
235236
return None
236237

237238

238-
def _clean_one(req, global_options):
239+
def _clean_one_legacy(req, global_options):
239240
# type: (InstallRequirement, List[str]) -> bool
240241
clean_args = make_setuptools_clean_args(
241242
req.setup_py_path,

tests/data/packages/pep517_wrapper_buildsys/mybuildsys.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99

1010
def build_wheel(*a, **kw):
11+
if os.environ.get("PIP_TEST_FAIL_BUILD_WHEEL"):
12+
raise RuntimeError("Failing build_wheel, as requested.")
13+
1114
# Create the marker file to record that the hook was called
1215
with open(os.environ['PIP_TEST_MARKER_FILE'], 'wb'):
1316
pass

tests/functional/test_install.py

+1
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ def test_cleanup_after_failed_wheel(script, with_wheel):
12561256
shebang = open(script_py, 'r').readline().strip()
12571257
assert shebang != '#!python', shebang
12581258
# OK, assert that we *said* we were cleaning up:
1259+
# /!\ if in need to change this, also change test_pep517_no_legacy_cleanup
12591260
assert "Running setup.py clean for wheelbrokenafter" in str(res), str(res)
12601261

12611262

tests/functional/test_install_cleanup.py

+16
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,19 @@ def test_cleanup_prevented_upon_build_dir_exception(script, data):
136136
assert result.returncode == PREVIOUS_BUILD_DIR_ERROR, str(result)
137137
assert "pip can't proceed" in result.stderr, str(result)
138138
assert exists(build_simple), str(result)
139+
140+
141+
@pytest.mark.network
142+
def test_pep517_no_legacy_cleanup(script, data, with_wheel):
143+
"""Test a PEP 517 failed build does not attempt a legacy cleanup"""
144+
to_install = data.packages.joinpath('pep517_wrapper_buildsys')
145+
script.environ["PIP_TEST_FAIL_BUILD_WHEEL"] = "1"
146+
res = script.pip(
147+
'install', '-f', data.find_links, to_install,
148+
expect_error=True
149+
)
150+
# Must not have built the package
151+
expected = "Failed building wheel for pep517-wrapper-buildsys"
152+
assert expected in str(res)
153+
# Must not have attempted legacy cleanup
154+
assert "setup.py clean" not in str(res)

0 commit comments

Comments
 (0)