33
33
from pip ._internal .utils .deprecation import deprecated
34
34
from pip ._internal .utils .hashes import Hashes
35
35
from pip ._internal .utils .logging import indent_log
36
- from pip ._internal .utils .marker_files import (
37
- PIP_DELETE_MARKER_FILENAME ,
38
- has_delete_marker_file ,
39
- )
40
36
from pip ._internal .utils .misc import (
41
37
ask_path_exists ,
42
38
backup_dir ,
46
42
get_installed_version ,
47
43
hide_url ,
48
44
redact_auth_from_url ,
49
- rmtree ,
50
45
)
51
46
from pip ._internal .utils .packaging import get_metadata
52
47
from pip ._internal .utils .temp_dir import TempDirectory , tempdir_kinds
@@ -348,8 +343,8 @@ def from_path(self):
348
343
s += '->' + comes_from
349
344
return s
350
345
351
- def ensure_build_location (self , build_dir ):
352
- # type: (str) -> str
346
+ def ensure_build_location (self , build_dir , autodelete ):
347
+ # type: (str, bool ) -> str
353
348
assert build_dir is not None
354
349
if self ._temp_build_dir is not None :
355
350
assert self ._temp_build_dir .path
@@ -372,7 +367,16 @@ def ensure_build_location(self, build_dir):
372
367
if not os .path .exists (build_dir ):
373
368
logger .debug ('Creating directory %s' , build_dir )
374
369
os .makedirs (build_dir )
375
- return os .path .join (build_dir , name )
370
+ actual_build_dir = os .path .join (build_dir , name )
371
+ # `None` indicates that we respect the globally-configured deletion
372
+ # settings, which is what we actually want when auto-deleting.
373
+ delete_arg = None if autodelete else False
374
+ return TempDirectory (
375
+ path = actual_build_dir ,
376
+ delete = delete_arg ,
377
+ kind = tempdir_kinds .REQ_BUILD ,
378
+ globally_managed = True ,
379
+ ).path
376
380
377
381
def _set_requirement (self ):
378
382
# type: () -> None
@@ -412,16 +416,6 @@ def warn_on_mismatching_name(self):
412
416
)
413
417
self .req = Requirement (metadata_name )
414
418
415
- def remove_temporary_source (self ):
416
- # type: () -> None
417
- """Remove the source files from this requirement, if they are marked
418
- for deletion"""
419
- if self .source_dir and has_delete_marker_file (self .source_dir ):
420
- logger .debug ('Removing source in %s' , self .source_dir )
421
- rmtree (self .source_dir )
422
- self .source_dir = None
423
- self ._temp_build_dir = None
424
-
425
419
def check_if_exists (self , use_user_site ):
426
420
# type: (bool) -> None
427
421
"""Find an installed distribution that satisfies or conflicts
@@ -599,8 +593,8 @@ def assert_source_matches_version(self):
599
593
)
600
594
601
595
# For both source distributions and editables
602
- def ensure_has_source_dir (self , parent_dir ):
603
- # type: (str) -> None
596
+ def ensure_has_source_dir (self , parent_dir , autodelete = False ):
597
+ # type: (str, bool ) -> None
604
598
"""Ensure that a source_dir is set.
605
599
606
600
This will create a temporary build dir if the name of the requirement
@@ -611,7 +605,9 @@ def ensure_has_source_dir(self, parent_dir):
611
605
:return: self.source_dir
612
606
"""
613
607
if self .source_dir is None :
614
- self .source_dir = self .ensure_build_location (parent_dir )
608
+ self .source_dir = self .ensure_build_location (
609
+ parent_dir , autodelete
610
+ )
615
611
616
612
# For editable installations
617
613
def update_editable (self , obtain = True ):
@@ -755,8 +751,6 @@ def archive(self, build_dir):
755
751
zipdir .external_attr = 0x1ED << 16 # 0o755
756
752
zip_output .writestr (zipdir , '' )
757
753
for filename in filenames :
758
- if filename == PIP_DELETE_MARKER_FILENAME :
759
- continue
760
754
file_arcname = self ._get_archive_name (
761
755
filename , parentdir = dirpath , rootdir = dir ,
762
756
)
0 commit comments