Your IP : 18.191.67.90


Current Path : /opt/alt/python36/lib64/python3.6/venv/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/venv/__pycache__/__init__.cpython-36.opt-2.pyc

3

��2a�H�@s�ddlZddlZddlZddlZddlZddlZeje�ZGdd�d�Z	d
dd�Z
ddd�Zed	kr�d
Zye�dZWn4e
k
r�Zzedeejd�WYddZ[XnXeje�dS)�Nc@s�eZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zej	d
krDdd�Z
ddd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �
EnvBuilderFNcCs(||_||_||_||_||_||_dS)N)�system_site_packages�clear�symlinks�upgrade�with_pip�prompt)�selfrrrrrr�r
�-/opt/alt/python36/lib64/python3.6/__init__.py�__init__*szEnvBuilder.__init__cCsxtjj|�}|j|�}|j}d|_|j|�|j|�|jrF|j|�|j	s`|j
|�|j|�|rtd|_|j|�dS)NFT)�os�path�abspath�ensure_directoriesr�create_configuration�setup_pythonr�
_setup_pipr�
setup_scripts�
post_setup)r	�env_dir�contextZtrue_system_site_packagesr
r
r�create3s





zEnvBuilder.createcCs`xZtj|�D]L}tjj||�}tjj|�s6tjj|�rBtj|�qtjj|�rtj	|�qWdS)N)
r
�listdirr�join�islink�isfile�remove�isdir�shutilZrmtree)r	r�fnr
r
r�clear_directoryMszEnvBuilder.clear_directorycCs�dd�}tjj|�r$|jr$|j|�tj�}||_tjj|�d|_	|j
dk	rT|j
n|j	}d||_
||�tj}tj
dkr�d|kr�tjd}ntj}tjjtjj|��\}}||_||_||_tj
dkr�d}	d	}
tjj|d
d�}n(d}	d
}
tjj|ddtjdd�d�}tjj||
�|_}||�||�tjdk�r|tjdk�r|tj
dk�r|tjj|d�}
tjj|
��s|tjd|
�tjj||	�|_}|	|_tjj||�|_||�|S)NcSs@tjj|�stj|�n$tjj|�s0tjj|�r<td|��dS)NzUnable to create directory %r)r
r�exists�makedirsrr�
ValueError)�dr
r
r�create_if_needed]sz7EnvBuilder.ensure_directories.<locals>.create_if_needed�z(%s) �darwin�__PYVENV_LAUNCHER__�win32ZScriptsZInclude�Libz
site-packages�bin�include�libzpython%d.%d�� �posix�lib64l)r
rr"rr!�types�SimpleNamespacer�split�env_namer�environ�sys�platform�
executabler�
python_dirZ
python_exer�version_infoZinc_path�maxsize�name�symlink�bin_path�bin_name�env_exe)r	rr&rr�envr:�dirnameZexenameZbinnameZincpathZlibpathrZ	link_path�binpathr
r
rrUsN



