Your IP : 3.14.247.170


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

3

�QgqM�@s�ddlZddlZddlZddlZddlZddlZddlZeje�Z	Gdd�d�Z
d
dd�Zddd�Zed	kr�d
Z
ye�dZ
Wn4ek
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
�%/usr/lib64/python3.6/venv/__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�create4s





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_directoryNs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__Zwin32ZScriptsZInclude�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�envr9�dirnameZexenameZbinnameZincpathZlibpathrZ	link_path�binpathr
r
rrVsN



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:rr7r;)r	rr�fZinclr
r
rr�s	zEnvBuilder.create_configuration�ntcCs(|jd�rd}n|jd�o"|jd�}|S)N�.pyd�.dllT�pythonz.exe)rMrN)�endswith�
startswith)r	rK�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)NrLi�rO�python3T)r[ZDLLscsg|]}�|�r|�qSr
r
)�.0rK)r,r
r�
<listcomp>�sz+EnvBuilder.setup_python.<locals>.<listcomp>csg|]}�|�r|�qSr
r
)r^rK)r,r
rr_�szinit.tclr*)rOr])r?rAr\r9r:r
r=rr�chmodrr"rSrr�walkrTrr#rrX)r	rrDrZcopierrC�suffixZsubdir�filesrKrYrZ�root�dirsZtcldirr
)r,rr�sN






zEnvBuilder.setup_pythoncCs$|jddddg}tj|tjd�dS)Nz-ImZ	ensurepipz	--upgradez
--default-pip)�stderr)rA�
subprocessZcheck_outputZSTDOUT)r	r�cmdr
r
rr�s
zEnvBuilder._setup_pipcCs2tjjtjjt��}tjj|d�}|j||�dS)N�scripts)r
rrrC�__file__r�install_scripts)r	rrr
r
rr�szEnvBuilder.setup_scriptscCsdS)Nr
)r	rr
r
rrszEnvBuilder.post_setupc	s�|j|j|j|j|jd�}dd�}dd�}tj�|j}|jd�rF|�n|jd�rV|�ntj��fdd	�|j	�D�}x |j	�D]\}}|j
||�}q|W|S)
N)Z__VENV_DIR__Z
__VENV_NAME__Z__VENV_PROMPT__Z__VENV_BIN_NAME__Z__VENV_PYTHON__cSs|jdd�}d|�d�S)N�'z'')�replace)�sr
r
r�	quote_ps1$sz/EnvBuilder.replace_variables.<locals>.quote_ps1cSs|S)Nr
)rnr
r
r�	quote_bat.sz/EnvBuilder.replace_variables.<locals>.quote_batz.ps1z.batcsi|]\}}�|�|�qSr
r
)r^�keyrn)�quoter
r�
<dictcomp><sz0EnvBuilder.replace_variables.<locals>.<dictcomp>)rr5rr@rA�shlexrr�script_pathrP�itemsrm)	r	�textrZreplacementsrorprurqZquotedr
)rrr�replace_variabless$



zEnvBuilder.replace_variablesc!Cs�|j}t|�}�x�tj|�D�]~\}}}||kr`x,|dd�D]}|dtjfkr>|j|�q>Wq�x8|D�].}	tjj||	�}
||d�jtj	�dd�}|s�|}ntjj|f|��}tjj
|�s�tj|�tjj||	�}
t|
d��}	|	j
�}WdQRX|
jd��sd|
|_y$|jd�}|j||�}|jd�}Wn6tk
�rb}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
rar=rrrr4�sepr"r#rI�readrPru�decoderx�encode�UnicodeErrorrVrWrJrZcopymode)r	rrrDZplenrdrercr%rKZsrcfilerbZdstdirZdstfile�data�er
r
rrkAsB


zEnvBuilder.install_scripts)FFFFFN)F)�__name__�
__module__�__qualname__rrr!rrr
r=rSr\rrrrrxrkr
r
r
rrs
8

3	
0rFcCs 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)+NTrHF�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.)�progZdescriptionZepilogreZENV_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�rLz
--symlinksrz[Try to use symlinks rather than copies, when symlinks are not the default for the platform.z--copiesZstore_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)rHrH)r7r;�hasattrr$�argparse�ArgumentParserr��add_argumentr
r=Zadd_mutually_exclusive_group�
parse_argsrrrr�rrrrer)	�argsZ
compatibler��parserZuse_symlinks�groupZoptionsr�r%r
r
r�mainzs\










r��__main__r'z	Error: %s)�file)FFFFN)N)Zloggingr
rrgr7r2rtZ	getLoggerr�rVrrr�ZrcrUr��printrf�exitr
r
r
r�<module>s*
b

H$

?>