
    .Ph#                    t   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ ddlmZ  eej                            e                    j        Z e dz  Z! ej"        e#          Z$ G d d          Z% G d de          Z&d Z'ddgZ(dS )    )annotationsN)ABCabstractmethod)ArgumentTypeError)literal_eval)OrderedDict)Path)LogCmd)safe_delete)run_cmd)__version__   )PyEnvCfgzdebug.pyc                      e Zd ZddZdS )CreatorMetareturnNonec                    d | _         d S N)errorselfs    Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/virtualenv/create/creator.py__init__zCreatorMeta.__init__   s    


    Nr   r   )__name__
__module____qualname__r    r   r   r   r      s(             r   r   c                      e Zd ZdZddZddZd Zed             Zed	             Z	e
d
             Zed             Zd Zd Zd Zd Zed             Zed             ZdS )CreatorzFA class that given a python Interpreter creates a virtual environment.r   r   c                    || _         d| _        t          |j                  | _        |j        | _        |j        | _        t          j        | j                  | _        |j	        | _	        |j
        | _
        dS )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   optionsr$   s      r   r   zCreator.__init__"   sc     '&&	]
$2!-di88(;r   strc                    | j         j         dd                    d |                                 D                        dS )N(z, c              3  *   K   | ]\  }}| d | V  dS )=Nr    ).0kvs      r   	<genexpr>z#Creator.__repr__.<locals>.<genexpr>3   s0      5Z5ZTQjjQjj5Z5Z5Z5Z5Z5Zr   ))	__class__r   join_argsr   s    r   __repr__zCreator.__repr__2   sA    .)]]DII5Z5ZTZZ\\5Z5Z5Z,Z,Z]]]]r   c                P    dt          | j                  fd| j        fd| j        fgS )Nr&   r'   r(   )r.   r&   r'   r(   r   s    r   r:   zCreator._args5   s1    S^^$dj!d01
 	
r   c                    dS )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    )clsr$   s     r   
can_createzCreator.can_create<   s	     tr   c                    |                     dd| j                   |                     ddddd	           |                     d
dddd	           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&   actionrA   defaultz--no-vcs-ignorer(   z>don't create VCS ignore directive in the destination directoryN)add_argumentvalidate_dest)r>   parserr$   metar+   s        r   add_parser_argumentszCreator.add_parser_argumentsG   s     	4" 	 	
 	
 	

 	m 	 	
 	
 	
 	 Q 	 	
 	
 	
 	
 	
r   c                    t           )z)Perform the virtual environment creation.)NotImplementedErrorr   s    r   createzCreator.createe   s
     "!r   c                :   d }t          j                    }t                      }|dk    rddini }t          |          D ]N}	  |j        |fi |                    |          }||k    r+t          |          # t          $ r d||<   Y Kw xY w|rAd                    |                                          }d| d|d	|}	t          |	          t          j        |v r"d
|dt          j         d}	t          |	          t          |          }
|
                                r)|
                                rd|
 d}	t          |	          t          t          j                            t          |
                                                              }|}
|rq|                                r9t          j        t          |          t          j                  rn0 |||
           |j        |j        }}||k    r |||
           |}|qt          |
          S )zBNo path separator in the path, valid chars and must be write-able.c                    t          t          j                            |j        | j        g           }d|                     |           d| }t          |          )Nthe destination z is not write-able at )r	   ospathcommonprefixpartsrelative_tor   )r&   valuecommonmsgs       r   non_write_ablez-Creator.validate_dest.<locals>.non_write_ablen   sW    27//dj0IJJKF]T%5%5f%=%=]]U[]]C#C(((r   mbcserrorsignoreN zthe 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 scriptsrP   z already exists and is a file)sysgetfilesystemencodingr   r.   encodedecode
ValueErrorr9   keysr   rQ   pathsepr	   existsis_filerR   abspathresolveaccessW_OKparentname)r>   	raw_valuerY   encodingrefusedkwargschartripbadrX   rV   r&   base_s                 r   rG   zCreator.validate_destj   sd   	) 	) 	) ,..--)1V););(H%%	NN 	% 	%D%"t{866v66==hGG4<< &&& % % % $% 	)''',,..))CmHmmQTmm`immC#C(((:""?y ? ?RTR\ ? ? ?  $C(((Y<<>> 	)emmoo 	)IUIIIC#C(((BGOOCJJ//0088:: 	{{}} ,9SYY00 tU+++k49!Dt||tU+++D  	 5zzs   'A:+A::BBc                `   | j                                         r;| j        r4t                              d| j                    t          | j                    |                                  |                                  |                                  | j	        s| 
                                 d S d S )Nz	delete %s)r&   re   r'   LOGGERdebugr   rM   add_cachedir_tagset_pyenv_cfgr(   setup_ignore_vcsr   s    r   runzCreator.run   s    9 	#$* 	#LLdi000	"""! 	$!!#####	$ 	$r   c                    | j         dz  }|                                s?t          j        d                                          }|                    |d           dS dS )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rn   N)r&   re   textwrapdedentstrip