zEnvBuilder.ensure_directoriescCsztjj|jd�|_}t|ddd��L}|jd|j�|jrBd}nd}|jd|�|jd	t	j
dd
��WdQRXdS)Nz
pyvenv.cfg�wzutf-8)�encodingz
home = %s
�trueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
�)r
rrrZcfg_path�open�writer;rr8r<)r	rr�fZinclr
r
rr�s	zEnvBuilder.create_configuration�ntcCs(|jd�rd}n|jd�o"|jd�}|S)N�.pyd�.dllT�pythonz.exe)rNrO)�endswith�
startswith)r	rL�resultr
r
r�include_binary�s
zEnvBuilder.include_binarycCs~|j}|sjy6tjj|�s@|r4tjtjj|�|�ntj||�Wn&tk
rhtjd||�d}YnX|rzt	j
||�dS)NzUnable to symlink %r to %rT)rr
rrr?�basename�	Exception�logger�warningr�copyfile)r	�src�dst�relative_symlinks_okZ
force_copyr
r
r�symlink_or_copy�s
zEnvBuilder.symlink_or_copycs�|j}|j}|j}||j|�|j}tjdkr�tjj|�sFtj	|d�xNd
D]F}tjj
||�}tjj|�sL||j|dd�tjj|�sLtj	|d�qLW�nRd}|j��fdd	�tj
|�D�}x<|D]4}	tjj
||	�}
tjj
||	�}||jkr�||
|�q�Wtjj
||�}tjj|��rd�fd
d	�tj
|�D�}x4|D],}	tjj
||	�}
tjj
||	�}||
|��q4Wx�tj|j�D]v\}}
}d|k�rrtjj|�}tjj
|jd|�}tjj|��s�tj|�tjj
|d�}
tjj
|d�}tj|
|�P�qrWdS)NrMi�rP�python3T)r\ZDLLscsg|]}�|�r|�qSr
r
)�.0rL)r-r
r�
<listcomp>�sz+EnvBuilder.setup_python.<locals>.<listcomp>csg|]}�|�r|�qSr
r
)r_rL)r-r
rr`�szinit.tclr+)rPr^)r@rBr]r:r;r
r>rr�chmodrr"rTrr�walkrUrr#rrY)r	rrEr�copierrD�suffixZsubdir�filesrLrZr[�root�dirsZtcldirr
)r-rr�sN






zEnvBuilder.setup_pythoncCs$|jddddg}tj|tjd�dS)Nz-ImZ	ensurepipz	--upgradez
--default-pip)�stderr)rB�
subprocessZcheck_outputZSTDOUT)r	r�cmdr
r
rr�s
zEnvBuilder._setup_pipcCs2tjjtjjt��}tjj|d�}|j||�dS)N�scripts)r
rrrD�__file__r�install_scripts)r	rrr
r
rr�szEnvBuilder.setup_scriptscCsdS)Nr
)r	rr
r
rrszEnvBuilder.post_setupcCsJ|jd|j�}|jd|j�}|jd|j�}|jd|j�}|jd|j�}|S)NZ__VENV_DIR__Z
__VENV_NAME__Z__VENV_PROMPT__Z__VENV_BIN_NAME__Z__VENV_PYTHON__)�replacerr6rrArB)r	�textrr
r
r�replace_variablesszEnvBuilder.replace_variablesc!Cs�|j}t|�}�x�tj|�D�]x\}}}||kr`x,|dd�D]}|dtjfkr>|j|�q>Wq�x2|D�](}	tjj||	�}
||d�jtj	�dd�}|s�|}ntjj|f|��}tjj
|�s�tj|�tjj||	�}
t|
d��}	|	j
�}WdQRX|
jd��s^y$|jd�}|j||�}|jd�}Wn6tk
�r\}zd}tjd|
|�WYdd}~XnX|dk	rht|
d��}	|	j|�WdQRXtj|
|
�qhWqWdS)N�commonr/�rbz.exezutf-8z+unable to copy script %r, may be binary: %s�wb)r@�lenr
rbr>rrrr5�sepr"r#rJ�readrQ�decoderp�encode�UnicodeErrorrWrXrKrZcopymode)r	rrrEZplenrfrgrer%rLZsrcfilerdZdstdirZdstfile�data�er
r
rrm"s@


zEnvBuilder.install_scripts)FFFFFN)F)�__name__�
__module__�__qualname__rrr!rrr
r>rTr]rrrrrprmr
r
r
rrs
8

3	
rFcCs t|||||d�}|j|�dS)N)rrrrr)rr)rrrrrr�builderr
r
rrRsrc	Csbd}tjd*krd}nttd�s"d}|s2td���n,ddl}|jtddd	�}|jd
ddd
d�|jdddddd�tj	dkr�d}nd}|j
�}|jd|dddd�|jd|dddd�|jdddddd�|jddddd d�|jd!d"ddd#d$�|jd%d&d'�|j|�}|j�r"|j
�r"td(��t|j|j
|j|j|j|jd)�}x|jD]}|j|��qJWdS)+NTrIF�base_prefixz.This script is only for use with Python >= 3.3rzFCreates virtual Python environments in one or more target directories.z|Once an environment has been created, you may wish to activate it, e.g. by sourcing an activate script in its bin directory.)�prog�description�epilogrgZENV_DIR�+z)A directory to create the environment in.)�metavar�nargs�helpz--system-site-packages�
store_true�system_sitezDGive the virtual environment access to the system site-packages dir.)�default�action�destr�rMz
--symlinksrz[Try to use symlinks rather than copies, when symlinks are not the default for the platform.z--copies�store_falsez\Try to use copies rather than symlinks, even when symlinks are the default for the platform.z--clearrzcDelete the contents of the environment directory if it already exists, before environment creation.z	--upgraderzlUpgrade the environment directory to use this version of Python, assuming Python has been upgraded in-place.z
--without-piprz]Skips installing or upgrading pip in the virtual environment (pip is bootstrapped by default))r�r�r�r�z--promptz;Provides an alternative prompt prefix for this environment.)r�z1you cannot supply --upgrade and --clear together.)rrrrrr)rIrI)r8r<�hasattrr$�argparse�ArgumentParserr|�add_argumentr
r>�add_mutually_exclusive_group�
parse_argsrrrr�rrrrgr)	�argsZ
compatibler��parserZuse_symlinks�group�optionsrr%r
r
r�mainZs\










r��__main__r'z	Error: %s)�file)FFFFN)N)Zloggingr
rrir8r3Z	getLoggerr|rWrrr�ZrcrVr{�printrh�exitr
r
r
r�<module>s(
C

H$

?>