
    .Ph                        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ZddZddZddZd Zd Z d Z!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                    |t           j        n|}t          | |||          }|5  |                                 ddd           n# 1 swxY 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_sessions        W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/virtualenv/run/__init__.pycli_runr      s     "**C wsCCJ	                s   AA
A
c                   |t           j        n|}t          | ||          \  }}|                    |           |j        j        _        t          f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  B   K   | ]}|                               V  d S N)create).0er   s     r   	<genexpr>z"session_via_cli.<locals>.<genexpr>4   s/      'L'La(9(9'L'L'L'L'L'L    )r   r   build_parser
parse_args_interpreterversion_info
py_versiontupler	   	verbosityapp_data)	r   r   r   r   parserelementscreatorseeder
activatorss	    `       r   r   r   %   s     "**C#D'=#FFFH%%G,9G"''L'L'L'L8'L'L'L"L"LGVZ  r$   c                L   t          ||t          j        n|          }t          |           |                    ddddd           t          || |           t          | ||          }t          |           t          ||           }|j	        x|_
        }|d| }t          |          t          ||          t          ||          t          ||          g}|                    |           \  }}	|D ]}
|
                    |           |                                 ||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.   _elements              r   r%   r%   ?   sR   #G3;RZZCPPFV
M     VT=111D&'22G'"""FD))H(0(<<F+:::3V,,{F++;//H
 ((..JGQ 3 3))'2222
8r$   c                ,    t          |           d         S )z0Used to provide a parser for the doc generation.r   )r%   )r   s    r   build_parser_onlyrH   ^   s    a  r$   c                f    | j         r)t          | j        | j                  }t	          |          d S r   )upgrade_embed_wheelsr
   r,   r   
SystemExit)r   results     r   r=   r=   c   s9    # ! 0'+>>   ! !r$   c           
        |                     ddd           |                    | |          \  }}|                     ddt          t          |j        |j                  t          d |j        |j                  	           |                     d
dd           |                     ddd           |                    | |          \  }}|j        r|j                                         |S )Nz--read-only-app-datar4   zMuse app data folder in read-only mode (write operations will fail with error))r6   r8   )	namespacez
--app-dataz-a data folder used as cache by the virtualenv)	read_onlyr   )r8   typer7   z--reset-app-dataz start with empty app data folderz--upgrade-embed-wheelsz.trigger a manual update of the embedded wheels)	r:   r@   r   r   read_only_app_datar   reset_app_datar,   reset)r   r-   r   rE   s       r   r<   r<   i   s,   
\    
 (((AAJGQ <]g.HgkZZZdg.HgkZZZ	     /    
  =    
 (((AAJGQ !   Nr$   c                `    dd l }|                     dddt           d|j         d           d S )Nr   z	--versionversionz	%(prog)s z from zIdisplay the version of the virtualenv package and its location, then exit)r6   rU   r8   )
virtualenvr:   r   __file__)r-   rV   s     r   r9   r9      sT    
DKDDz/BDDX	      r$   c           	        d                     d t          t          j                              D                       }d}|                     d|                    t          j        t          d                   |                    }|                                }|	                    ddd	d
dd           |	                    ddd	ddd           | 
                    |          \  }}|rt          |j                   d S d S )Nz, c              3  N   K   | ] \  }}t          j        |           d | V  !dS )=N)logginggetLevelName)r!   clines      r   r#   z#_do_report_setup.<locals>.<genexpr>   s?      dd'!TW1$77==!==ddddddr$   z6verbosity = verbose - quiet, default {}, mapping => {}r+      )titledescriptionz-vz	--verbosecountverbosezincrease verbosity   )r6   r5   r8   r7   z-qz--quietquietzdecrease verbosityr   )joinsortedr   itemsadd_argument_groupformatr[   r\   add_mutually_exclusive_groupr:   r@   r   r+   )	r-   r   r   	level_maprD   verbosity_groupr+   optionrE   s	            r   r;   r;      s   		ddVTZT`TbTbMcMcdddddI
BC//JJw3F1I>>	JJ 0  O  <<>>I4W9Sgqrsss47Ocmnooo''--IFA 'V%&&&&&' 'r$   r   r   )NTN)NNTNr   )$
__future__r   r[   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%   rH   r=   r<   r9   r;   __all__ r$   r   <module>r}      s   " " " " " "  				       - - - - - - ? ? ? ? ? ? 2 2 2 2 2 2 2 2 * * * * * * A A A A A A * * * * * * 1 1 1 1 1 1 , , , , , , * * * * * * * * * * * *   "   4   >! ! ! !
! ! !  >  ' ' '  r$   