Skip to content

Commit

Permalink
Use interpreter_name and _version in cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Dec 2, 2019
1 parent 824dca1 commit ab05936
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
10 changes: 3 additions & 7 deletions src/pip/_internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
import json
import logging
import os
import sys

from pip._vendor.packaging.utils import canonicalize_name

from pip._internal.exceptions import InvalidWheelFilename
from pip._internal.models.link import Link
from pip._internal.models.wheel import Wheel
from pip._internal.pep425tags import interpreter_name, interpreter_version
from pip._internal.utils.compat import expanduser
from pip._internal.utils.misc import interpreter_name
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.utils.urls import path_to_url
Expand Down Expand Up @@ -104,11 +103,8 @@ def _get_cache_path_parts(self, link):
# depending on the python version their setup.py is being run on,
# and don't encode the difference in compatibility tags.
# https://github.com/pypa/pip/issues/7296
key_parts["interpreter"] = "{}-{}.{}".format(
interpreter_name(),
sys.version_info[0],
sys.version_info[1],
)
key_parts["interpreter_name"] = interpreter_name()
key_parts["interpreter_version"] = interpreter_version()

# Encode our key url with sha224, we'll use this because it has similar
# security properties to sha256, but with a shorter total output (and
Expand Down
6 changes: 6 additions & 0 deletions src/pip/_internal/pep425tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def get_abbr_impl():
return pyimpl


interpreter_name = get_abbr_impl


def version_info_to_nodot(version_info):
# type: (Tuple[int, ...]) -> str
# Only use up to the first two numbers.
Expand All @@ -69,6 +72,9 @@ def get_impl_ver():
return impl_ver


interpreter_version = get_impl_ver


def get_impl_version_info():
# type: () -> Tuple[int, ...]
"""Return sys.version_info-like tuple for use in decrementing the minor
Expand Down
11 changes: 0 additions & 11 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io
import logging
import os
import platform
import posixpath
import shutil
import stat
Expand Down Expand Up @@ -880,13 +879,3 @@ def hash_file(path, blocksize=1 << 20):
length += len(block)
h.update(block)
return (h, length) # type: ignore


def interpreter_name():
# type: () -> str
try:
name = sys.implementation.name # type: ignore
except AttributeError: # pragma: no cover
# Python 2.7 compatibility.
name = platform.python_implementation().lower()
return name

0 comments on commit ab05936

Please sign in to comment.