diff --git a/news/6158.bugfix b/news/6158.bugfix new file mode 100644 index 00000000000..fe5a0352f9b --- /dev/null +++ b/news/6158.bugfix @@ -0,0 +1 @@ +Fix a crash when using --no-cache-dir with PEP 517 distributions diff --git a/news/6171.bugfix b/news/6171.bugfix new file mode 100644 index 00000000000..fe5a0352f9b --- /dev/null +++ b/news/6171.bugfix @@ -0,0 +1 @@ +Fix a crash when using --no-cache-dir with PEP 517 distributions diff --git a/src/pip/_internal/wheel.py b/src/pip/_internal/wheel.py index 93b4768622a..3f200b77edc 100644 --- a/src/pip/_internal/wheel.py +++ b/src/pip/_internal/wheel.py @@ -840,12 +840,6 @@ def build( newly built wheel, in preparation for installation. :return: True if all the wheels built correctly. """ - # TODO: This check fails if --no-cache-dir is set. And yet we - # might be able to build into the ephemeral cache, surely? - building_is_possible = self._wheel_dir or ( - autobuilding and self.wheel_cache.cache_dir - ) - assert building_is_possible buildset = [] format_control = self.finder.format_control @@ -884,6 +878,13 @@ def build( if not buildset: return [] + # Is any wheel build not using the ephemeral cache? + if any(not ephem_cache for _, ephem_cache in buildset): + have_directory_for_build = self._wheel_dir or ( + autobuilding and self.wheel_cache.cache_dir + ) + assert have_directory_for_build + # TODO by @pradyunsg # Should break up this method into 2 separate methods. diff --git a/tests/functional/test_install_wheel.py b/tests/functional/test_install_wheel.py index 9937d5a0af3..e09fdce850a 100644 --- a/tests/functional/test_install_wheel.py +++ b/tests/functional/test_install_wheel.py @@ -420,3 +420,11 @@ def test_wheel_compile_syntax_error(script, data): result = script.pip('install', '--compile', package, '--no-index') assert 'yield from' not in result.stdout assert 'SyntaxError: ' not in result.stdout + + +def test_wheel_install_with_no_cache_dir(script, tmpdir, data): + """Check wheel installations work, even with no cache. + """ + package = data.packages.join("simple.dist-0.1-py2.py3-none-any.whl") + result = script.pip('install', '--no-cache-dir', '--no-index', package) + result.assert_installed('simpledist', editable=False) diff --git a/tests/functional/test_pep517.py b/tests/functional/test_pep517.py index 52e3acded90..a1a45d27bb9 100644 --- a/tests/functional/test_pep517.py +++ b/tests/functional/test_pep517.py @@ -109,3 +109,17 @@ def test_pep517_backend_requirements_already_satisfied(script, tmpdir, data): project_dir, ) assert 'Installing backend dependencies:' not in result.stdout + + +def test_pep517_install_with_no_cache_dir(script, tmpdir, data): + """Check builds with a custom backends work, even with no cache. + """ + project_dir = make_project( + tmpdir, requires=['test_backend'], + backend="test_backend" + ) + result = script.pip( + 'install', '--no-cache-dir', '--no-index', '-f', data.backends, + project_dir, + ) + result.assert_installed('project', editable=False)