File tree 4 files changed +25
-2
lines changed 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change
1
+ Cache wheels built from VCS requirements that are considered immutables
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ class Git(VersionControl):
48
48
def get_base_rev_args (rev ):
49
49
return [rev ]
50
50
51
+ def is_immutable_rev_checkout (self , url , dest ):
52
+ _ , rev_options = self .get_url_rev_options (url )
53
+ if not rev_options .rev :
54
+ return False
55
+ return self .is_commit_id_equal (dest , rev_options .rev )
56
+
51
57
def get_git_version (self ):
52
58
VERSION_PFX = 'git version '
53
59
version = self .run_command (['version' ], show_stdout = False )
Original file line number Diff line number Diff line change @@ -268,6 +268,20 @@ def get_base_rev_args(rev):
268
268
"""
269
269
raise NotImplementedError
270
270
271
+ def is_immutable_rev_checkout (self , url , dest ):
272
+ # type: (str, str) -> bool
273
+ """
274
+ Return true if the commit hash checked out at dest matches
275
+ the revision in url.
276
+
277
+ Always return False, if the VCS does not support immutable commit
278
+ hashes.
279
+
280
+ This method does not check if there are local uncommitted changes
281
+ in dest after checkout, as pip currently has no use case for that.
282
+ """
283
+ return False
284
+
271
285
@classmethod
272
286
def make_rev_options (cls , rev = None , extra_args = None ):
273
287
# type: (Optional[str], Optional[List[str]]) -> RevOptions
Original file line number Diff line number Diff line change 27
27
from pip ._vendor .six import StringIO
28
28
29
29
from pip ._internal import pep425tags
30
- from pip ._internal .download import unpack_file_url
30
+ from pip ._internal .download import _get_used_vcs_backend , unpack_file_url
31
31
from pip ._internal .exceptions import (
32
32
InstallationError ,
33
33
InvalidWheelFilename ,
@@ -845,7 +845,9 @@ def should_use_ephemeral_cache(
845
845
# VCS checkout. Build wheel just for this run
846
846
# unless it points to an immutable commit hash in which
847
847
# case it can be cached.
848
- # TODO if req.link.is_vcs_immutable: return False
848
+ vcs_backend = _get_used_vcs_backend (req .link )
849
+ if vcs_backend .is_immutable_rev_checkout (req .link .url , req .source_dir ):
850
+ return False
849
851
return True
850
852
851
853
link = req .link
You can’t perform that action at this time.
0 commit comments