Your IP : 3.145.43.200


Current Path : /opt/alt/python35/lib64/python3.5/venv/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/venv/__pycache__/__init__.cpython-35.opt-2.pyc



���]2N�@sddlZddlZddlZddlZddlZddlZeje�ZGdd�d�Z	dddddd�Z
ddd�Zed	krd
Zye�dZWn<e
k
r�Zzededej�WYddZ[XnXeje�dS)
�Nc@s�eZdZddddddd�Zdd�Zdd�Zdd	�Zd
d�Zej	dkrrd
d�Z
ddd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�
EnvBuilderFcCs1||_||_||_||_||_dS)N)�system_site_packages�clear�symlinks�upgrade�with_pip)�selfrrrrr�r	�-/opt/alt/python35/lib64/python3.5/__init__.py�__init__?s
				zEnvBuilder.__init__cCs�tjj|�}|j|�}|j}d|_|j|�|j|�|jrc|j|�|j	s�|j
|�|j|�|r�d|_|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
�createGs		

	
	

	zEnvBuilder.createcCs�xtj|�D]n}tjj||�}tjj|�sOtjj|�r_tj|�qtjj|�rtj	|�qWdS)N)
r�listdirr
�join�islink�isfile�remove�isdir�shutil�rmtree)rr
�fnr	r	r
�clear_directoryas$zEnvBuilder.clear_directorycCsEdd�}tjj|�r4|jr4|j|�tj�}||_tjj|�d|_	d|j	|_
||�tj}tj
dkr�d|kr�tjd}n	tj}tjjtjj|��\}}||_||_||_tj
dkr.d}d	}	tjj|d
d�}
n8d}d
}	tjj|ddtjdd�d�}
tjj||	�|_}||�||
�tjdkr�tjdkr�tj
dkr�tjj|d�}tjj|�s�tjd|�tjj||�|_}
||_tjj|
|�|_||
�|S)NcSsZtjj|�s"tj|�n4tjj|�sFtjj|�rVtd|��dS)NzUnable to create directory %r)rr
�exists�makedirsrr�
ValueError)�dr	r	r
�create_if_neededqs$z7EnvBuilder.ensure_directories.<locals>.create_if_needed�z(%s) �darwin�__PYVENV_LAUNCHER__�win32ZScriptsZInclude�Libz
site-packages�bin�include�libzpython%d.%d�� �posix�lib64l)rr
r"rr!�types�SimpleNamespacer�split�env_name�prompt�environ�sys�platform�
executabler�
python_dirZ
python_exer�version_infoZinc_path�maxsize�name�symlink�bin_path�bin_name�env_exe)rrr&r�envr;�dirnameZexenameZbinnameZincpathZlibpathr
Z	link_path�binpathr	r	r
risL
	
		$				

	
