@@ -223,7 +223,7 @@ def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
223
223
force_copy = not self .symlinks
224
224
if not force_copy :
225
225
try :
226
- if not os .path .islink (dst ): # can't link to itself!
226
+ if not os .path .islink (dst ): # can't link to itself!
227
227
if relative_symlinks_ok :
228
228
assert os .path .dirname (src ) == os .path .dirname (dst )
229
229
os .symlink (os .path .basename (src ), dst )
@@ -418,11 +418,11 @@ def install_scripts(self, context, path):
418
418
binpath = context .bin_path
419
419
plen = len (path )
420
420
for root , dirs , files in os .walk (path ):
421
- if root == path : # at top-level, remove irrelevant dirs
421
+ if root == path : # at top-level, remove irrelevant dirs
422
422
for d in dirs [:]:
423
423
if d not in ('common' , os .name ):
424
424
dirs .remove (d )
425
- continue # ignore files in top level
425
+ continue # ignore files in top level
426
426
for f in files :
427
427
if (os .name == 'nt' and f .startswith ('python' )
428
428
and f .endswith (('.exe' , '.pdb' ))):
@@ -468,83 +468,76 @@ def create(env_dir, system_site_packages=False, clear=False,
468
468
prompt = prompt , upgrade_deps = upgrade_deps )
469
469
builder .create (env_dir )
470
470
471
+
471
472
def main (args = None ):
472
- compatible = True
473
- if sys .version_info < (3 , 3 ):
474
- compatible = False
475
- elif not hasattr (sys , 'base_prefix' ):
476
- compatible = False
477
- if not compatible :
478
- raise ValueError ('This script is only for use with Python >= 3.3' )
473
+ import argparse
474
+
475
+ parser = argparse .ArgumentParser (prog = __name__ ,
476
+ description = 'Creates virtual Python '
477
+ 'environments in one or '
478
+ 'more target '
479
+ 'directories.' ,
480
+ epilog = 'Once an environment has been '
481
+ 'created, you may wish to '
482
+ 'activate it, e.g. by '
483
+ 'sourcing an activate script '
484
+ 'in its bin directory.' )
485
+ parser .add_argument ('dirs' , metavar = 'ENV_DIR' , nargs = '+' ,
486
+ help = 'A directory to create the environment in.' )
487
+ parser .add_argument ('--system-site-packages' , default = False ,
488
+ action = 'store_true' , dest = 'system_site' ,
489
+ help = 'Give the virtual environment access to the '
490
+ 'system site-packages dir.' )
491
+ if os .name == 'nt' :
492
+ use_symlinks = False
479
493
else :
480
- import argparse
481
-
482
- parser = argparse .ArgumentParser (prog = __name__ ,
483
- description = 'Creates virtual Python '
484
- 'environments in one or '
485
- 'more target '
486
- 'directories.' ,
487
- epilog = 'Once an environment has been '
488
- 'created, you may wish to '
489
- 'activate it, e.g. by '
490
- 'sourcing an activate script '
491
- 'in its bin directory.' )
492
- parser .add_argument ('dirs' , metavar = 'ENV_DIR' , nargs = '+' ,
493
- help = 'A directory to create the environment in.' )
494
- parser .add_argument ('--system-site-packages' , default = False ,
495
- action = 'store_true' , dest = 'system_site' ,
496
- help = 'Give the virtual environment access to the '
497
- 'system site-packages dir.' )
498
- if os .name == 'nt' :
499
- use_symlinks = False
500
- else :
501
- use_symlinks = True
502
- group = parser .add_mutually_exclusive_group ()
503
- group .add_argument ('--symlinks' , default = use_symlinks ,
504
- action = 'store_true' , dest = 'symlinks' ,
505
- help = 'Try to use symlinks rather than copies, '
506
- 'when symlinks are not the default for '
507
- 'the platform.' )
508
- group .add_argument ('--copies' , default = not use_symlinks ,
509
- action = 'store_false' , dest = 'symlinks' ,
510
- help = 'Try to use copies rather than symlinks, '
511
- 'even when symlinks are the default for '
512
- 'the platform.' )
513
- parser .add_argument ('--clear' , default = False , action = 'store_true' ,
514
- dest = 'clear' , help = 'Delete the contents of the '
515
- 'environment directory if it '
516
- 'already exists, before '
517
- 'environment creation.' )
518
- parser .add_argument ('--upgrade' , default = False , action = 'store_true' ,
519
- dest = 'upgrade' , help = 'Upgrade the environment '
520
- 'directory to use this version '
521
- 'of Python, assuming Python '
522
- 'has been upgraded in-place.' )
523
- parser .add_argument ('--without-pip' , dest = 'with_pip' ,
524
- default = True , action = 'store_false' ,
525
- help = 'Skips installing or upgrading pip in the '
526
- 'virtual environment (pip is bootstrapped '
527
- 'by default)' )
528
- parser .add_argument ('--prompt' ,
529
- help = 'Provides an alternative prompt prefix for '
530
- 'this environment.' )
531
- parser .add_argument ('--upgrade-deps' , default = False , action = 'store_true' ,
532
- dest = 'upgrade_deps' ,
533
- help = 'Upgrade core dependencies: {} to the latest '
534
- 'version in PyPI' .format (
535
- ' ' .join (CORE_VENV_DEPS )))
536
- options = parser .parse_args (args )
537
- if options .upgrade and options .clear :
538
- raise ValueError ('you cannot supply --upgrade and --clear together.' )
539
- builder = EnvBuilder (system_site_packages = options .system_site ,
540
- clear = options .clear ,
541
- symlinks = options .symlinks ,
542
- upgrade = options .upgrade ,
543
- with_pip = options .with_pip ,
544
- prompt = options .prompt ,
545
- upgrade_deps = options .upgrade_deps )
546
- for d in options .dirs :
547
- builder .create (d )
494
+ use_symlinks = True
495
+ group = parser .add_mutually_exclusive_group ()
496
+ group .add_argument ('--symlinks' , default = use_symlinks ,
497
+ action = 'store_true' , dest = 'symlinks' ,
498
+ help = 'Try to use symlinks rather than copies, '
499
+ 'when symlinks are not the default for '
500
+ 'the platform.' )
501
+ group .add_argument ('--copies' , default = not use_symlinks ,
502
+ action = 'store_false' , dest = 'symlinks' ,
503
+ help = 'Try to use copies rather than symlinks, '
504
+ 'even when symlinks are the default for '
505
+ 'the platform.' )
506
+ parser .add_argument ('--clear' , default = False , action = 'store_true' ,
507
+ dest = 'clear' , help = 'Delete the contents of the '
508
+ 'environment directory if it '
509
+ 'already exists, before '
510
+ 'environment creation.' )
511
+ parser .add_argument ('--upgrade' , default = False , action = 'store_true' ,
512
+ dest = 'upgrade' , help = 'Upgrade the environment '
513
+ 'directory to use this version '
514
+ 'of Python, assuming Python '
515
+ 'has been upgraded in-place.' )
516
+ parser .add_argument ('--without-pip' , dest = 'with_pip' ,
517
+ default = True , action = 'store_false' ,
518
+ help = 'Skips installing or upgrading pip in the '
519
+ 'virtual environment (pip is bootstrapped '
520
+ 'by default)' )
521
+ parser .add_argument ('--prompt' ,
522
+ help = 'Provides an alternative prompt prefix for '
523
+ 'this environment.' )
524
+ parser .add_argument ('--upgrade-deps' , default = False , action = 'store_true' ,
525
+ dest = 'upgrade_deps' ,
526
+ help = f'Upgrade core dependencies: { " " .join (CORE_VENV_DEPS )} '
527
+ 'to the latest version in PyPI' )
528
+ options = parser .parse_args (args )
529
+ if options .upgrade and options .clear :
530
+ raise ValueError ('you cannot supply --upgrade and --clear together.' )
531
+ builder = EnvBuilder (system_site_packages = options .system_site ,
532
+ clear = options .clear ,
533
+ symlinks = options .symlinks ,
534
+ upgrade = options .upgrade ,
535
+ with_pip = options .with_pip ,
536
+ prompt = options .prompt ,
537
+ upgrade_deps = options .upgrade_deps )
538
+ for d in options .dirs :
539
+ builder .create (d )
540
+
548
541
549
542
if __name__ == '__main__' :
550
543
rc = 1
0 commit comments