AlkantarClanX12

Your IP : 18.117.78.87


Current Path : /opt/alt/python310/lib64/python3.10/venv/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/venv/__pycache__/__init__.cpython-310.pyc

o

6��f�]�
@s�dZddlZddlZddlZddlZddlZddlZddlZdZe�	e
�ZGdd�d�Z		ddd�Z
dd	d
�Ze
dkrhdZze�dZWney`Zzed
eejd�WYdZ[ndZ[wwe�e�dSdS)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.
�N)�pipZ
setuptoolsc@s�eZdZdZ			d"dd�Zdd�Zdd	�Zd
d�Zdd
�Ze	j
dkr)d#dd�Znd#dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�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.
    :param upgrade_deps: Update the base venv modules to the latest on PyPI
    FNcCsF||_||_||_||_||_|dkrtj�t���}||_	||_
dS)N�.)�system_site_packages�clear�symlinks�upgrade�with_pip�os�path�basename�getcwd�prompt�upgrade_deps)�selfrrrrr	rr�r�4/opt/alt/python310/lib64/python3.10/venv/__init__.py�__init__.s
zEnvBuilder.__init__cCs�tj�|�}|�|�}|j}d|_|�|�|�|�|jr#|�|�|j	s0|�
|�|�|�|r:d|_|�|�|jrD|�
|�dSdS)z�
        Create a virtual environment in a directory.

        :param env_dir: The target directory to create an environment in.

        FTN)r
r�abspath�ensure_directoriesr�create_configuration�setup_pythonr	�
_setup_pipr�
setup_scripts�
post_setupr�upgrade_dependencies)r�env_dir�contextZtrue_system_site_packagesrrr�create;s"






�zEnvBuilder.createcCs\t�|�D]&}tj�||�}tj�|�stj�|�r t�|�qtj�|�r+t�	|�qdS�N)
r
�listdirr�join�islink�isfile�remove�isdir�shutilZrmtree)rr�fnrrr�clear_directoryWs
��zEnvBuilder.clear_directorycCs�dd�}tj�|�r|jr|�|�t��}||_tj�|�d|_	|j
dur*|j
n|j	}d||_
||�tj}|s?t
d��tj�tj�|��\}}||_||_||_tjdkrfd}d	}	tj�|d
d�}
nd}d
}	tj�|ddtjdd�d�}
tj�||	�|_}||�||
�tjdkr�tjdkr�tjdkr�tj�|d�}tj�|�s�t�d|�tj�||�|_}
||_tj�|
|�|_||
�|j|_tjdkr�tj�|j�}tj�|�tj�|j�kr�t� d|j|�||_|S)z�
        Create the directories for the environment.

        Returns a context object which holds paths in the environment,
        for use by subsequent logic.
        cSsBtj�|�s
t�|�dStj�|�stj�|�rtd|��dS)NzUnable to create directory %r)r
r�exists�makedirsr"r#�
ValueError)�drrr�create_if_neededgs
�z7EnvBuilder.ensure_directories.<locals>.create_if_needed�Nz(%s) z�Unable to determine path to the running Python interpreter. Provide an explicit path or check that your PATH environment variable is correctly set.Zwin32ZScriptsZInclude�Libz
site-packages�binZinclude�libzpython%d.%d�l�posix�darwinZlib64z�Actual environment location may have moved due to redirects, links or junctions.
  Requested location: "%s"
  Actual location:    "%s")!r
rr)rr(�types�SimpleNamespacer�split�env_namer�sys�_base_executabler+r�
executable�
python_dirZ
python_exe�platformr!�version_infoZinc_path�maxsize�name�symlink�bin_path�bin_name�env_exe�env_exec_cmd�realpath�normcase�logger�warning)rrr-rrr;�dirnameZexenameZbinnameZincpathZlibpathrZ	link_path�binpathZreal_env_exerrrr_s^



�

�zEnvBuilder.ensure_directoriescCs�tj�|jd�|_}t|ddd��C}|�d|j�|jr!d}nd}|�d|�|�d	t	j
d
d��|jd
urM|�d|j�d
��Wd
�d
SWd
�d
S1sXwYd
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
�trueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
N�z	prompt = �
)r
rr!rZcfg_path�open�writer<rr9r>r)rrr�fZinclrrrr�s	
�"�zEnvBuilder.create_configuration�ntcCs�|j}|sBz)tj�|�s.|r(tj�|�tj�|�ksJ�t�tj�|�|�nt�||�WntyAt�	d||�d}Ynw|rLt
�||�dSdS)�Y
            Try symlinking a file, and if that fails, fall back to copying.
            �Unable to symlink %r to %rTN)rr
rr"rJrAr�	ExceptionrHrIr&�copyfile)r�src�dst�relative_symlinks_okZ
force_copyrrr�symlink_or_copy�s ���zEnvBuilder.symlink_or_copycCsrtj�|�otj�|�}|jrO|sOtj�|�sOz&|r6tj�|�tj�|�ks)J�t�tj�|�|�WdSt�||�WdSt	yNt
�d||�Ynwtj�tj�|��\}}tj�
tj�t�dd||�}t�d�sutj�|�s�|�d�r�d|}|dd�}|dkr�d	}n|d
kr�d}tj�
tj�|�||�}n|}tj�|�s�|s�t
�d|�dSt�||�dS)
rVNrW�scriptsrUTZ_d����pythonZvenvlauncherZpythonwZ
venvwlauncherzUnable to copy %r)r
r�lexistsr)rr"rJrArrXrHrI�splitextr!�__file__�	sysconfig�is_python_buildr#�endswithr&rY)rrZr[r\Zbad_srcrZextZsrcfnrrrr]�sB���
cCs�|j}|j}|j}|j}tjdkrT||j|�tj�|�s#t�	|d�dddt
jd��fD]#}tj�||�}tj�
|�sQ||j|dd�tj�|�sQt�	|d�q.dS|jrnd	d
�t�|�D�}t�d�rmdd
�|D�}nhd�}tj�|j�}|�|�|D]}tj�||�}	tj�|	�r�||	tj�||��q�t�d�r�t�|j�D]<\}
}}d
|vr�tj�|
�}
tj�|jd|
�}
tj�
|
�s�t�|
�tj�|
d
�}	tj�|
d
�}t�|	|�dSq�dSdS)z�
        Set up a Python executable in the environment.

        :param context: The information for the environment creation request
                        being processed.
        rUi�r`Zpython3zpython3.r.T)r\cSs,g|]}tj�tj�|�d�dvr|�qS)r.)�.exez.dll)r
