Your IP : 18.117.183.206


Current Path : /proc/self/root/opt/alt/python37/lib64/python3.7/venv/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python37/lib64/python3.7/venv/__pycache__/__init__.cpython-37.opt-2.pyc

B

YI~dR�
@s�ddlZddlZddlZddlZddlZddlZddlZe�e�Z	Gdd�d�Z
d
dd�Zddd�Zed	kr�d
Z
ye�dZ
Wn4ek
r�Zzedeejd�WddZ[XYnXe�e
�dS)�Nc@s�eZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zej	d
krHddd�Z
n
ddd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS) �
EnvBuilderFNcCs(||_||_||_||_||_||_dS)N)�system_site_packages�clear�symlinks�upgrade�with_pip�prompt)�selfrrrrrr�r
�2/opt/alt/python37/lib64/python3.7/venv/__init__.py�__init__+szEnvBuilder.__init__cCsxtj�|�}|�|�}|j}d|_|�|�|�|�|jrF|�|�|j	s`|�
|�|�|�|rtd|_|�|�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`xZt�|�D]L}tj�||�}tj�|�s6tj�|�rBt�|�qtj�|�rt�	|�qWdS)N)
r
�listdirr�join�islink�isfile�remove�isdir�shutilZrmtree)r	r�fnr
r
r�clear_directoryNszEnvBuilder.clear_directorycCs�dd�}tj�|�r$|jr$|�|�t��}||_tj�|�d|_	|j
dk	rT|j
n|j	}d||_
||�tj}tt
dt
j�}tj�tj�|��\}}||_||_||_t
jdkr�d}	d}
tj�|d	d
�}n(d}	d}
tj�|d
dt
jdd�d
�}tj�||
�|_}||�||�t
jdk�rftjdk�rft
jdk�rftj�|d�}
tj�|
��sft�d
|
�tj�||	�|_}|	|_tj�||�|_||�|S)NcSs@tj�|�st�|�n$tj�|�s0tj�|�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) �_base_executable�win32ZScriptsZInclude�Libz
site-packages�binZinclude�libzpython%d.%d�l�posix�darwin�lib64)r
rr"rr!�types�SimpleNamespacer�split�env_namer�environ�getattr�sys�
executabler�
python_dirZ
python_exe�platformr�version_infoZinc_path�maxsize�name�symlink�bin_path�bin_name�env_exe)r	rr&rr�envr8�dirnameZexenameZbinnameZincpathZlibpathrZ	link_path�binpathr
r
rrVsJ



zEnvBuilder.ensure_directoriesc	Csztj�|jd�|_}t|ddd��L}|�d|j�|jrBd}nd}|�d|�|�d	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�writer9rr7r;)r	rr�fZinclr
r
rr�s	zEnvBuilder.create_configuration�ntcCs~|j}|sjy6tj�|�s@|r4t�tj�|�|�nt�||�Wn&tk
rht�d||�d}YnX|rzt	�
||�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_copycCsZtj�|�otj�|�}|jr~|s~tj�|�s~y*|rLt�tj�|�|�nt�||�dStk
r|t	�
d||�YnXtj�tj�|��\}}tj�tj�
t�dd||�}t�d�s�tj�|��s"|�d�r�d|}|dd�}|dkr�d}n|d	k�rd
}tj�tj�
|�||�}n|}tj�|��sJ|�sFt	�
d|�dSt�||�dS)NzUnable to symlink %r to %r�scriptsrLTZ_d����pythonZvenvlauncherZpythonwZ
venvwlauncherzUnable to copy %r)r
r�lexistsr"rrr>rMrNrOrP�splitextrrC�__file__�	sysconfig�is_python_buildr�endswithrrQ)r	rRrSrTZbad_srcrMZextZsrcfnr
r
rrU�s:


