o $"b@sddlmZmZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZdd lmZd d lmZd d lmZd dlmZd dlmZd"ddZd"ddZd#ddZd$ddZddZ ddZ!ddZ"dd Z#d!Z$dS)%)absolute_importunicode_literalsN)partial) make_app_data)VirtualEnvConfigParser)LEVELS setup_report)Session)manual_upgrade) __version__)ActivationSelector)CreatorSelector) get_discover)SeederSelectorTcCsR|durtjn|}t||||}| |Wd|S1s"wY|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)osenvironsession_via_clirun)argsoptions setup_loggingenv of_sessionr9/usr/lib/python3/dist-packages/virtualenv/run/__init__.pycli_runs   rc sf|durtjn|}t|||\}}||tfdd|D\}}}tjj|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) Nc3s|]}|VqdSN)create).0errr 2sz"session_via_cli..) rr build_parser parse_argstupler verbosityapp_data _interpreter) rrrrparserelementscreatorseeder activatorsrrr"rr$s   rc Cst||dur tjn|}t||jddddddt|||t|||}t|t||}|j |_ }|dur@t d |t ||t||t||g}||\}}|D]} | |qW|||fS)Nz--with-tracebackwith_traceback store_trueFz>on failure also display the stacktrace internals of virtualenv)destactiondefaulthelpz!failed to find interpreter for {})rrradd_version_flag add_argument_do_report_setup load_app_datahandle_extra_commandsr interpreterr) RuntimeErrorformatrrrparse_known_argshandle_selected_arg_parse enable_help) rrrrr*discoverr:r+_elementrrrr$7s2     r$cCs t|dS)z/Used to provide a parser for the doc generationr)r$)rrrrbuild_parser_onlyUs rCcCs |jrt|j|j}t|dSr)upgrade_embed_wheelsr r(r SystemExit)rresultrrrr9Zsr9c Cs|jdddd|j||d\}}|jddtt|j|jdtd|j|jdd |jd dd d|jd dd d|j||d\}}|jrI|j|S)Nz--read-only-app-datar0zMuse app data folder in read-only mode (write operations will fail with error))r2r4) namespacez --app-dataz-a data folder used as cache by the virtualenv) read_onlyr)r4typer3z--reset-app-dataz start with empty app data folderz--upgrade-embed-wheelsz.trigger a manual update of the embedded wheels) r6r=rrread_only_app_datarreset_app_datar(reset)rr*rrArrrr8`s4 r8cCs(ddl}|jdddt|jdddS)Nrz --versionversionz%(prog)s {} from {}zIdisplay the version of the virtualenv package and its location, then exit)r2rMr4) virtualenvr6r<r __file__)r*rNrrrr5s  r5c CsdddtttD}d}|jd|ttd|d}| }|j dd d d d d d|j ddd dddd| |\}}|rLt |j dSdS)Nz, css&|]\}}dt||VqdS)z{}={}N)r<logging getLevelName)r clrrrr#s$z#_do_report_setup..z6verbosity = verbose - quiet, default {}, mapping => {}r')title descriptionz-vz --verbosecountverbosezincrease verbosityr)r2r1r4r3z-qz--quietquietzdecrease verbosityr)joinsortedlistritemsadd_argument_groupr<rPrQadd_mutually_exclusive_groupr6r=r r') r*rr level_mapmsgverbosity_groupr'optionrArrrr7s r7)rr)NTN)NNTNr)% __future__rrrPr functoolsrr(rconfig.cli.parserrreportrr run.sessionr seed.wheels.periodic_updater rMr plugin.activatorsrplugin.creatorsrplugin.discoveryrplugin.seedersrrrr$rCr9r8r5r7__all__rrrrs.