Skip to content

Commit

Permalink
Better workaround for cache poisoning #3025
Browse files Browse the repository at this point in the history
Make sure ``pip wheel`` never outputs pure python wheels with a
python implementation tag. Better fix/workaround for
`#3025 <https://github.com/pypa/pip/issues/3025>`_ by
using a per-implementation wheel cache instead of caching pure python
wheels with an implementation tag in their name.

Fixes #7296
  • Loading branch information
sbidoul committed Nov 9, 2019
1 parent 53770a7 commit 2d71b3a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
5 changes: 5 additions & 0 deletions news/7296.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Make sure ``pip wheel`` never outputs pure python wheels with a
python implementation tag. Better fix/workaround for
`#3025 <https://github.com/pypa/pip/issues/3025>`_ by
using a per-implementation wheel cache instead of caching pure python
wheels with an implementation tag in their name.
5 changes: 4 additions & 1 deletion src/pip/_internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pip._vendor.packaging.utils import canonicalize_name

from pip._internal.models.link import Link
from pip._internal.pep425tags import implementation_tag
from pip._internal.utils.compat import expanduser
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
Expand Down Expand Up @@ -157,7 +158,9 @@ def get_path_for_link(self, link):
parts = self._get_cache_path_parts(link)

# Store wheels within the root cache_dir
return os.path.join(self.cache_dir, "wheels", *parts)
return os.path.join(
self.cache_dir, implementation_tag, "wheels", *parts
)

def get(
self,
Expand Down
10 changes: 1 addition & 9 deletions src/pip/_internal/wheel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import re
import shutil

from pip._internal import pep425tags
from pip._internal.models.link import Link
from pip._internal.utils.logging import indent_log
from pip._internal.utils.marker_files import has_delete_marker_file
Expand Down Expand Up @@ -433,10 +432,6 @@ def build(
', '.join([req.name for (req, _) in buildset]),
)

python_tag = None
if should_unpack:
python_tag = pep425tags.implementation_tag

with indent_log():
build_success, build_failure = [], []
for req, output_dir in buildset:
Expand All @@ -450,10 +445,7 @@ def build(
build_failure.append(req)
continue

wheel_file = self._build_one(
req, output_dir,
python_tag=python_tag,
)
wheel_file = self._build_one(req, output_dir)
if wheel_file:
if should_unpack:
# XXX: This is mildly duplicative with prepare_files,
Expand Down
8 changes: 5 additions & 3 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,9 @@ def test_install_builds_wheels(script, data, with_wheel):
'from pip._internal.utils import appdirs; '
'print(appdirs.user_cache_dir("pip"))'
))
wheels_cache = os.path.join(res.stdout.rstrip('\n'), 'wheels')
wheels_cache = os.path.join(
res.stdout.rstrip('\n'), pep425tags.implementation_tag, 'wheels'
)
# NB This incidentally tests a local tree + tarball inputs
# see test_install_editable_from_git_autobuild_wheel for editable
# vcs coverage.
Expand Down Expand Up @@ -1261,9 +1263,9 @@ def test_install_builds_wheels(script, data, with_wheel):
assert "Running setup.py install for requir" not in str(res), str(res)
# wheelbroken has to run install
assert "Running setup.py install for wheelb" in str(res), str(res)
# We want to make sure we used the correct implementation tag
# We want to make sure pure python wheels do not have an implementation tag
assert wheels == [
"Upper-2.0-{}-none-any.whl".format(pep425tags.implementation_tag),
"Upper-2.0-py{}-none-any.whl".format(sys.version_info[0]),
]


Expand Down

0 comments on commit 2d71b3a

Please sign in to comment.