cCs�|j}|j}|j}|j}tjdkr�||j|�tj�|�sFt�	|d�xNdD]F}tj�
||�}tj�|�sL||j|dd�tj�|�sLt�	|d�qLW�n|jr�dd�t�
|�D�}t�d�r�dd�|D�}nd	d
ddg}x:|D]2}tj�
||�}tj�|�r�||tj�
||��q�Wt�d��r�x�t�|j�D]v\}	}
}d
|k�r0tj�|	�}tj�
|jd|�}tj�|��szt�|�tj�
|	d
�}tj�
|d
�}
t�||
�P�q0WdS)NrLi�)rXZpython3T)rTcSs,g|]$}tj�tj�|�d�dkr|�qS)r')z.exez.dll)r
r�normcaserZ)�.0rKr
r
r�
<listcomp>�sz+EnvBuilder.setup_python.<locals>.<listcomp>cSs"g|]}tj�|��d�r|�qS))rXZ	vcruntime)r
rr_�
startswith)r`rKr
r
rrasz
python.exezpython_d.exezpythonw.exez
pythonw_d.exezinit.tclr*)r?rArUr9r
r=r8rr�chmodrr"rrr\r]rY�walkrMrr#rrQ)r	rrDrZcopierrC�suffix�suffixesrR�root�dirs�filesZtcldirrSr
r
rr�sF





zEnvBuilder.setup_pythoncCs$|jddddg}tj|tjd�dS)Nz-ImZ	ensurepipz	--upgradez
--default-pip)�stderr)rA�
subprocessZcheck_outputZSTDOUT)r	r�cmdr
r
rrs
zEnvBuilder._setup_pipcCs2tj�tj�t��}tj�|d�}|�||�dS)NrV)r
rrrCr[r�install_scripts)r	rrr
r
rr"szEnvBuilder.setup_scriptscCsdS)Nr
)r	rr
r
rr1szEnvBuilder.post_setupcCsJ|�d|j�}|�d|j�}|�d|j�}|�d|j�}|�d|j�}|S)NZ__VENV_DIR__Z
__VENV_NAME__Z__VENV_PROMPT__Z__VENV_BIN_NAME__Z__VENV_PYTHON__)�replacerr4rr@rA)r	�textrr
r
r�replace_variables;szEnvBuilder.replace_variablescCs�|j}t|�}�x�t�|�D�]�\}}}||kr`x,|dd�D]}|dtjfkr>|�|�q>Wq�xR|D�]H}	tjdkr�|	�d�r�|	�d�r�qhtj�	||	�}
||d��
tj�dd�}|s�|}ntjj	|f|��}tj�|�s�t�
|�tj�	||	�}
t|
d��}	|	��}WdQRX|
�d��s~y$|�d�}|�||�}|�d�}Wn6tk
�r|}zd}t�d|
|�Wdd}~XYnX|dk	rht|
d	��}	|	�|�WdQRXt�|
|
�qhWqWdS)
N�commonrLrX)z.exez.pdbr-�rbzutf-8z+unable to copy script %r, may be binary: %s�wb)r?�lenr
rdr=rrbr^rrr3�sepr"r#rI�read�decoderp�encode�UnicodeErrorrOrPrJrZcopymode)r	rrrDZplenrgrhrir%rKZsrcfilereZdstdirZdstfile�data�er
r
rrmMsF



zEnvBuilder.install_scripts)FFFFFN)F)F)�__name__�
__module__�__qualname__rrr!rrr
r=rUrrrrrprmr
r
r
rrs
5

+<	
rFcCs t|||||d�}|�|�dS)N)rrrrr)rr)rrrrrr�builderr
r
rr�src	Csbd}tjdkrd}nttd�s"d}|s2td���n,ddl}|jtddd	�}|jd
ddd
d�|jdddddd�tj	dkr�d}nd}|�
�}|jd|dddd�|jd|dddd�|jdddddd�|jddddd d�|jd!d"ddd#d$�|jd%d&d'�|�|�}|j�r"|j
�r"td(��t|j|j
|j|j|j|jd)�}x|jD]}|�|��qJWdS)*NT)rHrHF�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�epilogrhZENV_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--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)r7r;�hasattrr$�argparse�ArgumentParserr|�add_argumentr
r=�add_mutually_exclusive_group�
parse_argsrrrr�rrrrhr)	�argsZ
compatibler��parserZuse_symlinks�group�optionsrr%r
r
r�main�s\










r��__main__r'z	Error: %s)�file)FFFFN)N)Zloggingr
rrkr7r\r1Z	getLoggerr|rOrrr�ZrcrNr{�printrj�exitr
r
r
r�<module>s*
p

H$

?>