a RÛf­Zã @sÈddlZddlZddlZddlZddlZddlZddlZdZe e ¡Z Gdd„dƒZ ddd„Z ddd „Z e d krÄd Zze ƒdZWn6ey¸Zzed eejd WYdZ[n dZ[00e e¡dS)éN)ÚpipZ setuptoolsc@sŽeZdZddd„Zdd„Zdd„Zd d „Zd d „Zej d krHd dd„Z n d!dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZdS)"Ú EnvBuilderFNcCsF||_||_||_||_||_|dkr6tj t ¡¡}||_ ||_ dS)NÚ.) Úsystem_site_packagesÚclearÚsymlinksÚupgradeÚwith_pipÚosÚpathÚbasenameÚgetcwdÚpromptÚ upgrade_deps)Úselfrrrrr rr©rú2/opt/alt/python39/lib64/python3.9/venv/__init__.pyÚ__init__.szEnvBuilder.__init__cCsˆtj |¡}| |¡}|j}d|_| |¡| |¡|jrF| |¡|j s`|  |¡|  |¡|rtd|_| |¡|j r„|  |¡dS)NFT)r r ÚabspathÚensure_directoriesrÚcreate_configurationÚ setup_pythonr Ú _setup_piprÚ setup_scriptsÚ post_setuprÚupgrade_dependencies)rÚenv_dirÚcontextZtrue_system_site_packagesrrrÚcreate;s         zEnvBuilder.createcCs\t |¡D]L}tj ||¡}tj |¡s4tj |¡r@t |¡q tj |¡r t  |¡q dS©N) r Úlistdirr ÚjoinÚislinkÚisfileÚremoveÚisdirÚshutilZrmtree)rr ÚfnrrrÚclear_directoryWs   zEnvBuilder.clear_directorycCsâdd„}tj |¡r$|jr$| |¡t ¡}||_tj |¡d|_ |j durT|j n|j }d||_ ||ƒt j }tj tj  |¡¡\}}||_||_||_t jdkrÀd}d} tj |dd ¡} n(d }d } tj |d d t jdd…d ¡} tj || ¡|_} || ƒ|| ƒt jdkrXtjdkrXt jdkrXtj |d¡} tj | ¡sXt d | ¡tj ||¡|_} ||_tj | |¡|_|| ƒ|j|_t jdkrÞtj |j¡}tj |¡tj |j¡krÞt d|j|¡||_|S)NcSs@tj |¡st |¡n$tj |¡s0tj |¡r.create_if_neededéz(%s) Zwin32ZScriptsZIncludeÚLibz site-packagesÚbinZincludeÚlibz python%d.%délÚposixÚdarwinZlib64z†Actual environment location may have moved due to redirects, links or junctions. Requested location: "%s" Actual location: "%s") r r r)rr(ÚtypesÚSimpleNamespacerÚsplitÚenv_namerÚsysÚ_base_executablerÚ executableÚ python_dirZ python_exeÚplatformr!Ú version_infoZinc_pathÚmaxsizeÚnameÚsymlinkÚbin_pathÚbin_nameÚenv_exeÚ env_exec_cmdÚrealpathÚnormcaseÚloggerÚwarning)rrr-rrr;ÚdirnameZexenameZbinnameZincpathZlibpathr Z link_pathÚbinpathZ real_env_exerrrr_s\    þÿ  üzEnvBuilder.ensure_directoriescCs¬tj |jd¡|_}t|dddt}| d|j¡|jrBd}nd}| d|¡| d t j dd …¡|j durŠ| d |j ›d ¡Wdƒn1sž0YdS) Nz pyvenv.cfgÚwúutf-8)Úencodingz home = %s ÚtrueZfalsez"include-system-site-packages = %s zversion = %d.%d.%d éz prompt = Ú ) r r r!rZcfg_pathÚopenÚwriter<rr9r>r)rrr ÚfZinclrrrr¡s  zEnvBuilder.create_configurationÚntcCs||j }|shz6tj |¡s@|r4t tj |¡|¡n t ||¡Wn$tyft d||¡d}Yn0|rxt   ||¡dS)NúUnable to symlink %r to %rT) rr r r"rAr Ú ExceptionrHrIr&Úcopyfile)rÚsrcÚdstÚrelative_symlinks_okZ force_copyrrrÚsymlink_or_copy·s   zEnvBuilder.symlink_or_copycCsZtj |¡otj |¡ }|jr~|s~tj |¡s~z,|rLt tj |¡|¡n t ||¡WdSty|t   d||¡Yn0tj  tj |¡¡\}}tj  tj  t¡dd||¡}t d¡sÌtj |¡s"| d¡rêd|}|dd…}|dkrød}n|d krd }tj  tj  |¡||¡}n|}tj |¡sJ|sFt   d |¡dSt ||¡dS) NrVÚscriptsrUTZ_déþÿÿÿÚpythonZ venvlauncherZpythonwZ venvwlauncherzUnable to copy %r)r r Úlexistsr)rr"rAr rWrHrIÚsplitextr!rJÚ__file__Ú sysconfigÚis_python_buildr#Úendswithr&rX)rrYrZr[Zbad_srcr ZextZsrcfnrrrr\Ês<  ý    cCsÐ|j}|j}|j}|j}tjdkr¨||j|ƒtj |¡sFt  |d¡dddt j d›fD]F}tj  ||¡}tj  |¡s\||j|ddtj |¡s\t  |d¡q\n$|jrÜd d „t |¡Dƒ}t d¡rüd d „|Dƒ}n hd £}tj |j¡}| |¡|D]6}tj  ||¡} tj | ¡r|| tj  ||¡ƒqt d¡rÌt |j¡D]z\} } } d | vrPtj | ¡} tj  |jd| ¡} tj  | ¡sšt | ¡tj  | d ¡} tj  | d ¡}t | |¡qÌqPdS)NrUiír_Zpython3zpython3.r.T)r[cSs,g|]$}tj tj |¡d¡dvr|‘qS)r.)ú.exez.dll)r r rGra©Ú.0rTrrrÚ sÿz+EnvBuilder.setup_python..cSs"g|]}tj |¡ d¡r|‘qS))r_Z vcruntime)r r rGÚ startswithrgrrrrisÿ>z pythonw.exez python_d.exez python.exez pythonw_d.exezinit.tclr/)rBrDr\r<r r@r;r r"Úchmodr9r>r!r)rr rcrdr Úaddr`Úwalkrr*r&rX)rrrKr ZcopierrJÚsuffixÚsuffixesZbase_exerYÚrootÚdirsÚfilesZtcldirrZrrrrõsP      ÿ ÿ      zEnvBuilder.setup_pythoncCs$|jddddg}tj|tjddS)Nz-ImZ ensurepipú --upgradez --default-pip)Ústderr)rEÚ subprocessZ check_outputZSTDOUT©rrÚcmdrrrr2s ÿzEnvBuilder._setup_pipcCs2tj tj t¡¡}tj |d¡}| ||¡dS)Nr])r r rrJrbr!Úinstall_scripts)rrr rrrr;s zEnvBuilder.setup_scriptscCsdSrr)rrrrrrJszEnvBuilder.post_setupcCsJ| d|j¡}| d|j¡}| d|j¡}| d|j¡}| d|j¡}|S)NZ __VENV_DIR__Z __VENV_NAME__Z__VENV_PROMPT__Z__VENV_BIN_NAME__Z__VENV_PYTHON__)Úreplacerr8rrCrD)rÚtextrrrrÚreplace_variablesTs zEnvBuilder.replace_variablesc CsÞ|j}t|ƒ}t |¡D]¾\}}}||krX|dd…D]}|dtjfvr8| |¡q8q|D]x} tjdkr‚|  d¡r‚|  d¡r‚q\tj  || ¡} ||d…  tj ¡dd…} | s¶|} ntjj |g| ¢RŽ} tj  | ¡sàt  | ¡tj  | | ¡} t| dƒ} |  ¡}Wdƒn1s0Y|  d¡sŒz$| d¡}| ||¡}| d¡}Wn8tyŠ}zd}t d| |¡WYd}~n d}~00|dur\t| d ƒ} |  |¡Wdƒn1sÀ0Yt | | ¡q\qdS) NÚcommonrUr_)rfz.pdbr2ÚrbrMz+unable to copy script %r, may be binary: %sÚwb)rBÚlenr rmr@r$rjrer r!r7Úsepr)r*rRÚreadÚdecoder{ÚencodeÚ UnicodeErrorrHrIrSr&Zcopymode)rrr rKZplenrprqrrr,rTZsrcfilernZdstdirZdstfileÚdataÚerrrrxfsJ   ÿ   (   ÿ *zEnvBuilder.install_scriptscCs@t dt›d|j›¡|jddddg}| t¡t |¡dS)Nz Upgrading z packages in z-mrZinstallrs)rHÚdebugÚCORE_VENV_DEPSrBrEÚextendruZ check_callrvrrrr˜s ÿ zEnvBuilder.upgrade_dependencies)FFFFFNF)F)F)Ú__name__Ú __module__Ú __qualname__rrr(rrr r@r\rrrrr{rxrrrrrrs$þ B   +=  2rFcCs"t||||||d}| |¡dS)N)rrrr rr)rr)rrrrr rrÚbuilderrrrr¡s þrc Cs‚d}tjdkrd}nttdƒs"d}|s2tdƒ‚nLddl}|jtddd }|jd d d d d|jddddddtj dkr€d}nd}|  ¡}|jd|dddd|jd| dddd|jdddddd|jddddd d|jd!d"ddd#d$|jd%d&d'|jd(ddd)d*  d+  t ¡¡d| |¡}|jrB|jrBtd,ƒ‚t|j|j|j|j|j|j|jd-}|jD]}| |¡qldS).NT)rPrPFÚ base_prefixz.This script is only for use with Python >= 3.3rzFCreates virtual Python environments in one or more target directories.z|Once an environment has been created, you may wish to activate it, e.g. by sourcing an activate script in its bin directory.)ÚprogZ descriptionZepilogrqZENV_DIRú+z)A directory to create the environment in.)ÚmetavarÚnargsÚhelpz--system-site-packagesÚ store_trueÚ system_sitezDGive the virtual environment access to the system site-packages dir.)ÚdefaultÚactionÚdestr“rUz --symlinksrz[Try to use symlinks rather than copies, when symlinks are not the default for the platform.z--copiesZ store_falsez\Try to use copies rather than symlinks, even when symlinks are the default for the platform.z--clearrzcDelete the contents of the environment directory if it already exists, before environment creation.rsrzlUpgrade the environment directory to use this version of Python, assuming Python has been upgraded in-place.z --without-pipr z]Skips installing or upgrading pip in the virtual environment (pip is bootstrapped by default))r˜r–r—r“z--promptz;Provides an alternative prompt prefix for this environment.)r“z--upgrade-depsrz;Upgrade core dependencies: {} to the latest version in PyPIú z1you cannot supply --upgrade and --clear together.)rrrrr rr)r9r>Úhasattrr+ÚargparseÚArgumentParserrŠÚ add_argumentr r@Zadd_mutually_exclusive_groupÚformatr!rˆÚ parse_argsrrrr•rr rrrqr) ÚargsZ compatibler›ÚparserZ use_symlinksÚgroupZoptionsrr,rrrÚmain©s~   û ÿþ þ þ ÿ ÿþÿ þþ ú r£Ú__main__r.z Error: %s)Úfile)FFFFNF)N)Zloggingr r&rur9rcr5rˆZ getLoggerrŠrHrrr£ZrcrWr†ÚprintrtÚexitrrrrÚs0 ÿ  N(