ž §ÿfsAc@s dZddlZddlZddlZddlZddlZddlZejeƒZ Gdd„dƒZ e e e dd„Z e dd„Zed krd ZyeƒdZWn<ek rõZzed ed ejƒWYddZ[XnXejeƒndS( u5 Virtual environment (venv) package for Python. Based on PEP 405. Copyright (C) 2011-2012 Vinay Sajip. Licensed to the PSF under a contributor agreement. usage: python -m venv [-h] [--system-site-packages] [--symlinks] [--clear] [--upgrade] ENV_DIR [ENV_DIR ...] Creates virtual Python environments in one or more target directories. positional arguments: ENV_DIR A directory to create the environment in. optional arguments: -h, --help show this help message and exit --system-site-packages Give the virtual environment access to the system site-packages dir. --symlinks Attempt to symlink rather than copy. --clear Delete the environment directory if it already exists. If not specified and the directory exists, an error is raised. --upgrade Upgrade the environment directory to use this version of Python, assuming Python has been upgraded in-place. iNcBs¼|EeZdZdZdddddd„Zdd„Zdd„Zdd „Ze j d krpd d „Z nd d„Z dd„Z dd„Zdd„Zdd„Zdd„ZdS(u EnvBuilderu This class exists to allow virtual environment creation to be customized. The constructor parameters determine the builder's behaviour when called upon to create a virtual environment. By default, the builder makes the system (global) site-packages dir *un*available to the created environment. If invoked using the Python -m option, the default is to use copying on Windows platforms but symlinks elsewhere. If instantiated some other way, the default is to *not* use symlinks. :param system_site_packages: If True, the system (global) site-packages dir is available to created environments. :param clear: If True and the target directory exists, it is deleted. Otherwise, if the target directory exists, an error is raised. :param symlinks: If True, attempt to symlink rather than copy files into virtual environment. :param upgrade: If True, upgrade an existing virtual environment. cCs(||_||_||_||_dS(N(usystem_site_packagesuclearusymlinksuupgrade(uselfusystem_site_packagesuclearusymlinksuupgrade((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyu__init__=s   uEnvBuilder.__init__cCsetjj|ƒ}|j|ƒ}|j|ƒ|j|ƒ|jsa|j|ƒ|j|ƒndS(uŠ Create a virtual environment in a directory. :param env_dir: The target directory to create an environment in. N( uosupathuabspathuensure_directoriesucreate_configurationu setup_pythonuupgradeu setup_scriptsu post_setup(uselfuenv_dirucontext((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyucreateDs    uEnvBuilder.createc Csdd„}tjj|ƒrD|jp-|j rDtd|ƒ‚ntjj|ƒro|jrotj|ƒntj ƒ}||_ tjj |ƒd|_ d|j |_ ||ƒtj}tjdkrëd|krëtjd}n tj}tjj tjj|ƒƒ\}}||_||_||_tjdkrid }d } tjj|d d ƒ} n8d }d} tjj|ddtjdd…d ƒ} tjj|| ƒ|_} || ƒ|| ƒtjj||ƒ|_} ||_tjj| |ƒ|_|| ƒ|S(uª Create the directories for the environment. Returns a context object which holds paths in the environment, for use by subsequent logic. cSs&tjj|ƒs"tj|ƒndS(N(uosupathuexistsumakedirs(ud((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyucreate_if_needed[su7EnvBuilder.ensure_directories..create_if_neededuDirectory exists: %siu(%s) udarwinu__PYVENV_LAUNCHER__uwin32uScriptsuIncludeuLibu site-packagesubinuincludeulibu python%d.%dNi(uosupathuexistsuclearuupgradeu ValueErrorushutilurmtreeutypesuSimpleNamespaceuenv_dirusplituenv_nameupromptuenvironusysuplatformu executableuabspathu python_diru python_exeujoinu version_infouinc_pathubin_pathubin_nameuenv_exe( uselfuenv_dirucreate_if_neededucontextuenvu executableudirnameuexenameubinnameuincpathulibpathupathubinpath((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyuensure_directoriesSsB %     $   ,    uEnvBuilder.ensure_directoriesc Csœtjj|jdƒ|_}t|dddƒb}|jd|jƒ|jr]d}nd}|jd|ƒ|jd t j d d …ƒWd QXd S( uA Create a configuration file indicating where the environment's Python was copied from, and whether the system site-packages should be made available in the environment. :param context: The information for the environment creation request being processed. u pyvenv.cfguwuencodinguutf-8u home = %s utrueufalseu"include-system-site-packages = %s uversion = %d.%d.%d Ni( uosupathujoinuenv_dirucfg_pathuopenuwriteu python_dirusystem_site_packagesusysu version_info(uselfucontextupathufuincl((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyucreate_configuration‚s   uEnvBuilder.create_configurationuntcCs:|jdƒrd}n|jdƒo3|jdƒ}|S(Nu.pydu.dllupythonu.exe(u.pydu.dllT(uendswithuTrueu startswith(uselfufuresult((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyuinclude_binary–s uEnvBuilder.include_binaryc Cs‡|j }|sjy)tjj|ƒs8tj||ƒnWqjtk rftjd||ƒd}YqjXn|rƒt j ||ƒndS(uQ Try symlinking a file, and if that fails, fall back to copying. uUnable to symlink %r to %rNT( usymlinksuosupathuislinkusymlinku ExceptionuloggeruwarninguTrueushutilucopyfile(uselfusrcudstu force_copy((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyusymlink_or_copys  uEnvBuilder.symlink_or_copycsŒ|j}|j}|j}|j}||j|ƒ|j}tjdkr¿tjj |ƒsqtj |dƒnxd D]@}tjj ||ƒ}tjj |ƒsxtj ||ƒqxqxWnÉd}|j‰‡fdd†tj|ƒDƒ} xW| D]O} tjj || ƒ} tjj || ƒ} | |jkr÷|| | ƒq÷q÷Wtjj ||ƒ}tjj|ƒrÞ‡fdd†tj|ƒDƒ} xH| D]=} tjj || ƒ} tjj || ƒ} || | ƒqšWnx§tj|jƒD]“\} }} d | krñtjj| ƒ}tjj |jd |ƒ}tj|ƒtjj | d ƒ} tjj |d ƒ} tj| | ƒPqñqñWd S( u· Set up a Python executable in the environment. :param context: The information for the environment creation request being processed. untiíupythonupython3uDLLscs"g|]}ˆ|ƒr|‘qS(((u.0uf(uinclude(u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyu Ãs u+EnvBuilder.setup_python..cs"g|]}ˆ|ƒr|‘qS(((u.0uf(uinclude(u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyu Ës uinit.tcluLibN(upythonupython3(ubin_pathu python_exeuenv_exeusymlink_or_copyu executableu python_diruosunameupathuislinkuchmodujoinuexistsusymlinkuinclude_binaryulistdiruisdiruwalkubasenameuenv_dirumakedirsushutilucopyfile(uselfucontextubinpathuexenameupathucopierudirnameusuffixusubdirufilesufusrcudsturootudirsutcldir((uincludeu2/opt/alt/python33/lib64/python3.3/venv/__init__.pyu setup_python¬sJ       " " "  uEnvBuilder.setup_pythoncCsGtjjtjjtƒƒ}tjj|dƒ}|j||ƒdS(u× Set up scripts into the created environment from a directory. This method installs the default scripts into the environment being created. You can prevent the default installation by overriding this method if you really need to, or if you need to specify a different location for the scripts to install. By default, the 'scripts' directory in the venv package is used as the source of scripts to install. uscriptsN(uosupathuabspathudirnameu__file__ujoinuinstall_scripts(uselfucontextupath((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyu setup_scriptsÛs uEnvBuilder.setup_scriptscCsdS(u Hook for post-setup modification of the venv. Subclasses may install additional packages or scripts here, add activation shell scripts, etc. :param context: The information for the environment creation request being processed. N((uselfucontext((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyu post_setupêsuEnvBuilder.post_setupcCsX|jd|jƒ}|jd|jƒ}|jd|jƒ}|jd|jƒ}|S(ui Replace variable placeholders in script text with context-specific variables. Return the text passed in , but with variables replaced. :param text: The text in which to replace placeholder variables. :param context: The information for the environment creation request being processed. u __VENV_DIR__u __VENV_NAME__u__VENV_BIN_NAME__u__VENV_PYTHON__(ureplaceuenv_dirupromptubin_nameuenv_exe(uselfutextucontext((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyureplace_variablesôs uEnvBuilder.replace_variablescCs!|j}t|ƒ}xtj|ƒD]ô\}}}||kr†x=|dd…D]+}|dtjfkrQ|j|ƒqQqQWq%nx|D]ˆ} tjj|| ƒ} ||d…jtj ƒdd…} | sÝ|} ntjj|| Œ} tjj | ƒstj | ƒntjj| | ƒ} t | dƒ} | j ƒ}WdQX| jdƒred}nld}y%|jdƒ}|j||ƒ}Wn>tk rÐ}zd}tjd | |ƒWYdd}~XnX|dk rt | |ƒ} | j|ƒWdQXtj| | ƒqqWq%WdS( us Install scripts into the created environment from a directory. :param context: The information for the environment creation request being processed. :param path: Absolute pathname of a directory containing script. Scripts in the 'common' subdirectory of this directory, and those in the directory named for the platform being run on, are installed in the created environment. Placeholder variables are replaced with environment- specific values. Nucommoniurbu.exeuwbuwuutf-8u+unable to copy script %r, may be binary: %s(ubin_pathulenuosuwalkunameuremoveupathujoinusplitusepuexistsumakedirsuopenureaduendswithudecodeureplace_variablesuUnicodeDecodeErroruNoneuloggeruwarninguwriteushutilucopymode(uselfucontextupathubinpathuplenurootudirsufilesudufusrcfileusuffixudstdirudstfileudataumodeue((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyuinstall_scriptssB    &    uEnvBuilder.install_scriptsNF(u__name__u __module__u __qualname__u__doc__uFalseu__init__ucreateuensure_directoriesucreate_configurationuosunameuinclude_binaryusymlink_or_copyu setup_pythonu setup_scriptsu post_setupureplace_variablesuinstall_scripts(u __locals__((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyu EnvBuilder&s  /   /  u EnvBuildercCs,td|d|d|ƒ}|j|ƒdS(u Create a virtual environment in a directory. By default, makes the system (global) site-packages dir *un*available to the created environment, and uses copying rather than symlinking for files obtained from the source Python installation. :param env_dir: The target directory to create an environment in. :param system_site_packages: If True, the system (global) site-packages dir is available to the environment. :param clear: If True and the target directory exists, it is deleted. Otherwise, if the target directory exists, an error is raised. :param symlinks: If True, attempt to symlink rather than copy files into virtual environment. usystem_site_packagesuclearusymlinksN(u EnvBuilderucreate(uenv_dirusystem_site_packagesuclearusymlinksubuilder((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyucreate7s ucreatec CsÈd$}tjd%krd&}nttdƒs6d&}n|sKtdƒ‚nyddl}|jdtdddd ƒ}|j d d d d dddƒ|j ddd&ddddddƒt j dkrÑd&}nd$}|j dd|ddddddƒ|j ddd&ddddddƒ|j ddd&dddd dd!ƒ|j |ƒ}|j rv|jrvtd"ƒ‚ntd#|jd|jd|jd |j ƒ}x|jD]}|j|ƒq­WdS('Niu base_prefixu.This script is only for use with Python >= 3.3iuprogu descriptionuFCreates virtual Python environments in one or more target directories.uepilogu|Once an environment has been created, you may wish to activate it, e.g. by sourcing an activate script in its bin directory.udirsumetavaruENV_DIRunargsu+uhelpu)A directory to create the environment in.u--system-site-packagesudefaultuactionu store_trueudestu system_siteuDGive the virtual environment access to the system site-packages dir.untu --symlinksusymlinksu[Try to use symlinks rather than copies, when symlinks are not the default for the platform.u--clearuclearuuDelete the environment directory if it already exists. If not specified and the directory exists, an error is raised.u --upgradeuupgradeulUpgrade the environment directory to use this version of Python, assuming Python has been upgraded in-place.u1you cannot supply --upgrade and --clear together.usystem_site_packagesT(iiF(uTrueusysu version_infouFalseuhasattru ValueErroruargparseuArgumentParseru__name__u add_argumentuosunameu parse_argsuupgradeuclearu EnvBuilderu system_siteusymlinksudirsucreate(uargsu compatibleuargparseuparseru use_symlinksuoptionsubuilderud((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyumainLsD          umainu__main__iu Error: %sufile(u__doc__ulogginguosushutilusysu sysconfigutypesu getLoggeru__name__uloggeru EnvBuilderuFalseucreateuNoneumainurcu Exceptionueuprintustderruexit(((u2/opt/alt/python33/lib64/python3.3/venv/__init__.pyus&      ÿ8  *