ok

Mini Shell

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

3


 \�H�@s�dZddlZddlZddlZddlZddlZddlZeje�Z	Gdd�d�Z
ddd�Zddd	�Zed
kr�dZ
ye�dZ
Wn4ek
r�Zzedeejd
�WYddZ[XnXeje
�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
dkrHdd�Zd dd�Zdd�Z
dd�Zdd�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
�%/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)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�create3s





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_directoryMs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|dd�}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)z�
        Create the directories for the environment.

        Returns a context object which holds paths in the environment,
        for use by subsequent logic.
        cSs@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�Nz(%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
rrUsN



zEnvBuilder.ensure_directoriescCsztjj|jd�|_}t|ddd��L}|jd|j�|jrBd}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�wzutf-8)�encodingz
home = %s
�trueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
N�)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}|s�yRtjj|�s\|rPtjj|�tjj|�ks:t�tjtjj|�|�ntj||�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
rrrC�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|�sFtj	|d�xNdD]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�qrWd
S)z�
        Set up a Python executable in the environment.

        :param context: The information for the environment creation request
                        being processed.
        rLi�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*N)rOr^)r?rAr]r9r:r
r=rr�chmodrr"rSrr�walkrUrr#rrY)r	rrDrZcopierrC�suffixZsubdir�filesrKrZr[�root�dirsZtcldirr
)r,rr�sN






zEnvBuilder.setup_pythoncCs$|jddddg}tj|tjd�dS)z1Installs or upgrades pip in a virtual environmentz-ImZ	ensurepipz	--upgradez
--default-pip)�stderrN)rA�
subprocessZcheck_outputZSTDOUT)r	r�cmdr
r
rr�s
zEnvBuilder._setup_pipcCs2tjjtjjt��}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
rrrC�__file__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
rrszEnvBuilder.post_setupcCsJ|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__)�replacerr5rr@rA)r	�textrr
r
r�replace_variablesszEnvBuilder.replace_variablesc!Cs�|j}t|�}�x�tj|�D�]x\}}}||kr`x,|dd�D]}|dtjfkr>|j|�q>Wq�x2|D�](}	tjj||	�}
||d�jtj	�dd�}|s�|}ntjj|f|��}tjj
|�s�tj|�tjj||	�}
t|
d��}	|	j
�}WdQRX|
jd��s^y$|jd�}|j||�}|jd�}Wn6tk
�r\}zd}tjd|
|�WYdd}~XnX|dk	rht|
d��}	|	j|�WdQRXtj|
|
�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�commonr.�rbz.exezutf-8z+unable to copy script %r, may be binary: %s�wb)r?�lenr
rbr=rrrr4�sepr"r#rI�readrP�decodero�encode�UnicodeErrorrWrXrJrZcopymode)r	rrrDZplenrerfrdr%rKZsrcfilercZdstdirZdstfile�data�er
r
rrl"s@


zEnvBuilder.install_scripts)FFFFFN)F)�__name__�
__module__�__qualname__�__doc__rrr!rrr
r=rSr]rrrrrorlr
r
r
rrs 
8

3	
rFcCs t|||||d�}|j|�dS)z,Create a virtual environment in a directory.)rrrrrN)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.)�progZdescriptionZepilogrfZENV_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�rrrrfr)	�argsZ
compatibler��parserZuse_symlinks�groupZoptionsrr%r
r
r�mainZs\










r��__main__r'z	Error: %s)�file)FFFFN)N)r~Zloggingr
rrhr7r2Z	getLoggerr{rWrrr�ZrcrVrz�printrg�exitr
r
r
r�<module>s*
C

H$

Zerion Mini Shell 1.0