Your IP : 52.15.241.87


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.pyc



��Yf2N�@s
dZddlZddlZddlZddlZddlZddlZeje�Z	Gdd�d�Z
dddddd�Zddd	�Zed
krdZ
ye�dZ
Wn<ek
r�Zzeded
ej�WYddZ[XnXeje
�dS)a�
Virtual environment (venv) package for Python. Based on PEP 405.

Copyright (C) 2011-2014 Vinay Sajip.
Licensed to the PSF under a contributor agreement.

usage: python -m venv [-h] [--system-site-packages] [--symlinks] [--clear]
            [--upgrade]
            ENV_DIR [ENV_DIR ...]

Creates virtual Python environments in one or more target directories.

positional arguments:
  ENV_DIR               A directory to create the environment in.

optional arguments:
  -h, --help            show this help message and exit
  --system-site-packages
                        Give the virtual environment access to the system
                        site-packages dir.
  --symlinks            Attempt to symlink rather than copy.
  --clear               Delete the contents of the environment directory if it
                        already exists, before environment creation.
  --upgrade             Upgrade the environment directory to use this version
                        of Python, assuming Python has been upgraded in-place.
  --without-pip         Skips installing or upgrading pip in the virtual
                        environment (pip is bootstrapped by default)
�Nc@s�eZdZdZddddddd�Zdd�Zdd�Zd	d
�Zdd�Ze	j
d
krxdd�Zddd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS)�
EnvBuilderaR
    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
    FcCs1||_||_||_||_||_dS)N)�system_site_packages�clear�symlinks�upgrade�with_pip)�selfrrrrr�r	�2/opt/alt/python35/lib64/python3.5/venv/__init__.py�__init__?s
				zEnvBuilder.__init__cCs�tjj|�}|j|�}|j}d|_|j|�|j|�|jrc|j|�|j	s�|j
|�|j|�|r�d|_|j|�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
�createGs		

	
	

	zEnvBuilder.createcCs�xtj|�D]n}tjj||�}tjj|�sOtjj|�r_tj|�qtjj|�rtj	|�qWdS)N)
r�listdirr
�join�islink�isfile�remove�isdir�shutilZrmtree)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)z�
        Create the directories for the environment.

        Returns a context object which holds paths in the environment,
        for use by subsequent logic.
        cSsZtjj|�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.%dN�� �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
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�w�encodingzutf-8z
home = %s
�true�falsez"include-system-site-packages = %s
zversion = %d.%d.%d
N�)rr
rrZcfg_path�open�writer;rr8r<)rrr
�fZinclr	r	r
r�s			zEnvBuilder.create_configuration�ntcCs:|jd�rd}n|jd�o3|jd�}|S)N�.pyd�.dllT�pythonz.exe)rOrP)�endswith�
startswith)rrM�resultr	r	r
�include_binary�s	zEnvBuilder.include_binarycCs�|j}|s�yutjj|�s�|rttjj|�tjj|�ksUt�tjtjj|�|�ntj||�Wn+tk
r�t	j
d||�d}YnX|r�tj||�dS)zQ
        Try symlinking a file, and if that fails, fall back to copying.
        zUnable to symlink %r to %rTN)
rrr
rrD�AssertionErrorr?�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�xBdD]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|
|�PqWd
S)z�
        Set up a Python executable in the environment.

        :param context: The information for the environment creation request
                        being processed.
        rNi�rQ�python3r^TZDLLscs"g|]}�|�r|�qSr	r	)�.0rM)r,r	r
�
<listcomp>�s	z+EnvBuilder.setup_python.<locals>.<listcomp>cs"g|]}�|�r|�qSr	r	)rarM)r,r	r
rb�s	zinit.tclr*N)rQr`)r@rBr_r:r;rr>r
r�chmodrr!rUrr�walkrWrr"rr[)rrrEr
ZcopierrD�suffixZsubdir�filesrMr\r]�root�dirsZtcldirr	)r,r
r�sN				
	"
"
"
zEnvBuilder.setup_pythoncCs2|jddddg}tj|dtj�dS)z1Installs or upgrades pip in a virtual environmentz-ImZ	ensurepipz	--upgradez
--default-pip�stderrN)rB�
subprocessZcheck_outputZSTDOUT)rr�cmdr	r	r
rs	zEnvBuilder._setup_pipcCsGtjjtjjt��}tjj|d�}|j||�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.
        �scriptsN)rr
rrD�__file__r�install_scripts)rrr
r	r	r
r
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	)rrr	r	r
rszEnvBuilder.post_setupcCsm|jd|j�}|jd|j�}|jd|j�}|jd|j�}|jd|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__)�replacerr5r6rArB)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)	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�commonr.�rbz.exezutf-8z+unable to copy script %r, may be binary: %s�wb)r@�lenrrdr>rr
rr4�sepr!r"rK�readrR�decoderq�encode�UnicodeErrorrYrZrLrZcopymode)rrr
rEZplenrgrhrfr$rMZsrcfilereZdstdirZdstfile�data�er	r	r
rn5s@
	
&	
	zEnvBuilder.install_scriptsN)�__name__�
__module__�__qualname__�__doc__rrr rrrr>rUr_rrrrrqrnr	r	r	r
r's 73	
rFc	Cs2td|d|d|d|�}|j|�dS)aL
    Create a virtual environment in a directory.

    By default, makes the system (global) site-packages dir *un*available to
    the created environment, and uses copying rather than symlinking for files
    obtained from the source Python installation.

    :param env_dir: The target directory to create an environment in.
    :param system_site_packages: If True, the system (global) site-packages
                                 dir is available to the environment.
    :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 with_pip: If True, ensure pip is installed in the virtual
                     environment
    rrrrN)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)-NTrJF�base_prefixz.This script is only for use with Python >= 3.3r�progZdescriptionzFCreates virtual Python environments in one or more target directories.Zepilogz|Once an environment has been created, you may wish to activate it, e.g. by sourcing an activate script in its bin directory.rh�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.rNz
--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)z1you cannot supply --upgrade and --clear together.r)rJrJ)r8r<�hasattrr#�argparse�ArgumentParserr}�add_argumentrr>Zadd_mutually_exclusive_group�
parse_argsrrrr�rrrhr)	�argsZ
compatibler��parserZuse_symlinks�groupZoptionsr�r$r	r	r
�main|sV			

			r��__main__r&z	Error: %s�file)r�Zloggingrrrjr8r2Z	getLoggerr}rYrrr��rcrXr|�printri�exitr	r	r	r
�<module>s(�?D
*

?>