mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Fix editor auto-deletions of piptools patch lines
Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
@@ -19,7 +19,7 @@ index 4e6174c..75f9b49 100644
|
||||
# NOTE
|
||||
# We used to store the cache dir under ~/.pip-tools, which is not the
|
||||
diff --git a/pipenv/patched/piptools/repositories/pypi.py b/pipenv/patched/piptools/repositories/pypi.py
|
||||
index 1c4b943..10447b6 100644
|
||||
index 1c4b943..84077f0 100644
|
||||
--- a/pipenv/patched/piptools/repositories/pypi.py
|
||||
+++ b/pipenv/patched/piptools/repositories/pypi.py
|
||||
@@ -1,9 +1,10 @@
|
||||
@@ -33,7 +33,7 @@ index 1c4b943..10447b6 100644
|
||||
+import sys
|
||||
from contextlib import contextmanager
|
||||
from shutil import rmtree
|
||||
|
||||
|
||||
@@ -15,13 +16,22 @@ from .._compat import (
|
||||
Wheel,
|
||||
FAVORITE_HASH,
|
||||
@@ -43,7 +43,7 @@ index 1c4b943..10447b6 100644
|
||||
+ InstallRequirement,
|
||||
+ SafeFileCache,
|
||||
)
|
||||
|
||||
|
||||
-from ..cache import CACHE_DIR
|
||||
+from pip._vendor.packaging.requirements import Requirement
|
||||
+from pip._vendor.packaging.specifiers import SpecifierSet, Specifier
|
||||
@@ -58,12 +58,12 @@ index 1c4b943..10447b6 100644
|
||||
+ make_install_requirement, clean_requires_python)
|
||||
+
|
||||
from .base import BaseRepository
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +47,45 @@ except ImportError:
|
||||
from pip.wheel import WheelCache
|
||||
|
||||
|
||||
|
||||
|
||||
+class HashCache(SafeFileCache):
|
||||
+ """Caches hashes of PyPI artifacts so we do not need to re-download them
|
||||
+
|
||||
@@ -105,7 +105,7 @@ index 1c4b943..10447b6 100644
|
||||
+
|
||||
class PyPIRepository(BaseRepository):
|
||||
DEFAULT_INDEX_URL = PyPI.simple_url
|
||||
|
||||
|
||||
@@ -46,10 +95,11 @@ class PyPIRepository(BaseRepository):
|
||||
config), but any other PyPI mirror can be used if index_urls is
|
||||
changed/configured on the Finder.
|
||||
@@ -117,7 +117,7 @@ index 1c4b943..10447b6 100644
|
||||
self.pip_options = pip_options
|
||||
- self.wheel_cache = WheelCache(CACHE_DIR, pip_options.format_control)
|
||||
+ self.wheel_cache = WheelCache(PIPENV_CACHE_DIR, pip_options.format_control)
|
||||
|
||||
|
||||
index_urls = [pip_options.index_url] + pip_options.extra_index_urls
|
||||
if pip_options.no_index:
|
||||
@@ -74,11 +124,15 @@ class PyPIRepository(BaseRepository):
|
||||
@@ -128,20 +128,20 @@ index 1c4b943..10447b6 100644
|
||||
+
|
||||
+ # stores *full* path + fragment => sha256
|
||||
+ self._hash_cache = HashCache(session=session)
|
||||
|
||||
|
||||
# Setup file paths
|
||||
self.freshen_build_caches()
|
||||
- self._download_dir = fs_str(os.path.join(CACHE_DIR, 'pkgs'))
|
||||
- self._wheel_download_dir = fs_str(os.path.join(CACHE_DIR, 'wheels'))
|
||||
+ self._download_dir = fs_str(os.path.join(PIPENV_CACHE_DIR, 'pkgs'))
|
||||
+ self._wheel_download_dir = fs_str(os.path.join(PIPENV_CACHE_DIR, 'wheels'))
|
||||
|
||||
|
||||
def freshen_build_caches(self):
|
||||
"""
|
||||
@@ -114,10 +168,14 @@ class PyPIRepository(BaseRepository):
|
||||
if ireq.editable:
|
||||
return ireq # return itself as the best match
|
||||
|
||||
|
||||
- all_candidates = self.find_all_candidates(ireq.name)
|
||||
+ all_candidates = clean_requires_python(self.find_all_candidates(ireq.name))
|
||||
+
|
||||
@@ -152,12 +152,12 @@ index 1c4b943..10447b6 100644
|
||||
prereleases=prereleases)
|
||||
+ except TypeError:
|
||||
+ matching_versions = [candidate.version for candidate in all_candidates]
|
||||
|
||||
|
||||
# Reuses pip's internal candidate sort key to sort
|
||||
matching_candidates = [candidates_by_version[ver] for ver in matching_versions]
|
||||
@@ -126,11 +184,71 @@ class PyPIRepository(BaseRepository):
|
||||
best_candidate = max(matching_candidates, key=self.finder._candidate_sort_key)
|
||||
|
||||
|
||||
# Turn the candidate into a pinned InstallRequirement
|
||||
- return make_install_requirement(
|
||||
- best_candidate.project, best_candidate.version, ireq.extras, constraint=ireq.constraint
|
||||
@@ -211,7 +211,7 @@ index 1c4b943..10447b6 100644
|
||||
+ return set(self._json_dep_cache[ireq])
|
||||
+ except Exception:
|
||||
+ return set()
|
||||
|
||||
|
||||
def get_dependencies(self, ireq):
|
||||
+ json_results = set()
|
||||
+
|
||||
@@ -380,12 +380,12 @@ index 1c4b943..10447b6 100644
|
||||
reqset.cleanup_files()
|
||||
+
|
||||
return set(self._dependencies_cache[ireq])
|
||||
|
||||
|
||||
def get_hashes(self, ireq):
|
||||
@@ -210,6 +434,10 @@ class PyPIRepository(BaseRepository):
|
||||
if ireq.editable:
|
||||
return set()
|
||||
|
||||
|
||||
+ vcs = VcsSupport()
|
||||
+ if ireq.link and ireq.link.scheme in vcs.all_schemes and 'ssh' in ireq.link.scheme:
|
||||
+ return set()
|
||||
@@ -412,13 +412,13 @@ index 1c4b943..10447b6 100644
|
||||
+ # matching_versions = list(
|
||||
+ # ireq.specifier.filter((candidate.version for candidate in all_candidates)))
|
||||
+ # matching_candidates = candidates_by_version[matching_versions[0]]
|
||||
|
||||
|
||||
return {
|
||||
- self._get_file_hash(candidate.location)
|
||||
+ self._hash_cache.get_hash(candidate.location)
|
||||
for candidate in matching_candidates
|
||||
}
|
||||
|
||||
|
||||
- def _get_file_hash(self, location):
|
||||
- h = hashlib.new(FAVORITE_HASH)
|
||||
- with open_local_or_remote_file(location, self.session) as fp:
|
||||
|
||||
Reference in New Issue
Block a user