rrGrb��.0rTrrr�
<listcomp>s
�z+EnvBuilder.setup_python.<locals>.<listcomp>cSs"g|]
}tj�|��d�r|�qS))r`Z	vcruntime)r
rrG�
startswithrhrrrrjs��>zpython_d.exez
pythonw_d.exezpythonw.exez
python.exezinit.tclr/N)rBrDr]r<r
r@r;rr"�chmodr9r>r!r)rr rdrer�addra�walkrr*r&rY)rrrKrZcopierrJ�suffix�suffixesZbase_exerZ�root�dirs�filesZtcldirr[rrrr�s^
��	�
��
�

��zEnvBuilder.setup_pythoncOsj|jg|�}tj��|d<}|j|d<|�dd�|�dd�|j|d<|j|d<tj|fi|��dS)z8Executes the newly created Python using safe-ish options�envZVIRTUAL_ENVZ
PYTHONHOMENZ
PYTHONPATH�cwdr;)rEr
�environ�copyr�pop�
subprocessZcheck_output)rrZpy_args�kwargs�argsrtrrr�_call_new_python7s


zEnvBuilder._call_new_pythoncCs|j|ddddtjd�dS)z1Installs or upgrades pip in a virtual environment�-mZ	ensurepip�	--upgradez
--default-pip)�stderrN)r|ryZSTDOUT�rrrrrrFs
�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.
        r^N)r
rrrJrcr!�install_scripts)rrrrrrrKszEnvBuilder.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.
        Nrr�rrrrZszEnvBuilder.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__)�replacerr8rrCrD)r�textrrrr�replace_variablesdszEnvBuilder.replace_variablescCs�|j}t|�}t�|�D]�\}}}||kr+|dd�D]}|dtjfvr)|�|�qq|D]�}	tjdkr?|	�d�r?|	�d�r?q-tj�	||	�}
||d��
tj�dd�}|sY|}n
tjj	|g|�R�}tj�|�snt�
|�tj�	||	�}
t|
d��}	|	��}Wd�n1s�wY|
�d�s�z|�d�}|�||�}|�d�}Wnty�}zd}t�d	|
|�WYd}~nd}~ww|dur�t|
d
��
}	|	�|�Wd�n1s�wYt�|
|
�q-qdS)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�commonrUr`)rgz.pdbr2�rbrMz+unable to copy script %r, may be binary: %s�wb)rB�lenr
rnr@r$rkrfrr!r7�sepr)r*rR�read�decoder��encode�UnicodeErrorrHrIrSr&Zcopymode)rrrrKZplenrqrrrsr,rTZsrcfileroZdstdirZdstfile�data�errrr�vsZ

��

�

�������zEnvBuilder.install_scriptscCs6t�dt�d|j���|j|ddddgt�R�dS)Nz
Upgrading z
 packages in r}rZinstallr~)rH�debug�CORE_VENV_DEPSrBr|r�rrrr�s��zEnvBuilder.upgrade_dependencies)FFFFFNF)F)�__name__�
__module__�__qualname__�__doc__rrr(rrr
r@r]rr|rrrr�r�rrrrrrs*
�
G

+=
2rFcCs"t||||||d�}|�|�dS)z,Create a virtual environment in a directory.)rrrr	rrN)rr)rrrrr	rr�builderrrrr�s
�rc	
Csxd}tjdkr
d}nttd�sd}|std��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'�|jd(ddd)d*�d+�t
��d�|�|�}|jr�|jr�td,��t|j|j|j|j|j|j|jd-�}|jD]}|�|�q�dS).NT)rPrPF�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�descriptionZepilogrrZENV_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�rUz
--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.r~rzlUpgrade 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�z--upgrade-depsrz;Upgrade core dependencies: {} to the latest version in PyPI� z1you cannot supply --upgrade and --clear together.)rrrrr	rr)r9r>�hasattrr+�argparse�ArgumentParserr��add_argumentr
r@Zadd_mutually_exclusive_group�formatr!r��
parse_argsrrrr�rr	rrrrr)	r{Z
compatibler��parserZuse_symlinks�groupZoptionsr�r,rrr�main�s�

�

��
�
�
�
���
��
�
�r��__main__r.z	Error: %s)�file)FFFFNFr)r�Zloggingr
r&ryr9rdr5r�Z	getLoggerr�rHrrr�ZrcrXr��printr�exitrrrr�<module>s:

�
N���