HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/virtualenv/create/__pycache__/creator.cpython-310.pyc
o

3�h�#�@sddlmZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZdd
lmZeej�e��jZ e dZ!e�"e#�Z$Gdd�d�Z%Gdd�de�Z&dd�Z'ddgZ(dS)�)�annotationsN)�ABC�abstractmethod)�ArgumentTypeError)�literal_eval)�OrderedDict)�Path)�LogCmd)�safe_delete)�run_cmd)�__version__�)�PyEnvCfgzdebug.pyc@seZdZddd�ZdS)�CreatorMeta�return�NonecCs
d|_dS�N)�error��self�r�D/usr/local/lib/python3.10/dist-packages/virtualenv/create/creator.py�__init__s
zCreatorMeta.__init__N�rr)�__name__�
__module__�__qualname__rrrrrrsrc@s�eZdZdZd dd�Zd!dd�Zd	d
�Zedd��Zed
d��Z	e
dd��Zedd��Zdd�Z
dd�Zdd�Zdd�Zedd��Zedd��ZdS)"�CreatorzFA class that given a python Interpreter creates a virtual environment.rrcCsJ||_d|_t|j�|_|j|_|j|_t�|j�|_|j	|_	|j
|_
dS)z�
        Construct a new virtual environment creator.

        :param options: the CLI option as parsed from :meth:`add_parser_arguments`
        :param interpreter: the interpreter to create virtual environment from
        N)�interpreter�_debugr�dest�clear�
no_vcs_ignorer�from_folder�	pyenv_cfg�app_data�env)r�optionsrrrrr"szCreator.__init__�strcCs(|jj�dd�dd�|��D���d�S)N�(z, css"�|]\}}|�d|��VqdS)�=Nr)�.0�k�vrrr�	<genexpr>3s� z#Creator.__repr__.<locals>.<genexpr>�))�	__class__r�join�_argsrrrr�__repr__2s(zCreator.__repr__cCs dt|j�fd|jfd|jfgS)Nr r!r")r(r r!r"rrrrr25s�z
Creator._argscCsdS)a
        Determine if we can create a virtual environment.

        :param interpreter: the interpreter in question
        :return: ``None`` if we can't create, any other object otherwise that will be forwarded to                   :meth:`add_parser_arguments`
        Tr)�clsrrrr�
can_create<s	zCreator.can_createcCs>|jdd|jd�|jdddddd	�|jd
ddddd	�d
S)a'
        Add CLI arguments for the creator.

        :param parser: the CLI parser
        :param app_data: the application data folder
        :param interpreter: the interpreter we're asked to create virtual environment for
        :param meta: value as returned by :meth:`can_create`
        r z!directory to create virtualenv at)�help�typez--clearr!�
store_truezZremove the destination directory if exist before starting (will overwrite files otherwise)F)r �actionr6�defaultz--no-vcs-ignorer"z>don't create VCS ignore directive in the destination directoryN)�add_argument�
validate_dest)r4�parserr�metar%rrr�add_parser_argumentsGs&
��
�zCreator.add_parser_argumentscCst�)z)Perform the virtual environment creation.)�NotImplementedErrorrrrr�createeszCreator.createc	Cs~dd�}t��}t�}|dkrddini}t|�D]%}z|j|fi|���|�}||kr.Wqt|��ty>d||<Yqw|rWd�|���}d|�d	|�d
|��}	t	|	��t
j|vrjd|�dt
j�d
�}	t	|	��t|�}
|
�
�r�|
��r�d|
�d�}	t	|	��tt
j�t|
�����}|}
|r�|�
�r�t
�t|�t
j�r�	t|
�S|||
�|j|j}}
||kr�|||
�|}|s�t|
�S)zBNo path separator in the path, valid chars and must be write-able.cSs6ttj�|j|jg��}d|�|��d|��}t|��)N�the destination z is not write-able at )r�os�path�commonprefix�parts�relative_tor)r �value�common�msgrrr�non_write_ablensz-Creator.validate_dest.<locals>.non_write_able�mbcs�errors�ignoreN�zthe file system codec (z) cannot handle characters z within zdestination z& must not contain the path separator (z,) as this would break the activation scriptsrBz already exists and is a file)�sys�getfilesystemencodingrr(�encode�decode�
ValueErrorr1�keysrrC�pathsepr�exists�is_filerD�abspath�resolve�access�W_OK�parent�name)r4�	raw_valuerK�encoding�refused�kwargs�char�trip�badrJrHr �base�_rrrr<jsN�
�
�
�	zCreator.validate_destcCsV|j��r|jrt�d|j�t|j�|��|��|��|j	s)|�
�dSdS)Nz	delete %s)r rWr!�LOGGER�debugr
rA�add_cachedir_tag�
set_pyenv_cfgr"�setup_ignore_vcsrrrr�run�s
�zCreator.runcCs6|jd}|��st�d���}|j|dd�dSdS)zBGenerate a file indicating that this is not meant to be backed up.zCACHEDIR.TAGa
                Signature: 8a477f597d28d172789f06886806bc55
                # This file is a cache directory tag created by Python virtualenv.
                # For information about cache directory tags, see:
                #   https://bford.info/cachedir/
            �utf-8�r`N)r rW�textwrap�dedent�strip�
write_text)r�cachedir_tag_file�cachedir_tag_textrrrrj�s
��zCreator.add_cachedir_tagcCsbt�|j_tj�tj�|jj��|jd<|jj	|jd<d�
dd�|jjD��|jd<t|jd<dS)N�home�implementation�.css�|]}t|�VqdSr)r()r+�irrrr.�s�z(Creator.set_pyenv_cfg.<locals>.<genexpr>�version_info�
virtualenv)
rr$�contentrCrD�dirnamerYr�system_executablerwr1rzrrrrrrk�s

zCreator.set_pyenv_cfgcCs(|jd}|��s|jddd�dSdS)z9Generate ignore instructions for version control systems.z
.gitignorez(# created by virtualenv automatically
*
rnroN)r rWrs)r�
git_ignorerrrrl�s
�zCreator.setup_ignore_vcscCs4|jdur|jdurt|j|��|j|j�|_|jS)zb:return: debug information about the virtual environment (only valid after :meth:`create` has run)N)r�exe�get_env_debug_info�debug_scriptr%r&rrrrri�sz
Creator.debugcCstSr)�DEBUG_SCRIPTrrrrr��szCreator.debug_scriptNr)rr()rrr�__doc__rr3r2�classmethodr5r?rrAr<rmrjrkrl�propertyri�staticmethodr�rrrrrs*






1

rc
Cs|��}|�dd�|�|��}t|�t|�g}t�dt|��t|�\}}}Wd�n1s1wYz(|dkrR|rBt|�}	n|dkrNd|vrNt	|��t
|��t�|�}	|r]||	d<Wnt
yy}
z|||t
|
�d�WYd}
~
Sd}
~
wwd|	vr�d	|	dvr�|	dd	d=|	S)
N�
PYTHONPATHzdebug via %rr��file�err)�outr��
returncode�	exceptionrPrD)�copy�pop�ensure_extractedr(rhrir	rr�OSError�	Exception�json�loads�repr)�env_exer�r%r&�debug_script_extracted�cmd�coder�r��resultr�rrrr��s2�

���r�))�
__future__rr��loggingrCrPrp�abcrr�argparser�astr�collectionsr�pathlibr�#virtualenv.discovery.cached_py_infor	�virtualenv.util.pathr
�virtualenv.util.subprocessr�virtualenv.versionrr$rrDrY�__file__r]�HEREr��	getLoggerrrhrrr��__all__rrrr�<module>s4
3