B a"@s*ddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl mZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZmZdd lm Z ddl!m"Z"ddl#m$Z$eej%&e'j(Z)e)dZ*Gddde+Z,ee Gddde+Z-ddZ.dS))absolute_importprint_functionunicode_literalsN)ABCMetaabstractmethod)ArgumentTypeError) literal_eval) OrderedDict)dedent) add_metaclass)LogCmd) WIN_CPYTHON_2)Path safe_delete) ensure_str ensure_text)run_cmd) __version__)PyEnvCfgzdebug.pyc@seZdZddZdS) CreatorMetacCs d|_dS)N)error)selfrJ/opt/alt/python37/lib/python3.7/site-packages/virtualenv/create/creator.py__init__szCreatorMeta.__init__N)__name__ __module__ __qualname__rrrrrrsrc@seZdZdZddZddZddZdd Zed d Z ed d Z e ddZ eddZ ddZddZddZeddZddZdS)CreatorzEA class that given a python Interpreter creates a virtual environmentcCsJ||_d|_t|j|_|j|_|j|_t|j|_|j |_ |j |_ dS)zConstruct a new virtual environment creator. :param options: the CLI option as parsed from :meth:`add_parser_arguments` :param interpreter: the interpreter to create virtual environment from N) interpreter_debugrdestclear no_vcs_ignorerZ from_folder pyenv_cfgapp_dataenv)roptionsr rrrr%s zCreator.__init__cCs t|S)N)r __unicode__)rrrr__repr__4szCreator.__repr__cCs$d|jjddd|DS)Nz{}({})z, css|]\}}d||VqdS)z{}={}N)format).0kvrrr 8sz&Creator.__unicode__..)r+ __class__rjoin_args)rrrrr)7szCreator.__unicode__cCs$dtt|jfd|jfd|jfgS)Nr"r#r$)rstrr"r#r$)rrrrr2:sz Creator._argscCsdS)aDetermine if we can create a virtual environment. :param interpreter: the interpreter in question :return: ``None`` if we can't create, any other object otherwise that will be forwarded to :meth:`add_parser_arguments` Tr)clsr rrr can_createAszCreator.can_createcCs>|jdd|jd|jdddddd |jd d dd dd d S)aAdd CLI arguments for the creator. :param parser: the CLI parser :param app_data: the application data folder :param interpreter: the interpreter we're asked to create virtual environment for :param meta: value as returned by :meth:`can_create` r"z!directory to create virtualenv at)helptypez--clearr# store_truezZremove the destination directory if exist before starting (will overwrite files otherwise)F)r"actionr6defaultz--no-vcs-ignorer$z>don't create VCS ignore directive in the destination directoryN) add_argument validate_dest)r4parserr metar&rrradd_parser_argumentsKs  zCreator.add_parser_argumentscCstdS)z)Perform the virtual environment creation.N)NotImplementedError)rrrrcreatehszCreator.createc Csdd}t}t}|dkr&ddini}xXt|D]L}y*|j|f||}||krXw4t|Wq4tk r~d||<Yq4Xq4W|rtd|d | |t j |krtd |t j t |}|r|rtd |d tjkrd krnnt t j|} nt t jt|} | }xb| r| rht tt| t jr^Pn || || j| j} } | | kr|| || } q2Wt|S) zANo path separator in the path, valid chars and must be write-ablecSs2ttj|j|jg}td|||dS)Nz*the destination {} is not write-able at {})rospath commonprefixpartsrr+ relative_to)r"valuecommonrrrnon_write_ableqsz-Creator.validate_dest..non_write_ablembcserrorsignoreNzDthe file system codec ({}) cannot handle characters {!r} within {!r}zddestination {!r} must not contain the path separator ({}) as this would break the activation scriptsz/the destination {} already exists and is a file)rN)rN)sysgetfilesystemencodingr rencodedecode ValueErrorrr+r1keysrBpathseprexistsis_file version_inforCrealpathabspathr3resolveaccessW_OKparentname) r4Z raw_valuerIencodingZrefusedkwargscharZtriprGr"base_rrrr<msN         zCreator.validate_destcCsJ|jr(|jr(td|jt|j|||jsF| dS)Nz delete %s) r"rWr#loggingdebugrrA set_pyenv_cfgr$setup_ignore_vcs)rrrrruns z Creator.runcCsRt|j_|jj|jd<|jj|jd<ddd|jjD|jd<t|jd<dS)Nhomeimplementation.css|]}t|VqdS)N)r3)r,irrrr/sz(Creator.set_pyenv_cfg..rYZ virtualenv) r r%contentr Zsystem_exec_prefixrlr1rYr)rrrrrhs  zCreator.set_pyenv_cfgcCs(|jd}|s$|tddS)z9Generate ignore instructions for version control systems.z .gitignoreze # created by virtualenv automatically * N)r"rWZ write_textr lstrip)rZ git_ignorerrrris  zCreator.setup_ignore_vcscCs4|jdkr.|jdk r.t|j||j|j|_|jS)zt :return: debug information about the virtual environment (only valid after :meth:`create` has run) N)r!Zexeget_env_debug_info debug_scriptr&r')rrrrrgsz Creator.debugcCstS)N) DEBUG_SCRIPT)rrrrrrszCreator.debug_scriptN)rrr__doc__rr*r)r2 classmethodr5r?rrAr<rjrhripropertyrgrrrrrrr!s   :  rc Cs|}|tdd||J}t|t|g}trFdd|D}ttdt|t|\}}}WdQRXy,|dkrt |}n t |}|r||d<Wn0t k r} z|||t | dSd} ~ XYnXd|krd |dkr|dd d=|S) N PYTHONPATHcSsg|] }t|qSr)r)r,rnrrr sz&get_env_debug_info..z debug via %rrerr)outry returncode exceptionrPrC)copypopr3Zensure_extractedr rfrgr rrjsonloads Exceptionrepr) Zenv_exerrr&r'cmdcoderzryresultr|rrrrqs&     rq)/ __future__rrrrrfrBrPabcrrargparserastr collectionsr textwrapr Zsixr Z#virtualenv.discovery.cached_py_infor Zvirtualenv.infor Zvirtualenv.util.pathrrZvirtualenv.util.sixrrZvirtualenv.util.subprocessrZvirtualenv.versionrr%rrCr[__file__r_ZHERErsobjectrrrqrrrrs0          7