zEnvBuilder.ensure_directoriescCs�tjj|jd�|_}t|ddd��b}|jd|j�|jr]d}nd}|jd|�|jd	t	j
dd
��WdQRXdS)Nz
pyvenv.cfg�w�encodingzutf-8z
home = %s
�true�falsez"include-system-site-packages = %s
zversion = %d.%d.%d
�)rr
rrZcfg_path�open�writer<rr9r=)rrr
�fZinclr	r	r
r�s			zEnvBuilder.create_configuration�ntcCs:|jd�rd}n|jd�o3|jd�}|S)N�.pyd�.dllT�pythonz.exe)rPrQ)�endswith�
startswith)rrN�resultr	r	r
�include_binary�s	zEnvBuilder.include_binarycCs�|j}|s�yKtjj|�sZ|rJtjtjj|�|�ntj||�Wn+tk
r�tjd||�d}YnX|r�t	j
||�dS)NzUnable to symlink %r to %rT)rrr
rr@�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|�setj	|d�xBd
D]e}tjj
||�}tjj|�sl||j|dd�tjj|�sltj	|d�qlWn�d}|j��fdd	�tj
|�D�}xT|D]L}	tjj
||	�}
tjj
||	�}||jkr||
|�qWtjj
||�}tjj|�r��fd
d	�tj
|�D�}xE|D]=}	tjj
||	�}
tjj
||	�}||
|�q�Wx�tj|j�D]�\}}
}d|krtjj|�}tjj
|jd|�}tjj|�sktj|�tjj
|d�}
tjj
|d�}tj|
|�PqWdS)NrOi�rR�python3r^TZDLLscs"g|]}�|�r|�qSr	r	)�.0rN)r-r	r
�
<listcomp>�s	z+EnvBuilder.setup_python.<locals>.<listcomp>cs"g|]}�|�r|�qSr	r	)rarN)r-r	r
rb�s	zinit.tclr+)rRr`)rArCr_r;r<rr?r
r�chmodrr"rVrr�walkrWrr#rr[)rrrFr
�copierrE�suffixZsubdir�filesrNr\r]�root�dirsZtcldirr	)r-r
r�sN				
	"
"
"
zEnvBuilder.setup_pythoncCs2|jddddg}tj|dtj�dS)Nz-ImZ	ensurepipz	--upgradez
--default-pip�stderr)rC�
subprocess�check_output�STDOUT)rr�cmdr	r	r
rs	zEnvBuilder._setup_pipcCsGtjjtjjt��}tjj|d�}|j||�dS)N�scripts)rr
rrE�__file__r�install_scripts)rrr
r	r	r
r
szEnvBuilder.setup_scriptscCsdS)Nr	)rrr	r	r
rszEnvBuilder.post_setupcCsm|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__)�replacerr6r7rBrC)r�textrr	r	r
�replace_variables#szEnvBuilder.replace_variablesc!Cs|j}t|�}x�tj|�D]�\}}}||kr�x:|dd�D](}|dtjfkrQ|j|�qQWq%x�|D]�}	tjj||	�}
||d�jtj	�dd�}|s�|}ntjj||�}tjj
|�stj|�tjj||	�}
t|
d��}	|	j
�}WdQRX|
jd�s�y4|jd�}|j||�}|jd�}Wn>tk
r�}zd}tjd|
|�WYdd}~XnX|dk	r�t|
d��}	|	j|�WdQRXtj|
|
�q�Wq%WdS)N�commonr/�rbz.exezutf-8z+unable to copy script %r, may be binary: %s�wb)rA�lenrrdr?rr
rr5�sepr"r#rL�readrS�decodert�encode�UnicodeErrorrYrZrMr�copymode)rrr
rFZplenrhrirgr%rNZsrcfilerfZdstdirZdstfile�data�er	r	r
rq5s@
	
&	
	zEnvBuilder.install_scriptsN)�__name__�
__module__�__qualname__rrr!rrrr?rVr_rrrrrtrqr	r	r	r
r's73	
rFc	Cs2td|d|d|d|�}|j|�dS)Nrrrr)rr)rrrrr�builderr	r	r
resrc	Cs"d}tjd,krd}nttd�s3d}|sHtd��n�ddl}|jdtdd	d
d�}|jdd
ddddd�|jddddddddd�tj	dkr�d}nd}|j
�}|jdd|dddddd�|jdd|dddddd �|jd!dddddd"dd#�|jd$dddddd%dd&�|jd'dd(dddddd)�|j|�}|jr�|j
r�td*��td+|jd"|j
d|jd%|jd(|j�}x|jD]}|j|�qWdS)-NTrKF�base_prefixz.This script is only for use with Python >= 3.3r�prog�descriptionzFCreates virtual Python environments in one or more target directories.�epilogz|Once an environment has been created, you may wish to activate it, e.g. by sourcing an activate script in its bin directory.ri�metavarZENV_DIR�nargs�+�helpz)A directory to create the environment in.z--system-site-packages�default�action�
store_true�dest�system_sitezDGive the virtual environment access to the system site-packages dir.rOz
--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)z1you cannot supply --upgrade and --clear together.r)rKrK)r9r=�hasattrr$�argparse�ArgumentParserr��add_argumentrr?�add_mutually_exclusive_group�
parse_argsrrrr�rrrir)	�argsZ
compatibler��parserZuse_symlinks�group�optionsr�r%r	r	r
�main|sV			

			r��__main__r'z	Error: %s�file)�loggingrrrkr9r3�	getLoggerr�rYrrr��rcrXr��printrj�exitr	r	r	r
�<module>s&�?D
*

?>