Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python3..../venv
File: __init__.py
"""
[0] Fix | Delete
Virtual environment (venv) package for Python. Based on PEP 405.
[1] Fix | Delete
[2] Fix | Delete
Copyright (C) 2011-2014 Vinay Sajip.
[3] Fix | Delete
Licensed to the PSF under a contributor agreement.
[4] Fix | Delete
"""
[5] Fix | Delete
import logging
[6] Fix | Delete
import os
[7] Fix | Delete
import shutil
[8] Fix | Delete
import subprocess
[9] Fix | Delete
import sys
[10] Fix | Delete
import sysconfig
[11] Fix | Delete
import types
[12] Fix | Delete
[13] Fix | Delete
logger = logging.getLogger(__name__)
[14] Fix | Delete
[15] Fix | Delete
[16] Fix | Delete
class EnvBuilder:
[17] Fix | Delete
"""
[18] Fix | Delete
This class exists to allow virtual environment creation to be
[19] Fix | Delete
customized. The constructor parameters determine the builder's
[20] Fix | Delete
behaviour when called upon to create a virtual environment.
[21] Fix | Delete
[22] Fix | Delete
By default, the builder makes the system (global) site-packages dir
[23] Fix | Delete
*un*available to the created environment.
[24] Fix | Delete
[25] Fix | Delete
If invoked using the Python -m option, the default is to use copying
[26] Fix | Delete
on Windows platforms but symlinks elsewhere. If instantiated some
[27] Fix | Delete
other way, the default is to *not* use symlinks.
[28] Fix | Delete
[29] Fix | Delete
:param system_site_packages: If True, the system (global) site-packages
[30] Fix | Delete
dir is available to created environments.
[31] Fix | Delete
:param clear: If True, delete the contents of the environment directory if
[32] Fix | Delete
it already exists, before environment creation.
[33] Fix | Delete
:param symlinks: If True, attempt to symlink rather than copy files into
[34] Fix | Delete
virtual environment.
[35] Fix | Delete
:param upgrade: If True, upgrade an existing virtual environment.
[36] Fix | Delete
:param with_pip: If True, ensure pip is installed in the virtual
[37] Fix | Delete
environment
[38] Fix | Delete
:param prompt: Alternative terminal prefix for the environment.
[39] Fix | Delete
"""
[40] Fix | Delete
[41] Fix | Delete
def __init__(self, system_site_packages=False, clear=False,
[42] Fix | Delete
symlinks=False, upgrade=False, with_pip=False, prompt=None):
[43] Fix | Delete
self.system_site_packages = system_site_packages
[44] Fix | Delete
self.clear = clear
[45] Fix | Delete
self.symlinks = symlinks
[46] Fix | Delete
self.upgrade = upgrade
[47] Fix | Delete
self.with_pip = with_pip
[48] Fix | Delete
self.prompt = prompt
[49] Fix | Delete
[50] Fix | Delete
def create(self, env_dir):
[51] Fix | Delete
"""
[52] Fix | Delete
Create a virtual environment in a directory.
[53] Fix | Delete
[54] Fix | Delete
:param env_dir: The target directory to create an environment in.
[55] Fix | Delete
[56] Fix | Delete
"""
[57] Fix | Delete
env_dir = os.path.abspath(env_dir)
[58] Fix | Delete
context = self.ensure_directories(env_dir)
[59] Fix | Delete
# See issue 24875. We need system_site_packages to be False
[60] Fix | Delete
# until after pip is installed.
[61] Fix | Delete
true_system_site_packages = self.system_site_packages
[62] Fix | Delete
self.system_site_packages = False
[63] Fix | Delete
self.create_configuration(context)
[64] Fix | Delete
self.setup_python(context)
[65] Fix | Delete
if self.with_pip:
[66] Fix | Delete
self._setup_pip(context)
[67] Fix | Delete
if not self.upgrade:
[68] Fix | Delete
self.setup_scripts(context)
[69] Fix | Delete
self.post_setup(context)
[70] Fix | Delete
if true_system_site_packages:
[71] Fix | Delete
# We had set it to False before, now
[72] Fix | Delete
# restore it and rewrite the configuration
[73] Fix | Delete
self.system_site_packages = True
[74] Fix | Delete
self.create_configuration(context)
[75] Fix | Delete
[76] Fix | Delete
def clear_directory(self, path):
[77] Fix | Delete
for fn in os.listdir(path):
[78] Fix | Delete
fn = os.path.join(path, fn)
[79] Fix | Delete
if os.path.islink(fn) or os.path.isfile(fn):
[80] Fix | Delete
os.remove(fn)
[81] Fix | Delete
elif os.path.isdir(fn):
[82] Fix | Delete
shutil.rmtree(fn)
[83] Fix | Delete
[84] Fix | Delete
def ensure_directories(self, env_dir):
[85] Fix | Delete
"""
[86] Fix | Delete
Create the directories for the environment.
[87] Fix | Delete
[88] Fix | Delete
Returns a context object which holds paths in the environment,
[89] Fix | Delete
for use by subsequent logic.
[90] Fix | Delete
"""
[91] Fix | Delete
[92] Fix | Delete
def create_if_needed(d):
[93] Fix | Delete
if not os.path.exists(d):
[94] Fix | Delete
os.makedirs(d)
[95] Fix | Delete
elif os.path.islink(d) or os.path.isfile(d):
[96] Fix | Delete
raise ValueError('Unable to create directory %r' % d)
[97] Fix | Delete
[98] Fix | Delete
if os.path.exists(env_dir) and self.clear:
[99] Fix | Delete
self.clear_directory(env_dir)
[100] Fix | Delete
context = types.SimpleNamespace()
[101] Fix | Delete
context.env_dir = env_dir
[102] Fix | Delete
context.env_name = os.path.split(env_dir)[1]
[103] Fix | Delete
prompt = self.prompt if self.prompt is not None else context.env_name
[104] Fix | Delete
context.prompt = '(%s) ' % prompt
[105] Fix | Delete
create_if_needed(env_dir)
[106] Fix | Delete
executable = sys._base_executable
[107] Fix | Delete
dirname, exename = os.path.split(os.path.abspath(executable))
[108] Fix | Delete
context.executable = executable
[109] Fix | Delete
context.python_dir = dirname
[110] Fix | Delete
context.python_exe = exename
[111] Fix | Delete
if sys.platform == 'win32':
[112] Fix | Delete
binname = 'Scripts'
[113] Fix | Delete
incpath = 'Include'
[114] Fix | Delete
libpath = os.path.join(env_dir, 'Lib', 'site-packages')
[115] Fix | Delete
else:
[116] Fix | Delete
binname = 'bin'
[117] Fix | Delete
incpath = 'include'
[118] Fix | Delete
libpath = os.path.join(env_dir, 'lib',
[119] Fix | Delete
'python%d.%d' % sys.version_info[:2],
[120] Fix | Delete
'site-packages')
[121] Fix | Delete
context.inc_path = path = os.path.join(env_dir, incpath)
[122] Fix | Delete
create_if_needed(path)
[123] Fix | Delete
create_if_needed(libpath)
[124] Fix | Delete
# Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
[125] Fix | Delete
if ((sys.maxsize > 2**32) and (os.name == 'posix') and
[126] Fix | Delete
(sys.platform != 'darwin')):
[127] Fix | Delete
link_path = os.path.join(env_dir, 'lib64')
[128] Fix | Delete
if not os.path.exists(link_path): # Issue #21643
[129] Fix | Delete
os.symlink('lib', link_path)
[130] Fix | Delete
context.bin_path = binpath = os.path.join(env_dir, binname)
[131] Fix | Delete
context.bin_name = binname
[132] Fix | Delete
context.env_exe = os.path.join(binpath, exename)
[133] Fix | Delete
create_if_needed(binpath)
[134] Fix | Delete
return context
[135] Fix | Delete
[136] Fix | Delete
def create_configuration(self, context):
[137] Fix | Delete
"""
[138] Fix | Delete
Create a configuration file indicating where the environment's Python
[139] Fix | Delete
was copied from, and whether the system site-packages should be made
[140] Fix | Delete
available in the environment.
[141] Fix | Delete
[142] Fix | Delete
:param context: The information for the environment creation request
[143] Fix | Delete
being processed.
[144] Fix | Delete
"""
[145] Fix | Delete
context.cfg_path = path = os.path.join(context.env_dir, 'pyvenv.cfg')
[146] Fix | Delete
with open(path, 'w', encoding='utf-8') as f:
[147] Fix | Delete
f.write('home = %s\n' % context.python_dir)
[148] Fix | Delete
if self.system_site_packages:
[149] Fix | Delete
incl = 'true'
[150] Fix | Delete
else:
[151] Fix | Delete
incl = 'false'
[152] Fix | Delete
f.write('include-system-site-packages = %s\n' % incl)
[153] Fix | Delete
f.write('version = %d.%d.%d\n' % sys.version_info[:3])
[154] Fix | Delete
if self.prompt is not None:
[155] Fix | Delete
f.write(f'prompt = {self.prompt!r}\n')
[156] Fix | Delete
[157] Fix | Delete
if os.name != 'nt':
[158] Fix | Delete
def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
[159] Fix | Delete
"""
[160] Fix | Delete
Try symlinking a file, and if that fails, fall back to copying.
[161] Fix | Delete
"""
[162] Fix | Delete
force_copy = not self.symlinks
[163] Fix | Delete
if not force_copy:
[164] Fix | Delete
try:
[165] Fix | Delete
if not os.path.islink(dst): # can't link to itself!
[166] Fix | Delete
if relative_symlinks_ok:
[167] Fix | Delete
assert os.path.dirname(src) == os.path.dirname(dst)
[168] Fix | Delete
os.symlink(os.path.basename(src), dst)
[169] Fix | Delete
else:
[170] Fix | Delete
os.symlink(src, dst)
[171] Fix | Delete
except Exception: # may need to use a more specific exception
[172] Fix | Delete
logger.warning('Unable to symlink %r to %r', src, dst)
[173] Fix | Delete
force_copy = True
[174] Fix | Delete
if force_copy:
[175] Fix | Delete
shutil.copyfile(src, dst)
[176] Fix | Delete
else:
[177] Fix | Delete
def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
[178] Fix | Delete
"""
[179] Fix | Delete
Try symlinking a file, and if that fails, fall back to copying.
[180] Fix | Delete
"""
[181] Fix | Delete
bad_src = os.path.lexists(src) and not os.path.exists(src)
[182] Fix | Delete
if self.symlinks and not bad_src and not os.path.islink(dst):
[183] Fix | Delete
try:
[184] Fix | Delete
if relative_symlinks_ok:
[185] Fix | Delete
assert os.path.dirname(src) == os.path.dirname(dst)
[186] Fix | Delete
os.symlink(os.path.basename(src), dst)
[187] Fix | Delete
else:
[188] Fix | Delete
os.symlink(src, dst)
[189] Fix | Delete
return
[190] Fix | Delete
except Exception: # may need to use a more specific exception
[191] Fix | Delete
logger.warning('Unable to symlink %r to %r', src, dst)
[192] Fix | Delete
[193] Fix | Delete
# On Windows, we rewrite symlinks to our base python.exe into
[194] Fix | Delete
# copies of venvlauncher.exe
[195] Fix | Delete
basename, ext = os.path.splitext(os.path.basename(src))
[196] Fix | Delete
srcfn = os.path.join(os.path.dirname(__file__),
[197] Fix | Delete
"scripts",
[198] Fix | Delete
"nt",
[199] Fix | Delete
basename + ext)
[200] Fix | Delete
# Builds or venv's from builds need to remap source file
[201] Fix | Delete
# locations, as we do not put them into Lib/venv/scripts
[202] Fix | Delete
if sysconfig.is_python_build(True) or not os.path.isfile(srcfn):
[203] Fix | Delete
if basename.endswith('_d'):
[204] Fix | Delete
ext = '_d' + ext
[205] Fix | Delete
basename = basename[:-2]
[206] Fix | Delete
if basename == 'python':
[207] Fix | Delete
basename = 'venvlauncher'
[208] Fix | Delete
elif basename == 'pythonw':
[209] Fix | Delete
basename = 'venvwlauncher'
[210] Fix | Delete
src = os.path.join(os.path.dirname(src), basename + ext)
[211] Fix | Delete
else:
[212] Fix | Delete
src = srcfn
[213] Fix | Delete
if not os.path.exists(src):
[214] Fix | Delete
if not bad_src:
[215] Fix | Delete
logger.warning('Unable to copy %r', src)
[216] Fix | Delete
return
[217] Fix | Delete
[218] Fix | Delete
shutil.copyfile(src, dst)
[219] Fix | Delete
[220] Fix | Delete
def setup_python(self, context):
[221] Fix | Delete
"""
[222] Fix | Delete
Set up a Python executable in the environment.
[223] Fix | Delete
[224] Fix | Delete
:param context: The information for the environment creation request
[225] Fix | Delete
being processed.
[226] Fix | Delete
"""
[227] Fix | Delete
binpath = context.bin_path
[228] Fix | Delete
path = context.env_exe
[229] Fix | Delete
copier = self.symlink_or_copy
[230] Fix | Delete
dirname = context.python_dir
[231] Fix | Delete
if os.name != 'nt':
[232] Fix | Delete
copier(context.executable, path)
[233] Fix | Delete
if not os.path.islink(path):
[234] Fix | Delete
os.chmod(path, 0o755)
[235] Fix | Delete
for suffix in ('python', 'python3'):
[236] Fix | Delete
path = os.path.join(binpath, suffix)
[237] Fix | Delete
if not os.path.exists(path):
[238] Fix | Delete
# Issue 18807: make copies if
[239] Fix | Delete
# symlinks are not wanted
[240] Fix | Delete
copier(context.env_exe, path, relative_symlinks_ok=True)
[241] Fix | Delete
if not os.path.islink(path):
[242] Fix | Delete
os.chmod(path, 0o755)
[243] Fix | Delete
else:
[244] Fix | Delete
if self.symlinks:
[245] Fix | Delete
# For symlinking, we need a complete copy of the root directory
[246] Fix | Delete
# If symlinks fail, you'll get unnecessary copies of files, but
[247] Fix | Delete
# we assume that if you've opted into symlinks on Windows then
[248] Fix | Delete
# you know what you're doing.
[249] Fix | Delete
suffixes = [
[250] Fix | Delete
f for f in os.listdir(dirname) if
[251] Fix | Delete
os.path.normcase(os.path.splitext(f)[1]) in ('.exe', '.dll')
[252] Fix | Delete
]
[253] Fix | Delete
if sysconfig.is_python_build(True):
[254] Fix | Delete
suffixes = [
[255] Fix | Delete
f for f in suffixes if
[256] Fix | Delete
os.path.normcase(f).startswith(('python', 'vcruntime'))
[257] Fix | Delete
]
[258] Fix | Delete
else:
[259] Fix | Delete
suffixes = ['python.exe', 'python_d.exe', 'pythonw.exe',
[260] Fix | Delete
'pythonw_d.exe']
[261] Fix | Delete
[262] Fix | Delete
for suffix in suffixes:
[263] Fix | Delete
src = os.path.join(dirname, suffix)
[264] Fix | Delete
if os.path.lexists(src):
[265] Fix | Delete
copier(src, os.path.join(binpath, suffix))
[266] Fix | Delete
[267] Fix | Delete
if sysconfig.is_python_build(True):
[268] Fix | Delete
# copy init.tcl
[269] Fix | Delete
for root, dirs, files in os.walk(context.python_dir):
[270] Fix | Delete
if 'init.tcl' in files:
[271] Fix | Delete
tcldir = os.path.basename(root)
[272] Fix | Delete
tcldir = os.path.join(context.env_dir, 'Lib', tcldir)
[273] Fix | Delete
if not os.path.exists(tcldir):
[274] Fix | Delete
os.makedirs(tcldir)
[275] Fix | Delete
src = os.path.join(root, 'init.tcl')
[276] Fix | Delete
dst = os.path.join(tcldir, 'init.tcl')
[277] Fix | Delete
shutil.copyfile(src, dst)
[278] Fix | Delete
break
[279] Fix | Delete
[280] Fix | Delete
def _setup_pip(self, context):
[281] Fix | Delete
"""Installs or upgrades pip in a virtual environment"""
[282] Fix | Delete
# We run ensurepip in isolated mode to avoid side effects from
[283] Fix | Delete
# environment vars, the current directory and anything else
[284] Fix | Delete
# intended for the global Python environment
[285] Fix | Delete
cmd = [context.env_exe, '-Im', 'ensurepip', '--upgrade',
[286] Fix | Delete
'--default-pip']
[287] Fix | Delete
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
[288] Fix | Delete
[289] Fix | Delete
def setup_scripts(self, context):
[290] Fix | Delete
"""
[291] Fix | Delete
Set up scripts into the created environment from a directory.
[292] Fix | Delete
[293] Fix | Delete
This method installs the default scripts into the environment
[294] Fix | Delete
being created. You can prevent the default installation by overriding
[295] Fix | Delete
this method if you really need to, or if you need to specify
[296] Fix | Delete
a different location for the scripts to install. By default, the
[297] Fix | Delete
'scripts' directory in the venv package is used as the source of
[298] Fix | Delete
scripts to install.
[299] Fix | Delete
"""
[300] Fix | Delete
path = os.path.abspath(os.path.dirname(__file__))
[301] Fix | Delete
path = os.path.join(path, 'scripts')
[302] Fix | Delete
self.install_scripts(context, path)
[303] Fix | Delete
[304] Fix | Delete
def post_setup(self, context):
[305] Fix | Delete
"""
[306] Fix | Delete
Hook for post-setup modification of the venv. Subclasses may install
[307] Fix | Delete
additional packages or scripts here, add activation shell scripts, etc.
[308] Fix | Delete
[309] Fix | Delete
:param context: The information for the environment creation request
[310] Fix | Delete
being processed.
[311] Fix | Delete
"""
[312] Fix | Delete
pass
[313] Fix | Delete
[314] Fix | Delete
def replace_variables(self, text, context):
[315] Fix | Delete
"""
[316] Fix | Delete
Replace variable placeholders in script text with context-specific
[317] Fix | Delete
variables.
[318] Fix | Delete
[319] Fix | Delete
Return the text passed in , but with variables replaced.
[320] Fix | Delete
[321] Fix | Delete
:param text: The text in which to replace placeholder variables.
[322] Fix | Delete
:param context: The information for the environment creation request
[323] Fix | Delete
being processed.
[324] Fix | Delete
"""
[325] Fix | Delete
text = text.replace('__VENV_DIR__', context.env_dir)
[326] Fix | Delete
text = text.replace('__VENV_NAME__', context.env_name)
[327] Fix | Delete
text = text.replace('__VENV_PROMPT__', context.prompt)
[328] Fix | Delete
text = text.replace('__VENV_BIN_NAME__', context.bin_name)
[329] Fix | Delete
text = text.replace('__VENV_PYTHON__', context.env_exe)
[330] Fix | Delete
return text
[331] Fix | Delete
[332] Fix | Delete
def install_scripts(self, context, path):
[333] Fix | Delete
"""
[334] Fix | Delete
Install scripts into the created environment from a directory.
[335] Fix | Delete
[336] Fix | Delete
:param context: The information for the environment creation request
[337] Fix | Delete
being processed.
[338] Fix | Delete
:param path: Absolute pathname of a directory containing script.
[339] Fix | Delete
Scripts in the 'common' subdirectory of this directory,
[340] Fix | Delete
and those in the directory named for the platform
[341] Fix | Delete
being run on, are installed in the created environment.
[342] Fix | Delete
Placeholder variables are replaced with environment-
[343] Fix | Delete
specific values.
[344] Fix | Delete
"""
[345] Fix | Delete
binpath = context.bin_path
[346] Fix | Delete
plen = len(path)
[347] Fix | Delete
for root, dirs, files in os.walk(path):
[348] Fix | Delete
if root == path: # at top-level, remove irrelevant dirs
[349] Fix | Delete
for d in dirs[:]:
[350] Fix | Delete
if d not in ('common', os.name):
[351] Fix | Delete
dirs.remove(d)
[352] Fix | Delete
continue # ignore files in top level
[353] Fix | Delete
for f in files:
[354] Fix | Delete
if (os.name == 'nt' and f.startswith('python')
[355] Fix | Delete
and f.endswith(('.exe', '.pdb'))):
[356] Fix | Delete
continue
[357] Fix | Delete
srcfile = os.path.join(root, f)
[358] Fix | Delete
suffix = root[plen:].split(os.sep)[2:]
[359] Fix | Delete
if not suffix:
[360] Fix | Delete
dstdir = binpath
[361] Fix | Delete
else:
[362] Fix | Delete
dstdir = os.path.join(binpath, *suffix)
[363] Fix | Delete
if not os.path.exists(dstdir):
[364] Fix | Delete
os.makedirs(dstdir)
[365] Fix | Delete
dstfile = os.path.join(dstdir, f)
[366] Fix | Delete
with open(srcfile, 'rb') as f:
[367] Fix | Delete
data = f.read()
[368] Fix | Delete
if not srcfile.endswith(('.exe', '.pdb')):
[369] Fix | Delete
try:
[370] Fix | Delete
data = data.decode('utf-8')
[371] Fix | Delete
data = self.replace_variables(data, context)
[372] Fix | Delete
data = data.encode('utf-8')
[373] Fix | Delete
except UnicodeError as e:
[374] Fix | Delete
data = None
[375] Fix | Delete
logger.warning('unable to copy script %r, '
[376] Fix | Delete
'may be binary: %s', srcfile, e)
[377] Fix | Delete
if data is not None:
[378] Fix | Delete
with open(dstfile, 'wb') as f:
[379] Fix | Delete
f.write(data)
[380] Fix | Delete
shutil.copymode(srcfile, dstfile)
[381] Fix | Delete
[382] Fix | Delete
[383] Fix | Delete
def create(env_dir, system_site_packages=False, clear=False,
[384] Fix | Delete
symlinks=False, with_pip=False, prompt=None):
[385] Fix | Delete
"""Create a virtual environment in a directory."""
[386] Fix | Delete
builder = EnvBuilder(system_site_packages=system_site_packages,
[387] Fix | Delete
clear=clear, symlinks=symlinks, with_pip=with_pip,
[388] Fix | Delete
prompt=prompt)
[389] Fix | Delete
builder.create(env_dir)
[390] Fix | Delete
[391] Fix | Delete
def main(args=None):
[392] Fix | Delete
compatible = True
[393] Fix | Delete
if sys.version_info < (3, 3):
[394] Fix | Delete
compatible = False
[395] Fix | Delete
elif not hasattr(sys, 'base_prefix'):
[396] Fix | Delete
compatible = False
[397] Fix | Delete
if not compatible:
[398] Fix | Delete
raise ValueError('This script is only for use with Python >= 3.3')
[399] Fix | Delete
else:
[400] Fix | Delete
import argparse
[401] Fix | Delete
[402] Fix | Delete
parser = argparse.ArgumentParser(prog=__name__,
[403] Fix | Delete
description='Creates virtual Python '
[404] Fix | Delete
'environments in one or '
[405] Fix | Delete
'more target '
[406] Fix | Delete
'directories.',
[407] Fix | Delete
epilog='Once an environment has been '
[408] Fix | Delete
'created, you may wish to '
[409] Fix | Delete
'activate it, e.g. by '
[410] Fix | Delete
'sourcing an activate script '
[411] Fix | Delete
'in its bin directory.')
[412] Fix | Delete
parser.add_argument('dirs', metavar='ENV_DIR', nargs='+',
[413] Fix | Delete
help='A directory to create the environment in.')
[414] Fix | Delete
parser.add_argument('--system-site-packages', default=False,
[415] Fix | Delete
action='store_true', dest='system_site',
[416] Fix | Delete
help='Give the virtual environment access to the '
[417] Fix | Delete
'system site-packages dir.')
[418] Fix | Delete
if os.name == 'nt':
[419] Fix | Delete
use_symlinks = False
[420] Fix | Delete
else:
[421] Fix | Delete
use_symlinks = True
[422] Fix | Delete
group = parser.add_mutually_exclusive_group()
[423] Fix | Delete
group.add_argument('--symlinks', default=use_symlinks,
[424] Fix | Delete
action='store_true', dest='symlinks',
[425] Fix | Delete
help='Try to use symlinks rather than copies, '
[426] Fix | Delete
'when symlinks are not the default for '
[427] Fix | Delete
'the platform.')
[428] Fix | Delete
group.add_argument('--copies', default=not use_symlinks,
[429] Fix | Delete
action='store_false', dest='symlinks',
[430] Fix | Delete
help='Try to use copies rather than symlinks, '
[431] Fix | Delete
'even when symlinks are the default for '
[432] Fix | Delete
'the platform.')
[433] Fix | Delete
parser.add_argument('--clear', default=False, action='store_true',
[434] Fix | Delete
dest='clear', help='Delete the contents of the '
[435] Fix | Delete
'environment directory if it '
[436] Fix | Delete
'already exists, before '
[437] Fix | Delete
'environment creation.')
[438] Fix | Delete
parser.add_argument('--upgrade', default=False, action='store_true',
[439] Fix | Delete
dest='upgrade', help='Upgrade the environment '
[440] Fix | Delete
'directory to use this version '
[441] Fix | Delete
'of Python, assuming Python '
[442] Fix | Delete
'has been upgraded in-place.')
[443] Fix | Delete
parser.add_argument('--without-pip', dest='with_pip',
[444] Fix | Delete
default=True, action='store_false',
[445] Fix | Delete
help='Skips installing or upgrading pip in the '
[446] Fix | Delete
'virtual environment (pip is bootstrapped '
[447] Fix | Delete
'by default)')
[448] Fix | Delete
parser.add_argument('--prompt',
[449] Fix | Delete
help='Provides an alternative prompt prefix for '
[450] Fix | Delete
'this environment.')
[451] Fix | Delete
options = parser.parse_args(args)
[452] Fix | Delete
if options.upgrade and options.clear:
[453] Fix | Delete
raise ValueError('you cannot supply --upgrade and --clear together.')
[454] Fix | Delete
builder = EnvBuilder(system_site_packages=options.system_site,
[455] Fix | Delete
clear=options.clear,
[456] Fix | Delete
symlinks=options.symlinks,
[457] Fix | Delete
upgrade=options.upgrade,
[458] Fix | Delete
with_pip=options.with_pip,
[459] Fix | Delete
prompt=options.prompt)
[460] Fix | Delete
for d in options.dirs:
[461] Fix | Delete
builder.create(d)
[462] Fix | Delete
[463] Fix | Delete
if __name__ == '__main__':
[464] Fix | Delete
rc = 1
[465] Fix | Delete
try:
[466] Fix | Delete
main()
[467] Fix | Delete
rc = 0
[468] Fix | Delete
except Exception as e:
[469] Fix | Delete
print('Error: %s' % e, file=sys.stderr)
[470] Fix | Delete
sys.exit(rc)
[471] Fix | Delete
[472] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function