AlkantarClanX12

Your IP : 18.118.193.28


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

B

� fR�
@s�dZddlZddlZddlZddlZddlZddlZddlZe�e	�Z
Gdd�d�Zddd�Zddd	�Z
e	d
kr�dZye
�dZWn4ek
r�Zzedeejd
�WddZ[XYnXe�e�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�eZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Ze	j
dkrLddd�Zn
d dd�Zdd�Zdd�Z
dd�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.
    FNcCs(||_||_||_||_||_||_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)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�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�|ddt
jdd�d�}tj�||
�|_}||�||�t
jdk�rftjdk�rft
jdk�rftj�|d�}
tj�|
��sft�d|
�tj�||	�|_}|	|_tj�||�|_||�|S)z�
        Create the directories for the environment.

        Returns a context object which holds paths in the environment,
        for use by subsequent logic.
        cSs@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�Nz(%s) �_base_executableZwin32ZScriptsZInclude�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�envr7�dirnameZexenameZbinnameZincpathZlibpathrZ	link_path�binpathr
r
rrVsJ



zEnvBuilder.ensure_directoriesc	Csztj�|jd�|_}t|ddd��L}|�d|j�|jrBd}nd}|�d|�|�d	t	j
d
d��Wd
QRXd
S)aA
        Create a configuration file indicating where the environment's Python
        was copied from, and whether the system site-packages should be made
        available in the environment.

        :param context: The information for the environment creation request
                        being processed.
        z
pyvenv.cfg�wzutf-8)�encodingz
home = %s
�trueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
N�)r
rrrZcfg_path�open�writer8rr6r:)r	rr�fZinclr
r
rr�s	zEnvBuilder.create_configuration�ntcCs�|j}|s�yRtj�|�s\|rPtj�|�tj�|�ks:t�t�tj�|�|�nt�||�Wn&tk
r�t	�
d||�d}YnX|r�t�||�dS)zY
            Try symlinking a file, and if that fails, fall back to copying.
            zUnable to symlink %r to %rTN)
rr
rrrB�AssertionErrorr=�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�yF|rhtj�|�tj�|�ksRt�t�tj�	|�|�nt�||�dSt
k
r�t�d||�YnXtj�
tj�	|��\}}tj�tj�t�dd||�}t�d�s�tj�|��sB|�d��rd|}|dd�}|dk�rd	}n|d
k�r&d}tj�tj�|�||�}n|}tj�|��sj|�sft�d|�dSt�||�dS)
zY
            Try symlinking a file, and if that fails, fall back to copying.
            NzUnable to symlink %r to %r�scriptsrKTZ_d����pythonZvenvlauncherZpythonwZ
venvwlauncherzUnable to copy %r)r
r�lexistsr"rrrBrLr=rMrNrOrP�splitextr�__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)z�
        Set up a Python executable in the environment.

        :param context: The information for the environment creation request
                        being processed.
        rKi�)rXZpython3T)rTcSs,g|]$}tj�tj�|�d�dkr|�qS)r')z.exez.dll)r
r�normcaserZ)�.0rJr
r
r�
<listcomp>�sz+EnvBuilder.setup_python.<locals>.<listcomp>cSs"g|]}tj�|��d�r|�qS))rXZ	vcruntime)r
rr_�
startswith)r`rJr
r
rrasz
python.exezpython_d.exezpythonw.exez
pythonw_d.exezinit.tclr)N)r>r@rUr8r
r<r7rr�chmodrr"rrr\r]rY�walkrMrr#rrQ)r	rrCrZcopierrB�suffix�suffixesrR�root�dirs�filesZtcldirrSr
r
rr�sF





zEnvBuilder.setup_pythoncCs$|jddddg}tj|tjd�dS)z1Installs or upgrades pip in a virtual environmentz-ImZ	ensurepipz	--upgradez
--default-pip)�stderrN)r@�
subprocessZcheck_outputZSTDOUT)r	r�cmdr
r
rrs
zEnvBuilder._setup_pipcCs2tj�tj�t��}tj�|d�}|�||�dS)a�
        Set up scripts into the created environment from a directory.

        This method installs the default scripts into the environment
        being created. You can prevent the default installation by overriding
        this method if you really need to, or if you need to specify
        a different location for the scripts to install. By default, the
        'scripts' directory in the venv package is used as the source of
        scripts to install.
        rVN)r
rrrBr[r�install_scripts)r	rrr
r
rr"szEnvBuilder.setup_scriptscCsdS)a
        Hook for post-setup modification of the venv. Subclasses may install
        additional packages or scripts here, add activation shell scripts, etc.

        :param context: The information for the environment creation request
                        being processed.
        Nr
)r	rr
r
rr1szEnvBuilder.post_setupcCsJ|�d|j�}|�d|j�}|�d|j�}|�d|j�}|�d|j�}|S)ai
        Replace variable placeholders in script text with context-specific
        variables.

        Return the text passed in , but with variables replaced.

        :param text: The text in which to replace placeholder variables.
        :param context: The information for the environment creation request
                        being processed.
        Z__VENV_DIR__Z
__VENV_NAME__Z__VENV_PROMPT__Z__VENV_BIN_NAME__Z__VENV_PYTHON__)�replacerr3rr?r@)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)as
        Install scripts into the created environment from a directory.

        :param context: The information for the environment creation request
                        being processed.
        :param path:    Absolute pathname of a directory containing script.
                        Scripts in the 'common' subdirectory of this directory,
                        and those in the directory named for the platform
                        being run on, are installed in the created environment.
                        Placeholder variables are replaced with environment-
                        specific values.
        N�commonrKrX)z.exez.pdbr,�rbzutf-8z+unable to copy script %r, may be binary: %s�wb)r>�lenr
rdr<rrbr^rrr2�sepr"r#rH�read�decoderp�encode�UnicodeErrorrOrPrIrZcopymode)r	rrrCZplenrgrhrir%rJZsrcfilereZdstdirZdstfile�data�er
r
rrmMsF



zEnvBuilder.install_scripts)FFFFFN)F)F)�__name__�
__module__�__qualname__�__doc__rrr!rrr
r<rUrrrrrprmr
r
r
rrs 
5

+<	
rFcCs t|||||d�}|�|�dS)z,Create a virtual environment in a directory.)rrrrrN)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)rGrGF�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.)�progZdescriptionZepilogrhZENV_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�rKz
--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)r6r:�hasattrr$�argparse�ArgumentParserr|�add_argumentr
r<Zadd_mutually_exclusive_group�
parse_argsrrrr�rrrrhr)	�argsZ
compatibler��parserZuse_symlinks�groupZoptionsr�r%r
r
r�main�s\










r��__main__r'z	Error: %s)�file)FFFFN)N)rZloggingr
rrkr6r\r0Z	getLoggerr|rOrrr�ZrcrNr{�printrj�exitr
r
r
r�<module>s,
p

H$