
    yIfd                        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        K/var/www/piapp/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          | ||          \  }}|                    |           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>3   s/      'L'La(9(9'L'L'L'L'L'L    )	r   r   build_parser
parse_argstupler	   	verbosityapp_data_interpreter)	r   r   r   r   parserelementscreatorseeder
activatorss	    `       r   r   r   %   s     "**C#D'=#FFFH%%G"''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_onlyrF   ]   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;   b   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-datar2   zMuse app data folder in read-only mode (write operations will fail with error))r4   r6   )	namespacez
--app-dataz-a data folder used as cache by the virtualenv)	read_onlyr   )r6   typer5   z--reset-app-dataz start with empty app data folderz--upgrade-embed-wheelsz.trigger a manual update of the embedded wheels)	r8   r>   r   r   read_only_app_datar   reset_app_datar)   reset)r   r+   r   rC   s       r   r:   r:   h   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)r4   rS   r6   )
virtualenvr8   r   __file__)r+   rT   s     r   r7   r7      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   )r4   r3   r6   r5   z-qz--quietquietzdecrease verbosityr   )joinsortedr   itemsadd_argument_groupformatrY   rZ   add_mutually_exclusive_groupr8   r>   r   r(   )	r+   r   r   	level_maprB   verbosity_groupr(   optionrC   s	            r   r9   r9      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   rY   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%   rF   r;   r:   r7   r9   __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 , , , , , , * * * * * * * * * * * *   "   2   >! ! ! !
! ! !  >  ' ' '  r$   