
    yIf\                        d Z ddlmZ ddlZddlZddlmZ ddlmZ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mZ ddlmZ erddlmZ ddlmZ ddlmZ ddlmZ  G d de          Z dS )zpDeclare the abstract base class for tox environments that handle the Python language via the virtualenv project.    )annotationsN)Path)TYPE_CHECKINGAnycast)__version__)session_via_cli)
StrConvert)LocalSubProcessExecutor)Python
PythonInfo)Pip)Creator)Session)Execute)ToxEnvCreateArgsc                  ,    e Zd ZdZd% fdZd& fdZed'd	            Zed(d            Zd) fdZ	d) fdZ
d* fdZd+ fdZed,d            Zd+dZed-d            Zd&dZd.dZd/dZd0dZd0d Zd0d!Zed1d#            Zed+ fd$            Z xZS )2
VirtualEnvz<A python executor that uses the virtualenv project with pip.create_argsr   returnNonec                t    d | _         d | _        d | _        t                                          |           d S N)_virtualenv_session	_executor
_installersuper__init__)selfr   	__class__s     V/var/www/piapp/venv/lib/python3.11/site-packages/tox/tox_env/python/virtual_env/api.pyr   zVirtualEnv.__init__   s7    37 )-&*%%%%%    c                8    t                                                        j                            ddgt           fdd            j                            ddgt           fdd	            j                            d
gt           fdd           d S )Nsystem_site_packagessitepackagesc                x    t                                          j                            dd                    S )NVIRTUALENV_SYSTEM_SITE_PACKAGESFalser
   to_boolenvironment_variablesgetconfnamer   s     r!   <lambda>z,VirtualEnv.register_config.<locals>.<lambda>(   s3    z||';';*../PRYZZ( ( r"   zQcreate virtual environments that also have access to globally installed packages.)keysof_typedefaultdescalways_copy
alwayscopyc           	         t                                          j                            dj                            dd                              S )NVIRTUALENV_COPIESVIRTUALENV_ALWAYS_COPYr(   r)   r-   s     r!   r0   z,VirtualEnv.register_config.<locals>.<lambda>0   sK    z||';';*..'.223KWUU ( ( r"   z3force virtualenv to always copy rather than symlinkdownloadc                x    t                                          j                            dd                    S )NVIRTUALENV_DOWNLOADr(   r)   r-   s     r!   r0   z,VirtualEnv.register_config.<locals>.<lambda>;   s2    z||';';*../DgNN( ( r"   zQtrue if you want virtualenv to upgrade pip/wheel/setuptools to the latest version)r   register_configr.   
add_configbool)r   r    s   `r!   r=   zVirtualEnv.register_config#   s    !!!	(.9    e 	 	
 	
 	
 		.    G 	 
	
 
	
 
	
 		    e 	 	
 	
 	
 	
 	
r"   r   c                Z    | j         t          | j        j                  | _         | j         S r   )r   r   options
is_coloredr   s    r!   executorzVirtualEnv.executorA   s&    >!4T\5LMMDN~r"   r   c                F    | j         t          |           | _         | j         S r   )r   r   rC   s    r!   	installerzVirtualEnv.installerG   s    ?"!$iiDOr"   dict[str, Any]c                    t                                                      }|                    t          | j        j        d                   t          d           |S )N
executable)rI   zvirtualenv version)r   python_cacheupdatestrbase_pythonextravirtualenv_versionr   baser    s     r!   rJ   zVirtualEnv.python_cacheM   sX    ww##%%!$"2"8"FGG&8 	
 	
 	
 r"   c                    t                                                      }t          | j        j        d                   |d<   |S )NrI   )r   _get_env_journal_pythonrL   rM   rN   rP   s     r!   rS   z"VirtualEnv._get_env_journal_pythonW   s:    ww..00 !1!7!EFF\r"   	list[str]c                    t                                                      }|                    d           |                    d           |S )NzPIP_*zVIRTUALENV_*)r   _default_pass_envappendr   envr    s     r!   rV   zVirtualEnv._default_pass_env\   sA    gg''))

7

>"""
r"   dict[str, str]c                R    t                                                      }d|d<   |S )N1PIP_DISABLE_PIP_VERSION_CHECK)r   _default_set_envrX   s     r!   r^   zVirtualEnv._default_set_envb   s(    gg&&((/2+,
r"   r   c                    | j         At          | j                  g}|                                 }t	          |d d|          | _         | j         S )NF)rA   setup_loggingrY   )r   rL   env_dirvirtualenv_env_varsr	   )r   ra   rY   s      r!   sessionzVirtualEnv.sessiong   sR    #+4<(()G**,,C'6w\agj'k'k'kD$''r"   c                   | j                                         }| j        d         }d|vrd|d<   d|d<   t          | j        d                   |d<   t          | j        d                   |d	<   t          | j        d
                   |d<   d                    |          |d<   t          | j        d          r,t          j                            | j        j	                  |d<   |S )NrM   VIRTUALENV_NO_PERIODIC_UPDATETruer(   VIRTUALENV_CLEARr$   r'   r5   r8   r:   r<   
VIRTUALENV_PYTHONdiscoverVIRTUALENV_TRY_FIRST_WITH)
r+   copyr.   rL   joinhasattrrA   ospathseprj   )r   rY   rM   s      r!   rb   zVirtualEnv.virtualenv_env_varso   s    (--//!%=!9*#5539C/0")14TY?U5V1W1W-.#&ty'?#@#@ %(:)>%?%?!"#'99[#9#9 4<,, 	V/1zt|?T/U/UC+,
r"   r   c                    | j         j        S r   )rc   creatorrC   s    r!   rr   zVirtualEnv.creator}   s    |##r"   c                8    | j                                          d S r   )rc   runrC   s    r!   create_python_envzVirtualEnv.create_python_env   s    r"   rM   PythonInfo | Nonec                    	 | j         j        }n# t          t          f$ r Y d S w xY wt	          |j        |j        |j        |j        dk    |j	        dt          |j                                                  i          S )N@   rI   )implementationversion_infoversionis_64platformrN   )rr   interpreterFileNotFoundErrorRuntimeErrorr   ry   rz   r{   architecturer}   r   system_executableresolve)r   rM   r~   s      r!   _get_pythonzVirtualEnv._get_python   s    	,2KK!<0 	 	 	44	&5$1'+r1 )k&C!D!D!L!L!N!NO
 
 
 	
s    $$
list[Path]c                |    t          t                              | j        j        | j        j        f                    S )zPaths to add to the executable.)listdictfromkeysrr   bin_dir
script_dirrC   s    r!   prepend_env_var_pathzVirtualEnv.prepend_env_var_path   s-     DMM4<#79P"QRRSSSr"   r   c                @    t          t          | j        j                  S r   )r   r   rr   purelibrC   s    r!   env_site_package_dirzVirtualEnv.env_site_package_dir   s    D$,.///r"   c                @    t          t          | j        j                  S r   )r   r   rr   exerC   s    r!   
env_pythonzVirtualEnv.env_python   s    D$,*+++r"   c                @    t          t          | j        j                  S r   )r   r   rr   r   rC   s    r!   env_bin_dirzVirtualEnv.env_bin_dir   s    D$,1222r"   rL   c                    t           j        S r   )sysr}   rC   s    r!   runs_on_platformzVirtualEnv.runs_on_platform   s
    |r"   c                h    t                      j        }t          | j        d                   |d<   |S )Nra   VIRTUAL_ENV)r   r+   rL   r.   )r   r+   r    s     r!   r+   z VirtualEnv.environment_variables   s0     % =/249Y3G/H/Hm,$$r"   )r   r   r   r   )r   r   )r   r   )r   r   )r   rG   )r   rT   )r   rZ   )r   r   )r   r   )rM   rT   r   rv   )r   r   )r   r   )r   rL   )__name__
__module____qualname____doc__r   r=   propertyrD   rF   rJ   rS   rV   r^   rc   rb   rr   ru   r   r   r   r   r   r   r+   __classcell__)r    s   @r!   r   r      s3       FF& & & & & &
 
 
 
 
 
<    X
    X
          
          
 ( ( ( X(    $ $ $ X$   
 
 
 
T T T T
0 0 0 0, , , ,3 3 3 3    X % % % % % X% % % % %r"   r   )!r   
__future__r   ro   r   pathlibr   typingr   r   r   
virtualenvr   rO   r	   tox.config.loader.str_convertr
   tox.execute.local_sub_processr   tox.tox_env.python.apir   r   "tox.tox_env.python.pip.pip_installr   virtualenv.create.creatorr   virtualenv.run.sessionr   tox.execute.apir   tox.tox_env.apir   r    r"   r!   <module>r      s_   v v " " " " " " 				 



       + + + + + + + + + + 8 8 8 8 8 8 & & & & & & 4 4 4 4 4 4 A A A A A A 5 5 5 5 5 5 5 5 2 2 2 2 2 2 1111111......''''''000000O% O% O% O% O% O% O% O% O% O%r"   