
    3i:                        d dl mZ d dl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mZ d
dlmZ d
dlmZ d
dlmZ erd dlmZ d dlmZ  ej8                  e      Z G d de      ZdgZ y)    )annotationsN)copy)TYPE_CHECKING)
PythonInfo)handle_store_python)ProcessCallFailedError)
ensure_dir)run_cmd   )ViaGlobalRefApiViaGlobalRefMeta)is_mac_os_framework)CPython3macOsBrew)Pypy3Windows)Any)VirtualEnvOptionsc                  ~     e Zd Zd fdZd fdZedd       Zd fdZddZddZ	ddZ
ddZd fd	Zdd
Z xZS )Venvc                    |j                   | _         t        | 	  ||       t        j                         }||u xr |j
                  |j                  k(  | _        d | _        y N)	describesuper__init__r   current
executablesystem_executablecan_be_inline_context)selfoptionsinterpreterr   	__class__s       X/var/www/opsc/venv/lib/python3.12/site-packages/virtualenv/create/via_global_ref/venv.pyr   zVenv.__init__   sX    ((+.$$&(G3o8N8NR]RoRo8o    c                    t         |          | j                  r%d| j                  j                  j                  fgz   S g z   S )Nr   )r   _argsr   r"   __name__)r   r"   s    r#   r&   z
Venv._args#   s>    w}VZVcVcJ0G0G0P0P#Q"Rllikllr$   c                    |j                   rct        j                  |      rt        j                  |      S t	               }|j
                  dk(  rt        ||      }t        |      rd|_        |S y )Nwin32zEmacOS framework builds do not support copy-based virtual environments)	has_venvr   can_describe
setup_metar   platformr   r   
copy_error)clsr!   metas      r#   
can_createzVenv.can_create&   sc     --k:(33K@@#%D##w.*4=";/"iKr$   c                "   | j                   r| j                          n| j                          | j                  D ]  }t	        |        | j
                  | j
                  j                  |        t        | !          | j                          y r   )
r   create_inlinecreate_via_sub_processlibsr	   r   install_venv_shared_libsr   create!executables_for_win_pypy_less_v37)r   libr"   s     r#   r7   zVenv.create3   sp     '')99 	CsO	==$MM2248..0r$   c                    | j                   }t        |t              rJ|j                  r=|j	                  | j
                        D ]  }|j                  || j                           yyy)zPyPy <= 3.6 (v7.3.3) for Windows contains only pypy3.exe and pypy3w.exe Venv does not handle non-existing exe sources, e.g. python.exe, so this patch does it.N)r   
isinstancer   less_v37executablesr!   runsymlinks)r   creatorexes      r#   r8   z&Venv.executables_for_win_pypy_less_v37?   sX    --g|,1A1A**4+;+;< 0/0 2B,r$   c                    ddl m}  || j                  d| j                  d      }|j	                  t        | j                               y )Nr   )
EnvBuilderF)system_site_packagesclearr?   with_pip)venvrC   enable_system_site_packager?   r7   strdest)r   rC   builders      r#   r3   zVenv.create_inlineF   s;    #!%!@!@]]	
 	s499~&r$   c                    | j                         }t        j                  ddj                  |             t	        |      \  }}}|dk7  rt        ||||      y )Nz)using host built-in venv to create via %s r   )get_host_create_cmdLOGGERinfojoinr
   r   )r   cmdcodeouterrs        r#   r4   zVenv.create_via_sub_processQ   sS    &&(?#O c319(sC== r$   c                0   | j                   j                  dddg}| j                   j                  dk\  r|j                  d       | j                  r|j                  d       |j                  | j                  rdndt        | j                        f       |S )	Nz-mrG   z--without-pip)      z--without-scm-ignore-filesz--system-site-packagesz
--symlinksz--copies)	r!   r   version_infoappendrH   extendr?   rI   rJ   )r   rR   s     r#   rN   zVenv.get_host_create_cmdX   sy    114Q((G3JJ34**JJ/0

DMMLz3tyy>RS
r$   c                    t        | j                  j                               }t        |           | j                  j                  |       y r   )r   	pyenv_cfgrefreshr   set_pyenv_cfgupdate)r   venv_contentr"   s     r#   r_   zVenv.set_pyenv_cfga   s7    DNN2245l+r$   c                    t         j                  | d      }|*t        ||      rt        ||      }t	        |      r|dk(  r|S t         j                  | |      S )Nr   script)object__getattribute__hasattrgetattrcallable)r   itemr   elements       r#   re   zVenv.__getattribute__g   sV    **4<GHd$;h-GG$(8&&tT22r$   )r    r   r!   r   returnNone)rk   zlist[tuple[str, Any]])r!   r   rk   zViaGlobalRefMeta | None)rk   rl   )rk   z	list[str])ri   rI   rk   rd   )r'   
__module____qualname__r   r&   classmethodr1   r7   r8   r3   r4   rN   r_   re   __classcell__)r"   s   @r#   r   r      sE    m 
 

10	'>,3r$   r   )!
__future__r   loggingr   typingr   python_discoveryr   &virtualenv.create.via_global_ref.storer   virtualenv.util.errorr   virtualenv.util.pathr	   virtualenv.util.subprocessr
   apir   r   builtin.cpython.commonr   builtin.cpython.mac_osr   builtin.pypy.pypy3r   r   virtualenv.config.cli.parserr   	getLoggerr'   rO   r   __all__ r$   r#   <module>r      sb    "     ' F 8 + . 2 7 5 ,>			8	$R3? R3l r$   