Skip to content

Commit

Permalink
Merge pull request #6171 from pradyunsg/fix/pep-517-building-assertion
Browse files Browse the repository at this point in the history
Fix build directory assertion for a PEP 517/518 world
  • Loading branch information
pradyunsg authored Jan 23, 2019
2 parents 26184cb + a1cd49a commit ab79665
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions news/6158.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a crash when using --no-cache-dir with PEP 517 distributions
1 change: 1 addition & 0 deletions news/6171.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a crash when using --no-cache-dir with PEP 517 distributions
13 changes: 7 additions & 6 deletions src/pip/_internal/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
8 changes: 8 additions & 0 deletions tests/functional/test_install_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 14 additions & 0 deletions tests/functional/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ab79665

Please sign in to comment.