File: //lib64/python3.8/venv/__pycache__/__init__.cpython-38.opt-1.pyc
U
e5dFR ã
@ sÆ d Z ddlZddlZddlZddlZddlZddlZddlZe e ¡Z
G dd„ dƒZddd„Zddd „Z
e d
krÂdZze
ƒ dZW n4 ek
r¶ Z zede ejd
W 5 dZ[X Y nX e e¡ dS )z›
Virtual environment (venv) package for Python. Based on PEP 405.
Copyright (C) 2011-2014 Vinay Sajip.
Licensed to the PSF under a contributor agreement.
é Nc @ sŠ e Zd ZdZddd„Zdd„ Zdd „ Zd
d„ Zdd
„ Ze j
dkrLddd„Zn
d dd„Zdd„ Zdd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )!Ú
EnvBuildera–
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, delete the contents of the environment directory if
it already exists, before environment creation.
:param symlinks: If True, attempt to symlink rather than copy files into
virtual environment.
:param upgrade: If True, upgrade an existing virtual environment.
:param with_pip: If True, ensure pip is installed in the virtual
environment
:param prompt: Alternative terminal prefix for the environment.
FNc C s( || _ || _|| _|| _|| _|| _d S ©N©Úsystem_site_packagesÚclearÚsymlinksÚupgradeÚwith_pipÚprompt)Úselfr r r r r r
© r ú%/usr/lib64/python3.8/venv/__init__.pyÚ__init__+ s zEnvBuilder.__init__c C sx t j |¡}| |¡}| j}d| _| |¡ | |¡ | jrF| |¡ | j s`|
|¡ | |¡ |rtd| _| |¡ dS )zŠ
Create a virtual environment in a directory.
:param env_dir: The target directory to create an environment in.
FTN)ÚosÚpathÚabspathÚensure_directoriesr Úcreate_configurationÚsetup_pythonr Ú
_setup_pipr Ú
setup_scriptsÚ
post_setup)r Úenv_dirÚcontextZtrue_system_site_packagesr r r
Úcreate4 s
zEnvBuilder.createc C s\ t |¡D ]L}t j ||¡}t j |¡s4t j |¡r@t |¡ q
t j |¡r
t |¡ q
d S r )
r Úlistdirr ÚjoinÚislinkÚisfileÚremoveÚisdirÚshutilZrmtree)r r Úfnr r r
Úclear_directoryN s zEnvBuilder.clear_directoryc C sŽ dd„ }t j |¡r$| jr$| |¡ t ¡ }||_t j |¡d |_ | j
dk rT| j
n|j }d| |_
||ƒ tj}t j t j
|¡¡\}}||_||_||_tjdkrÀd}d} t j |d d
¡}
n(d}d} t j |d
dtjdd… d
¡}
t j || ¡ |_}||ƒ ||
ƒ tjdkrXt jdkrXtjdkrXt j |d¡}t j |¡sXt d
|¡ t j ||¡ |_}
||_t j |
|¡|_||
ƒ |S )zª
Create the directories for the environment.
Returns a context object which holds paths in the environment,
for use by subsequent logic.
c S s@ t j | ¡st | ¡ n$t j | ¡s0t j | ¡r<td| ƒ‚d S )NzUnable to create directory %r)r r ÚexistsÚmakedirsr r Ú
ValueError)Údr r r
Úcreate_if_needed^ s z7EnvBuilder.ensure_directories.<locals>.create_if_neededé Nz(%s) Zwin32ZScriptsZIncludeÚLibz
site-packagesÚbinZincludeÚlibzpython%d.%dé l ÚposixÚdarwinÚlib64)r r r$ r r# Ú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)r r r( r r
r7 ÚdirnameZexenameZbinnameZincpathZlibpathr Z link_pathÚbinpathr r r
r V sL
þÿzEnvBuilder.ensure_directoriesc C s˜ t j |jd¡ |_}t|dddj}| d|j ¡ | jrBd}nd}| d| ¡ | d t j
d
d… ¡ | jd
k rŠ| d| j›d
¡ W 5 Q R X d
S )aA
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.
z
pyvenv.cfgÚwúutf-8)Úencodingz
home = %s
ÚtrueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
Né z prompt = Ú
)r r r r Zcfg_pathÚopenÚwriter8 r r5 r: r
)r r r ÚfZinclr r r
r Š s
zEnvBuilder.create_configurationÚntc C s~ | j }|sjz6tj |¡s@|r4t tj |¡|¡ nt ||¡ W n& tk
rh t d||¡ d}Y nX |rzt
||¡ dS )úY
Try symlinking a file, and if that fails, fall back to copying.
úUnable to symlink %r to %rTN)r r r r r= ÚbasenameÚ ExceptionÚloggerÚwarningr! Úcopyfile)r ÚsrcÚdstÚrelative_symlinks_okZ
force_copyr r r
Úsymlink_or_copy s
zEnvBuilder.symlink_or_copyc C s\ t j |¡ot j |¡ }| jr€|s€t j |¡s€z,|rLt t j |¡|¡ nt ||¡ W dS tk
r~ t
d||¡ Y nX t j t j |¡¡\}}t j t j
t¡dd|| ¡}t d¡sÎt j |¡s$| d¡rìd| }|dd… }|dkrúd }n|d
krd}t j t j
|¡|| ¡}n|}t j |¡sL|sHt
d|¡ dS t ||¡ dS )
rM NrN ÚscriptsrL TZ_déþÿÿÿÚpythonZvenvlauncherZpythonwZ
venvwlauncherzUnable to copy %r)r r Úlexistsr$ r r r= rO rP rQ rR Úsplitextr rA Ú__file__Ú sysconfigÚis_python_buildr Úendswithr! rS )r rT rU rV Zbad_srcrO ZextZsrcfnr r r
rW ³ s<