write_text)r   cachedir_tag_filecachedir_tag_texts      r   ry   zCreator.add_cachedir_tag   sv     I6 '')) 	N ( 1 ! !
   (():W(MMMMM	N 	Nr   c                z   t                      | j        _        t          j                            t          j                            | j        j                            | j        d<   | j        j	        | j        d<   d
                    d | j        j        D                       | j        d<   t          | j        d<   d S )Nhomeimplementation.c              3  4   K   | ]}t          |          V  d S r   )r.   )r3   is     r   r6   z(Creator.set_pyenv_cfg.<locals>.<genexpr>   s(      1`1`Q#a&&1`1`1`1`1`1`r   version_info
virtualenv)r   r*   contentrQ   rR   dirnamerg   r$   system_executabler   r9   r   r   r   s    r   rz   zCreator.set_pyenv_cfg   s    !,!#AQAc1d1d!e!ev+/+;+J'(),1`1`$BRB_1`1`1`)`)`~&'2|$$$r   c                t    | j         dz  }|                                s|                    dd           dS dS )z9Generate ignore instructions for version control systems.z
.gitignorez(# created by virtualenv automatically
*
r~   r   N)r&   re   r   )r   
git_ignores     r   r{   zCreator.setup_ignore_vcs   sR     Y-
  "" 	b!!"NY`!aaaaa	b 	br   c                    | j         ?| j        8t          | j        |                                 | j        | j                  | _         | j         S )zb:return: debug information about the virtual environment (only valid after :meth:`create` has run))r%   exeget_env_debug_infodebug_scriptr+   r,   r   s    r   rx   zCreator.debug   sD     ;48#7,TXt7H7H7J7JDM[_[cddDK{r   c                     t           S r   )DEBUG_SCRIPTr    r   r   r   zCreator.debug_script   s    r   Nr   )r   r.   )r   r   r   __doc__r   r;   r:   classmethodr?   rJ   r   rM   rG   r|   ry   rz   r{   propertyrx   staticmethodr   r    r   r   r"   r"      s:       PP    ^ ^ ^ ^
 
 
   [ 
 
 [
: " " ^" / / [/b$ $ $
N 
N 
N3 3 3b b b   X   \  r   r"   c                   |                                 }|                    dd            |                    |          5 }t          |           t          |          g}t                              dt          |                     t          |          \  }}}d d d            n# 1 swxY w Y   	 |dk    r:|rt          |          }	n<|dk    rd|v rt          |          t          |          t          j        |          }	|r||	d<   n+# t          $ r}
|||t          |
          dcY d }
~
S d }
~
ww xY wd|	v rd	|	d         v r|	d         d	         d= |	S )
N
PYTHONPATHzdebug via %rr      fileerr)outr   
returncode	exceptionr^   rR   )copypopensure_extractedr.   rw   rx   r
   r   r   OSError	Exceptionjsonloadsrepr)env_exer   r+   r,   debug_script_extractedcmdcoder   r   resultr   s              r   r   r      s   
((**CGGL$		"	"<	0	0 &4J7||S!7889^VC[[111 c3& & & & & & & & & & & & & & &
Z199 %%c**1993!#,,&nn$Z__F 	 F5M Z Z Z3diYYYYYYYYZ6VE]225M&!!$Ms2    AB&&B*-B*2AD 
D6D1+D61D6))
__future__r   r   loggingrQ   r^   r   abcr   r   argparser   astr   collectionsr   pathlibr	   #virtualenv.discovery.cached_py_infor
   virtualenv.util.pathr   virtualenv.util.subprocessr   virtualenv.versionr   r*   r   rR   rg   __file__rk   HEREr   	getLoggerr   rw   r   r"   r   __all__r    r   r   <module>r      s   " " " " " "   				 



  # # # # # # # # & & & & & &       # # # # # #       6 6 6 6 6 6 , , , , , , . . . . . . * * * * * *      tBGOOH%%&&-j 		8	$	$       
o o o o oc o o od  < r   