|
8 | 8 | import hashlib
|
9 | 9 | import logging
|
10 | 10 | import os
|
| 11 | +import sys |
11 | 12 |
|
12 | 13 | from pip._vendor.packaging.utils import canonicalize_name
|
13 | 14 |
|
14 | 15 | from pip._internal.models.link import Link
|
15 | 16 | from pip._internal.utils.compat import expanduser
|
| 17 | +from pip._internal.utils.misc import interpreter_name |
16 | 18 | from pip._internal.utils.temp_dir import TempDirectory
|
17 | 19 | from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
18 | 20 | from pip._internal.utils.urls import path_to_url
|
@@ -60,11 +62,23 @@ def _get_cache_path_parts(self, link):
|
60 | 62 | key_parts.append("=".join([link.hash_name, link.hash]))
|
61 | 63 | key_url = "#".join(key_parts)
|
62 | 64 |
|
| 65 | + # Include interpreter name, major and minor version in cache key |
| 66 | + # to cope with ill-behaved sdists that build a different wheel |
| 67 | + # depending on the python version their setup.py is being run on, |
| 68 | + # and don't encode the difference in compatibility tags. |
| 69 | + # https://github.com/pypa/pip/issues/7296 |
| 70 | + key = "{}-{}.{} {}".format( |
| 71 | + interpreter_name(), |
| 72 | + sys.version_info[0], |
| 73 | + sys.version_info[1], |
| 74 | + key_url, |
| 75 | + ) |
| 76 | + |
63 | 77 | # Encode our key url with sha224, we'll use this because it has similar
|
64 | 78 | # security properties to sha256, but with a shorter total output (and
|
65 | 79 | # thus less secure). However the differences don't make a lot of
|
66 | 80 | # difference for our use case here.
|
67 |
| - hashed = hashlib.sha224(key_url.encode()).hexdigest() |
| 81 | + hashed = hashlib.sha224(key.encode()).hexdigest() |
68 | 82 |
|
69 | 83 | # We want to nest the directories some to prevent having a ton of top
|
70 | 84 | # level directories where we might run out of sub directories on some
|
|
0 commit comments