3
_VjqM ã @ sÆ d Z ddlZddlZddlZddlZddlZddlZddlZeje ƒZ
G dd„ dƒZddd„Zddd „Z
e d
krÂdZye
ƒ dZW n4 ek
r¶ Z zede ejd
� W Y ddZ[X nX ejeƒ dS )z›
Virtual environment (venv) package for Python. Based on PEP 405.
Copyright (C) 2011-2014 Vinay Sajip.
Licensed to the PSF under a contributor agreement.
é Nc @ s† e Zd ZdZddd„Zdd„ Zdd „ Zd
d„ Zdd
„ Ze j
dkrHdd„ Zd dd„Zdd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )!Ú
EnvBuildera–
This class exists to allow virtual environment creation to be
customized. The constructor parameters determine the builder's
behaviour when called upon to create a virtual environment.
By default, the builder makes the system (global) site-packages dir
*un*available to the created environment.
If invoked using the Python -m option, the default is to use copying
on Windows platforms but symlinks elsewhere. If instantiated some
other way, the default is to *not* use symlinks.
:param system_site_packages: If True, the system (global) site-packages
dir is available to created environments.
:param clear: If True, delete the contents of the environment directory if
it already exists, before environment creation.
:param symlinks: If True, attempt to symlink rather than copy files into
virtual environment.
:param upgrade: If True, upgrade an existing virtual environment.
:param with_pip: If True, ensure pip is installed in the virtual
environment
:param prompt: Alternative terminal prefix for the environment.
FNc C s( || _ || _|| _|| _|| _|| _d S )N)Úsystem_site_packagesÚclearÚsymlinksÚupgradeÚwith_pipÚprompt)Úselfr r r r r r © r
ú%/usr/lib64/python3.6/venv/__init__.pyÚ__init__+ s zEnvBuilder.__init__c C sx t jj|ƒ}| j|ƒ}| j}d| _| j|ƒ | j|ƒ | jrF| j|ƒ | j s`| j
|ƒ | j|ƒ |rtd| _| j|ƒ dS )zŠ
Create a virtual environment in a directory.
:param env_dir: The target directory to create an environment in.
FTN)ÚosÚpathÚabspathÚensure_directoriesr Úcreate_configurationÚsetup_pythonr Ú
_setup_pipr Ú
setup_scriptsÚ
post_setup)r Úenv_dirÚcontextZtrue_system_site_packagesr
r
r Úcreate4 s
zEnvBuilder.createc C s` xZt j|ƒD ]L}t jj||ƒ}t jj|ƒs6t jj|ƒrBt j|ƒ qt jj|ƒrtj |ƒ qW d S )N)
r
Úlistdirr ÚjoinÚislinkÚisfileÚremoveÚisdirÚshutilZrmtree)r r Úfnr
r
r Úclear_directoryN s zEnvBuilder.clear_directoryc C s² dd„ }t jj|ƒr$| jr$| j|ƒ tjƒ }||_t jj|ƒd |_ | j
dk rT| j
n|j }d| |_
||ƒ t j}tj
dkr�d|kr�t jd }ntj}t jjt jj|ƒƒ\}}||_||_||_tj
dkräd } d
}
t jj|ddƒ}n(d
} d}
t jj|ddtjdd… dƒ}t jj||
ƒ |_}||ƒ ||ƒ tjdk�r|t jdk�r|tj
dk�r|t jj|dƒ}
t jj|
ƒ�s|t jd|
ƒ t jj|| ƒ |_}| |_t jj||ƒ|_||ƒ |S )zª
Create the directories for the environment.
Returns a context object which holds paths in the environment,
for use by subsequent logic.
c S s@ t jj| ƒst j| ƒ n$t jj| ƒs0t jj| ƒr