Skip to content

Commit ab79665

Browse files
authored
Merge pull request #6171 from pradyunsg/fix/pep-517-building-assertion
Fix build directory assertion for a PEP 517/518 world
2 parents 26184cb + a1cd49a commit ab79665

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

news/6158.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a crash when using --no-cache-dir with PEP 517 distributions

news/6171.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a crash when using --no-cache-dir with PEP 517 distributions

src/pip/_internal/wheel.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -840,12 +840,6 @@ def build(
840840
newly built wheel, in preparation for installation.
841841
:return: True if all the wheels built correctly.
842842
"""
843-
# TODO: This check fails if --no-cache-dir is set. And yet we
844-
# might be able to build into the ephemeral cache, surely?
845-
building_is_possible = self._wheel_dir or (
846-
autobuilding and self.wheel_cache.cache_dir
847-
)
848-
assert building_is_possible
849843

850844
buildset = []
851845
format_control = self.finder.format_control
@@ -884,6 +878,13 @@ def build(
884878
if not buildset:
885879
return []
886880

881+
# Is any wheel build not using the ephemeral cache?
882+
if any(not ephem_cache for _, ephem_cache in buildset):
883+
have_directory_for_build = self._wheel_dir or (
884+
autobuilding and self.wheel_cache.cache_dir
885+
)
886+
assert have_directory_for_build
887+
887888
# TODO by @pradyunsg
888889
# Should break up this method into 2 separate methods.
889890

tests/functional/test_install_wheel.py

+8
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,11 @@ def test_wheel_compile_syntax_error(script, data):
420420
result = script.pip('install', '--compile', package, '--no-index')
421421
assert 'yield from' not in result.stdout
422422
assert 'SyntaxError: ' not in result.stdout
423+
424+
425+
def test_wheel_install_with_no_cache_dir(script, tmpdir, data):
426+
"""Check wheel installations work, even with no cache.
427+
"""
428+
package = data.packages.join("simple.dist-0.1-py2.py3-none-any.whl")
429+
result = script.pip('install', '--no-cache-dir', '--no-index', package)
430+
result.assert_installed('simpledist', editable=False)

tests/functional/test_pep517.py

+14
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,17 @@ def test_pep517_backend_requirements_already_satisfied(script, tmpdir, data):
109109
project_dir,
110110
)
111111
assert 'Installing backend dependencies:' not in result.stdout
112+
113+
114+
def test_pep517_install_with_no_cache_dir(script, tmpdir, data):
115+
"""Check builds with a custom backends work, even with no cache.
116+
"""
117+
project_dir = make_project(
118+
tmpdir, requires=['test_backend'],
119+
backend="test_backend"
120+
)
121+
result = script.pip(
122+
'install', '--no-cache-dir', '--no-index', '-f', data.backends,
123+
project_dir,
124+
)
125+
result.assert_installed('project', editable=False)

0 commit comments

Comments
 (0)