o
    Wi'                     @  sH  d dl mZ d dl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m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 erhd dlmZ ddl m!Z! 			d3d4ddZ"			d3d4dd Z#				d5d6d#d$Z$d7d8d&d'Z%d9d*d+Z&d:d-d.Z'd;d/d0Z(d<d1d2Z)dd gZ*dS )=    )annotationsN)partial)TYPE_CHECKING)make_app_data)VirtualEnvConfigParserVirtualEnvOptions)LEVELSsetup_report)Session)manual_upgrade)__version__   )ActivationSelector)CreatorSelector)get_discover)SeederSelector)MutableMapping)ComponentBuilderTargs	list[str]optionsVirtualEnvOptions | Nonesetup_loggingboolenvMutableMapping[str, str] | Nonereturnr
   c                 C  sR   |du rt jn|}t| |||}| |  W d   |S 1 s"w   Y  |S )a  Create a virtual environment given some command line interface arguments.

    :param args: the command line arguments
    :param options: passing in a ``VirtualEnvOptions`` object allows return of the parsed options
    :param setup_logging: ``True`` if setup logging handlers, ``False`` to use handlers already registered
    :param env: environment variables to use

    :returns: the session object of the creation (its structure for now is experimental and might change on short
        notice)

    N)osenvironsession_via_clirun)r   r   r   r   
of_session r"   K/home/ubuntu/.local/lib/python3.10/site-packages/virtualenv/run/__init__.pycli_run   s   

r$   c           	        sl   |du rt jn|}t|  ||\}}||  |jj _t fdd|D \}}}t j	 j
|j|||S )as  Create a virtualenv session (same as cli_run, but this does not perform the creation). Use this if you just want to query what the virtual environment would look like, but not actually create it.

    :param args: the command line arguments
    :param options: passing in a ``VirtualEnvOptions`` object allows return of the parsed options
    :param setup_logging: ``True`` if setup logging handlers, ``False`` to use handlers already registered
    :param env: environment variables to use

    :returns: the session object of the creation (its structure for now is experimental and might change on short
        notice)

    Nc                 3  s    | ]}|  V  qd S N)create).0er   r"   r#   	<genexpr>G   s
    
z"session_via_cli.<locals>.<genexpr>)r   r   build_parser
parse_args_interpreterversion_info
py_versiontupler
   	verbosityapp_data)	r   r   r   r   parserelementscreatorseeder
activatorsr"   r)   r#   r   2   s   

r   list[str] | None5tuple[VirtualEnvConfigParser, list[ComponentBuilder]]c                 C  s   t ||d u r	tjn|}t| |jdddddd t|| | t| ||}t| t|| }|j	 |_
}|d u rBd| }t|t||t||t||g}|| \}}	|D ]}
|
| qY|  ||fS )Nz--with-tracebackwith_traceback
store_trueFz>on failure also display the stacktrace internals of virtualenv)destactiondefaulthelpzfailed to find interpreter for )r   r   r   add_version_flagadd_argument_do_report_setupload_app_datahandle_extra_commandsr   interpreterr-   RuntimeErrorr   r   r   parse_known_argshandle_selected_arg_parseenable_help)r   r   r   r   r3   discoverrE   msgr4   _elementr"   r"   r#   r+   U   s4   

r+   r   c                 C  s   t | d S )z0Used to provide a parser for the doc generation.r   )r+   r   r"   r"   r#   build_parser_onlyy   s   rO   r   Nonec                 C  s    | j rt| j| j}t|d S r%   )upgrade_embed_wheelsr   r2   r   
SystemExit)r   resultr"   r"   r#   rD   ~   s   rD   r3   c              	   C  s   |j dddd |j| |d\}}|j ddtt|j|jdtd |j|jdd	 |j d
ddd |j dddd |j| |d\}}|jrI|j  |S )Nz--read-only-app-datar;   zMuse app data folder in read-only mode (write operations will fail with error))r=   r?   )	namespacez
--app-dataz-a data folder used as cache by the virtualenv)	read_onlyr   )r?   typer>   z--reset-app-dataz start with empty app data folderz--upgrade-embed-wheelsz.trigger a manual update of the embedded wheels)	rA   rG   r   r   read_only_app_datar   reset_app_datar2   reset)r   r3   r   rL   r"   r"   r#   rC      s4   
rC   c                 C  s,   dd l }| jdddt d|j dd d S )Nr   z	--versionversionz	%(prog)s z from zIdisplay the version of the virtualenv package and its location, then exit)r=   rZ   r?   )
virtualenvrA   r   __file__)r3   r[   r"   r"   r#   r@      s   
r@   c           	        s   d dd tt D }d}| jd|ttd |d}| }|j	dd	d
dddd |j	ddd
dddd  rIt
 fdddD rId S |  \}}|rYt|j d S d S )Nz, c                 s  s(    | ]\}}t | d | V  qdS )=N)logginggetLevelName)r'   cliner"   r"   r#   r*      s   & z#_do_report_setup.<locals>.<genexpr>z6verbosity = verbose - quiet, default {}, mapping => {}r1      )titledescriptionz-vz	--verbosecountverbosezincrease verbosity   )r=   r<   r?   r>   z-qz--quietquietzdecrease verbosityr   c                 3  s    | ]}| v V  qd S r%   r"   )r'   irN   r"   r#   r*      s    )z-hz--help)joinsortedr   itemsadd_argument_groupformatr^   r_   add_mutually_exclusive_grouprA   anyrG   r	   r1   )	r3   r   r   	level_maprK   verbosity_groupr1   optionrL   r"   rN   r#   rB      s   rB   )NTN)
r   r   r   r   r   r   r   r   r   r
   )NNTN)
r   r8   r   r   r   r   r   r   r   r9   r%   )r   r8   r   r   )r   r   r   rP   )r   r8   r3   r   r   r   r   r   )r3   r   r   rP   )r3   r   r   r8   r   r   r   rP   )+
__future__r   r^   r   	functoolsr   typingr   virtualenv.app_datar   virtualenv.config.cli.parserr   r   virtualenv.reportr   r	   virtualenv.run.sessionr
   &virtualenv.seed.wheels.periodic_updater   virtualenv.versionr   plugin.activatorsr   plugin.creatorsr   plugin.discoveryr   plugin.seedersr   collections.abcr   plugin.baser   r$   r   r+   rO   rD   rC   r@   rB   __all__r"   r"   r"   r#   <module>   sN    $$


!
