@@ -245,6 +245,15 @@ def get_backend_from_location(self, location):
245
245
help = 'Include site-packages in virtualenv if one is to be '
246
246
'created. Ignored if --environment is not used or '
247
247
'the virtualenv already exists.' )
248
+ parser .add_option (
249
+ # Defines a default root directory for virtualenvs, relative
250
+ # virtualenvs names/paths are considered relative to it.
251
+ '--virtualenv-base' ,
252
+ dest = 'venv_base' ,
253
+ type = 'str' ,
254
+ default = '' ,
255
+ help = optparse .SUPPRESS_HELP )
256
+
248
257
parser .add_option (
249
258
'-v' , '--verbose' ,
250
259
dest = 'verbose' ,
@@ -262,6 +271,21 @@ def get_backend_from_location(self, location):
262
271
dest = 'log' ,
263
272
metavar = 'FILENAME' ,
264
273
help = 'Log file where a complete (maximum verbosity) record will be kept' )
274
+ parser .add_option (
275
+ # Writes the log levels explicitely to the log'
276
+ '--log-explicit-levels' ,
277
+ dest = 'log_explicit_levels' ,
278
+ action = 'store_true' ,
279
+ default = False ,
280
+ help = optparse .SUPPRESS_HELP )
281
+ parser .add_option (
282
+ # The default log file
283
+ '--local-log' , '--log-file' ,
284
+ dest = 'log_file' ,
285
+ metavar = 'FILENAME' ,
286
+ default = './pip-log.txt' ,
287
+ help = optparse .SUPPRESS_HELP )
288
+
265
289
parser .add_option (
266
290
'--proxy' ,
267
291
dest = 'proxy' ,
@@ -270,30 +294,35 @@ def get_backend_from_location(self, location):
270
294
help = "Specify a proxy in the form user:[email protected] :port. "
271
295
"Note that the user:password@ is optional and required only if you "
272
296
"are behind an authenticated proxy. If you provide "
273
- "[email protected] :port then you will be prompted for a password."
274
- )
275
-
276
- default_timeout = parser .get_from_config ('default-timeout' , 15 )
297
+ "[email protected] :port then you will be prompted for a password." )
277
298
parser .add_option (
278
- '--timeout' ,
299
+ '--timeout' , '--default-timeout' ,
279
300
metavar = 'SECONDS' ,
280
301
dest = 'timeout' ,
281
302
type = 'float' ,
282
- default = default_timeout ,
283
- help = 'Set the socket timeout (default %s seconds)' % default_timeout )
303
+ default = 15 ,
304
+ help = 'Set the socket timeout (default %default seconds)' )
305
+ parser .add_option (
306
+ # The default version control system for editables, e.g. 'svn'
307
+ '--default-vcs' ,
308
+ dest = 'default_vcs' ,
309
+ type = 'str' ,
310
+ default = '' ,
311
+ help = optparse .SUPPRESS_HELP )
312
+ parser .add_option (
313
+ # A regex to be used to skip requirements
314
+ '--skip-requirements-regex' ,
315
+ dest = 'skip_requirements_regex' ,
316
+ type = 'str' ,
317
+ default = '' ,
318
+ help = optparse .SUPPRESS_HELP )
284
319
285
320
parser .disable_interspersed_args ()
286
321
287
- default_vcs = parser .get_from_config ('default-vcs' )
288
- virtualenv_base = parser .get_from_config ('virtualenv-base' )
289
- pypi_url = parser .get_from_config ('pypi-url' , 'http://pypi.python.org/simple' )
290
-
291
322
if getattr (sys , 'real_prefix' , None ):
292
323
## FIXME: is build/ a good name?
293
- build_prefix = parser .get_from_config (
294
- 'build-prefix' , os .path .join (sys .prefix , 'build' ))
295
- src_prefix = parser .get_from_config (
296
- 'src-prefix' , os .path .join (sys .prefix , 'src' ))
324
+ build_prefix = os .path .join (sys .prefix , 'build' )
325
+ src_prefix = os .path .join (sys .prefix , 'src' )
297
326
else :
298
327
## FIXME: this isn't a very good default
299
328
build_prefix = os .path .join (os .getcwd (), 'build' )
@@ -342,7 +371,7 @@ def main(self, complete_args, args, initial_options):
342
371
complete_log = []
343
372
logger = Logger ([(level , sys .stdout ),
344
373
(Logger .DEBUG , complete_log .append )])
345
- if self . parser . get_from_config ( 'log-explicit-levels' ) :
374
+ if options . log_explicit_levels :
346
375
logger .explicit_levels = True
347
376
if options .venv :
348
377
if options .verbose > 0 :
@@ -351,7 +380,8 @@ def main(self, complete_args, args, initial_options):
351
380
site_packages = False
352
381
if options .site_packages :
353
382
site_packages = True
354
- restart_in_venv (options .venv , site_packages , complete_args )
383
+ restart_in_venv (options .venv , options .venv_base , site_packages ,
384
+ complete_args )
355
385
# restart_in_venv should actually never return, but for clarity...
356
386
return
357
387
## FIXME: not sure if this sure come before or after venv restart
@@ -379,7 +409,7 @@ def main(self, complete_args, args, initial_options):
379
409
if log_fp is not None :
380
410
log_fp .close ()
381
411
if exit :
382
- log_fn = self . parser . get_from_config ( 'log-file' , './pip-log.txt' )
412
+ log_fn = options . log_file
383
413
text = '\n ' .join (complete_log )
384
414
logger .fatal ('Storing complete log in %s' % log_fn )
385
415
log_fp = open_logfile_append (log_fn )
@@ -446,10 +476,10 @@ def __init__(self):
446
476
metavar = 'URL' ,
447
477
help = 'URL to look for packages at' )
448
478
self .parser .add_option (
449
- '-i' , '--index-url' ,
479
+ '-i' , '--index-url' , '--pypi-url' ,
450
480
dest = 'index_url' ,
451
481
metavar = 'URL' ,
452
- default = pypi_url ,
482
+ default = 'http://pypi.python.org/simple' ,
453
483
help = 'base URL of Python Package Index' )
454
484
self .parser .add_option (
455
485
'--extra-index-url' ,
@@ -477,6 +507,13 @@ def __init__(self):
477
507
metavar = 'DIR' ,
478
508
default = None ,
479
509
help = 'Download packages into DIR instead of installing them' )
510
+ self .parser .add_option (
511
+ # Cache downloaded packages in DIR
512
+ '--download-cache' ,
513
+ dest = 'download_cache' ,
514
+ metavar = 'DIR' ,
515
+ default = None ,
516
+ help = optparse .SUPPRESS_HELP )
480
517
self .parser .add_option (
481
518
'--src' , '--source' , '--source-dir' , '--source-directory' ,
482
519
dest = 'src_dir' ,
@@ -539,6 +576,7 @@ def run(self, options, args):
539
576
build_dir = options .build_dir ,
540
577
src_dir = options .src_dir ,
541
578
download_dir = options .download_dir ,
579
+ download_cache = options .download_cache ,
542
580
upgrade = options .upgrade ,
543
581
ignore_installed = options .ignore_installed ,
544
582
ignore_dependencies = options .ignore_dependencies )
@@ -547,9 +585,9 @@ def run(self, options, args):
547
585
InstallRequirement .from_line (name , None ))
548
586
for name in options .editables :
549
587
requirement_set .add_requirement (
550
- InstallRequirement .from_editable (name ))
588
+ InstallRequirement .from_editable (name , default_vcs = options . default_vcs ))
551
589
for filename in options .requirements :
552
- for req in parse_requirements (filename , finder = finder ):
590
+ for req in parse_requirements (filename , finder = finder , options = options ):
553
591
requirement_set .add_requirement (req )
554
592
requirement_set .install_files (finder , force_root_egg_info = self .bundle )
555
593
if not options .no_install and not self .bundle :
@@ -597,7 +635,7 @@ def run(self, options, args):
597
635
requirement_set .add_requirement (
598
636
InstallRequirement .from_line (name ))
599
637
for filename in options .requirements :
600
- for req in parse_requirements (filename ):
638
+ for req in parse_requirements (filename , options = options ):
601
639
requirement_set .add_requirement (req )
602
640
requirement_set .uninstall (auto_confirm = options .yes )
603
641
@@ -663,7 +701,7 @@ def run(self, options, args):
663
701
find_tags = False
664
702
skip_match = None
665
703
666
- skip_regex = self . parser . get_from_config ( 'skip-requirements-regex' )
704
+ skip_regex = options . skip_requirements_regex
667
705
if skip_regex :
668
706
skip_match = re .compile (skip_regex )
669
707
@@ -701,7 +739,7 @@ def run(self, options, args):
701
739
line = line [2 :].strip ()
702
740
else :
703
741
line = line [len ('--editable' ):].strip ().lstrip ('=' )
704
- line_req = InstallRequirement .from_editable (line )
742
+ line_req = InstallRequirement .from_editable (line , default_vcs = options . default_vcs )
705
743
elif (line .startswith ('-r' ) or line .startswith ('--requirement' )
706
744
or line .startswith ('-Z' ) or line .startswith ('--always-unzip' )):
707
745
logger .debug ('Skipping line %r' % line .strip ())
@@ -1121,14 +1159,12 @@ def format_exc(exc_info=None):
1121
1159
traceback .print_exception (* exc_info , ** dict (file = out ))
1122
1160
return out .getvalue ()
1123
1161
1124
- def restart_in_venv (venv , site_packages , args ):
1162
+ def restart_in_venv (venv , base , site_packages , args ):
1125
1163
"""
1126
1164
Restart this script using the interpreter in the given virtual environment
1127
1165
"""
1128
- if virtualenv_base \
1129
- and not os .path .isabs (venv )\
1130
- and not venv .startswith ('~' ):
1131
- base = os .path .expanduser (virtualenv_base )
1166
+ if base and not os .path .isabs (venv ) and not venv .startswith ('~' ):
1167
+ base = os .path .expanduser (base )
1132
1168
# ensure we have an abs basepath at this point:
1133
1169
# a relative one makes no sense (or does it?)
1134
1170
if os .path .isabs (base ):
@@ -1458,8 +1494,8 @@ def __init__(self, req, comes_from, source_dir=None, editable=False,
1458
1494
self .uninstalled = None
1459
1495
1460
1496
@classmethod
1461
- def from_editable (cls , editable_req , comes_from = None ):
1462
- name , url = parse_editable (editable_req )
1497
+ def from_editable (cls , editable_req , comes_from = None , default_vcs = None ):
1498
+ name , url = parse_editable (editable_req , default_vcs )
1463
1499
if url .startswith ('file:' ):
1464
1500
source_dir = url_to_filename (url )
1465
1501
else :
@@ -2069,10 +2105,13 @@ def delete_marker_filename(self):
2069
2105
2070
2106
class RequirementSet (object ):
2071
2107
2072
- def __init__ (self , build_dir , src_dir , download_dir , upgrade = False , ignore_installed = False , ignore_dependencies = False ):
2108
+ def __init__ (self , build_dir , src_dir , download_dir , download_cache = None ,
2109
+ upgrade = False , ignore_installed = False ,
2110
+ ignore_dependencies = False ):
2073
2111
self .build_dir = build_dir
2074
2112
self .src_dir = src_dir
2075
2113
self .download_dir = download_dir
2114
+ self .download_cache = download_cache
2076
2115
self .upgrade = upgrade
2077
2116
self .ignore_installed = ignore_installed
2078
2117
self .requirements = {}
@@ -2273,9 +2312,8 @@ def unpack_url(self, link, location, only_download=False):
2273
2312
md5_hash = link .md5_hash
2274
2313
target_url = link .url .split ('#' , 1 )[0 ]
2275
2314
target_file = None
2276
- download_cache = self .parser .get_from_config ('download-cache' )
2277
- if download_cache :
2278
- target_file = os .path .join (download_cache ,
2315
+ if self .download_cache :
2316
+ target_file = os .path .join (self .download_cache ,
2279
2317
urllib .quote (target_url , '' ))
2280
2318
if (target_file and os .path .exists (target_file )
2281
2319
and os .path .exists (target_file + '.content-type' )):
@@ -3820,9 +3858,9 @@ def get_file_content(url, comes_from=None):
3820
3858
f .close ()
3821
3859
return url , content
3822
3860
3823
- def parse_requirements (filename , finder = None , comes_from = None ):
3861
+ def parse_requirements (filename , finder = None , comes_from = None , options = None ):
3824
3862
skip_match = None
3825
- skip_regex = self . parser . get_from_config ( 'skip-requirements-regex' )
3863
+ skip_regex = options . skip_requirements_regex
3826
3864
if skip_regex :
3827
3865
skip_match = re .compile (skip_regex )
3828
3866
filename , content = get_file_content (filename , comes_from = comes_from )
@@ -3843,7 +3881,7 @@ def parse_requirements(filename, finder=None, comes_from=None):
3843
3881
req_url = urlparse .urljoin (filename , url )
3844
3882
elif not _scheme_re .search (req_url ):
3845
3883
req_url = os .path .join (os .path .dirname (filename ), req_url )
3846
- for item in parse_requirements (req_url , finder , comes_from = filename ):
3884
+ for item in parse_requirements (req_url , finder , comes_from = filename , options = options ):
3847
3885
yield item
3848
3886
elif line .startswith ('-Z' ) or line .startswith ('--always-unzip' ):
3849
3887
# No longer used, but previously these were used in
@@ -3874,7 +3912,7 @@ def parse_requirements(filename, finder=None, comes_from=None):
3874
3912
else :
3875
3913
line = line [len ('--editable' ):].strip ()
3876
3914
req = InstallRequirement .from_editable (
3877
- line , comes_from )
3915
+ line , comes_from = comes_from , default_vcs = options . default_vcs )
3878
3916
else :
3879
3917
req = InstallRequirement .from_line (line , comes_from )
3880
3918
yield req
@@ -4224,7 +4262,7 @@ def display_path(path):
4224
4262
path = '.' + path [len (os .getcwd ()):]
4225
4263
return path
4226
4264
4227
- def parse_editable (editable_req ):
4265
+ def parse_editable (editable_req , default_vcs = None ):
4228
4266
"""Parses svn+http://blahblah@rev#egg=Foobar into a requirement
4229
4267
(Foobar) and a URL"""
4230
4268
url = editable_req
@@ -4571,6 +4609,7 @@ def find_command(cmd, paths=None, pathext=None):
4571
4609
return cmd_path
4572
4610
return None
4573
4611
4612
+
4574
4613
class _Inf (object ):
4575
4614
"""I am bigger than everything!"""
4576
4615
def __cmp__ (self , a ):
0 commit comments