o
    Ch                     @  s   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 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dZd ddZd!ddZd"ddZdd Zdd Z dd Z!dd Z"ddgZ#dS )#    )annotationsN)partial)make_app_data)VirtualEnvConfigParser)LEVELSsetup_report)Session)manual_upgrade)__version__   )ActivationSelector)CreatorSelector)get_discover)SeederSelectorTc                 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
    :return: 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)argsoptionssetup_loggingenv
of_session r   i/var/www/html/myvaluetrips/my_value_trip_new/venv/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 )aq  
    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
    :return: 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>4   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   %   s   

r   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   r*   discoverr:   msgr+   _elementr   r   r   r"   ?   s4   

r"   c                 C  s   t | d S )z0Used to provide a parser for the doc generation.r   )r"   )r   r   r   r   build_parser_only^   s   rC   c                 C  s    | j rt| j| j}t|d S r   )upgrade_embed_wheelsr	   r)   r   
SystemExit)r   resultr   r   r   r9   c   s   r9   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-datar0   zMuse app data folder in read-only mode (write operations will fail with error))r2   r4   )	namespacez
--app-dataz-a data folder used as cache by the virtualenv)	read_onlyr   )r4   typer3   z--reset-app-dataz start with empty app data folderz--upgrade-embed-wheelsz.trigger a manual update of the embedded wheels)	r6   r<   r   r   read_only_app_datar   reset_app_datar)   reset)r   r*   r   rA   r   r   r   r8   i   s4   
r8   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)r2   rM   r4   )
virtualenvr6   r
   __file__)r*   rN   r   r   r   r5      s   
r5   c           	      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 | 
|\}}|rJt|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 => {}r(      )titledescriptionz-vz	--verbosecountverbosezincrease verbosity   )r2   r1   r4   r3   z-qz--quietquietzdecrease verbosityr   )joinsortedr   itemsadd_argument_groupformatrQ   rR   add_mutually_exclusive_groupr6   r<   r   r(   )	r*   r   r   	level_mapr@   verbosity_groupr(   optionrA   r   r   r   r7      s   r7   )NTN)NNTNr   )$
__future__r   rQ   r   	functoolsr   virtualenv.app_datar   virtualenv.config.cli.parserr   virtualenv.reportr   r   virtualenv.run.sessionr   &virtualenv.seed.wheels.periodic_updater	   virtualenv.versionr
   plugin.activatorsr   plugin.creatorsr   plugin.discoveryr   plugin.seedersr   r   r   r"   rC   r9   r8   r5   r7   __all__r   r   r   r   <module>   s2    



