35
35
class InstallRequirement (object ):
36
36
37
37
def __init__ (self , req , comes_from , source_dir = None , editable = False ,
38
- url = None , update = True ):
38
+ url = None , as_egg = False , update = True ):
39
39
self .extras = ()
40
40
if isinstance (req , string_types ):
41
41
req = pkg_resources .Requirement .parse (req )
@@ -45,6 +45,7 @@ def __init__(self, req, comes_from, source_dir=None, editable=False,
45
45
self .source_dir = source_dir
46
46
self .editable = editable
47
47
self .url = url
48
+ self .as_egg = as_egg
48
49
self ._egg_info_path = None
49
50
# This holds the pkg_resources.Distribution object if this requirement
50
51
# is already available:
@@ -556,6 +557,7 @@ def install(self, install_options, global_options=()):
556
557
if self .editable :
557
558
self .install_editable (install_options , global_options )
558
559
return
560
+
559
561
temp_location = tempfile .mkdtemp ('-record' , 'pip-' )
560
562
record_filename = os .path .join (temp_location , 'install-record.txt' )
561
563
try :
@@ -565,9 +567,11 @@ def install(self, install_options, global_options=()):
565
567
"exec(compile(open(__file__).read().replace('\\ r\\ n', '\\ n'), __file__, 'exec'))" % self .setup_py ] + \
566
568
list (global_options ) + [
567
569
'install' ,
568
- '--single-version-externally-managed' ,
569
570
'--record' , record_filename ]
570
571
572
+ if not self .as_egg :
573
+ install_args += ['--single-version-externally-managed' ]
574
+
571
575
if running_under_virtualenv ():
572
576
## FIXME: I'm not sure if this is a reasonable location; probably not
573
577
## but we can't put it in the default location, as that is a virtualenv symlink that isn't writable
@@ -585,6 +589,11 @@ def install(self, install_options, global_options=()):
585
589
logger .notify ('Record file %s not found' % record_filename )
586
590
return
587
591
self .install_succeeded = True
592
+ if self .as_egg :
593
+ # there's no --always-unzip option we can pass to install command
594
+ # so we unable to save the installed-files.txt
595
+ return
596
+
588
597
f = open (record_filename )
589
598
for line in f :
590
599
line = line .strip ()
@@ -781,7 +790,7 @@ def __repr__(self):
781
790
class RequirementSet (object ):
782
791
783
792
def __init__ (self , build_dir , src_dir , download_dir , download_cache = None ,
784
- upgrade = False , ignore_installed = False ,
793
+ upgrade = False , ignore_installed = False , as_egg = False ,
785
794
ignore_dependencies = False , force_reinstall = False ):
786
795
self .build_dir = build_dir
787
796
self .src_dir = src_dir
@@ -798,6 +807,7 @@ def __init__(self, build_dir, src_dir, download_dir, download_cache=None,
798
807
self .successfully_downloaded = []
799
808
self .successfully_installed = []
800
809
self .reqs_to_cleanup = []
810
+ self .as_egg = as_egg
801
811
802
812
def __str__ (self ):
803
813
reqs = [req for req in self .requirements .values ()
@@ -807,6 +817,7 @@ def __str__(self):
807
817
808
818
def add_requirement (self , install_req ):
809
819
name = install_req .name
820
+ install_req .as_egg = self .as_egg
810
821
if not name :
811
822
self .unnamed_requirements .append (install_req )
812
823
else :
0 commit comments