• File: __init__.cpython-38.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python38/lib64/python3.8/venv/__pycache__/__init__.cpython-38.pyc
  • Date Modified: 10/26/2026 8:15 PM
  • File size: 15.23 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
U

jV
@sdZddlZddlZddlZddlZddlZddlZddlZddlZe	e
ZGdddZdddZ
ddd	Ze
d
krdZzedZWn4ek
rZzedeejd
W5dZ[XYnXeedS)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@seZdZdZdddZddZdd	Zd
dZdd
Ze	j
dkrLdddZn
d ddZddZddZ
ddZddZddZddZdS)!
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.
    FNcCs(||_||_||_||_||_||_dSNsystem_site_packagesclearsymlinksupgradewith_pipprompt)selfrrrrr	r
r2/opt/alt/python38/lib64/python3.8/venv/__init__.py__init__,szEnvBuilder.__init__cCsxtj|}||}|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)ospathabspathensure_directoriesrcreate_configurationsetup_pythonr	
_setup_pipr
setup_scripts
post_setup)renv_dircontextZtrue_system_site_packagesrrr
create5s





zEnvBuilder.createcCs\t|D]L}tj||}tj|s4tj|r@t|q
tj|r
t	|q
dSr)
rlistdirrjoinislinkisfileremoveisdirshutilZrmtree)rrfnrrr
clear_directoryOszEnvBuilder.clear_directorycCsdd}tj|r$|jr$||t}||_tj|d|_	|j
dk	rT|j
n|j	}d||_
||tj}tjtj
|\}}||_||_||_tjdkrd}d}	tj|d	d
}
n(d}d}	tj|d
dtjddd
}
tj||	|_}||||
tjdkrXtjdkrXtjdkrXtj|d}tj|sXtd
|tj|||_}
||_tj|
||_||
|S)z
        Create the directories for the environment.

        Returns a context object which holds paths in the environment,
        for use by subsequent logic.
        cSs@tj|st|n$tj|s0tj|r<td|dS)NzUnable to create directory %r)rrexistsmakedirsrr
ValueError)drrr
create_if_needed_sz7EnvBuilder.ensure_directories.<locals>.create_if_neededNz(%s) Zwin32ZScriptsZIncludeLibz
site-packagesbinZincludelibzpython%d.%dlposixdarwinlib64)rrr$rr#typesSimpleNamespacersplitenv_namer
sys_base_executabler
executable
python_dirZ
python_exeplatformrversion_infoZinc_pathmaxsizenamesymlinkbin_pathbin_nameenv_exe)rrr(rr
r7dirnameZexenameZbinnameZincpathZlibpathrZ	link_pathbinpathrrr
rWsL



zEnvBuilder.ensure_directoriesc	Cstj|jd|_}t|dddj}|d|j|jrBd}nd}|d||d	t	j
d
d|jd
k	r|d|jd
W5QRXd
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.cfgwutf-8)encodingz
home = %s
trueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
Nz	prompt = 
)rrrrZcfg_pathopenwriter8rr5r:r
)rrrfZinclrrr
rs	
zEnvBuilder.create_configurationntcCs|j}|szRtj|s\|rPtj|tj|ks:tttj||nt||Wn&tk
rt	
d||d}YnX|rt||dS)Y
            Try symlinking a file, and if that fails, fall back to copying.
            Unable to symlink %r to %rTN)
rrrrrAAssertionErrorr=basename	Exceptionloggerwarningr!copyfile)rsrcdstrelative_symlinks_okZ
force_copyrrr
symlink_or_copys
zEnvBuilder.symlink_or_copycCs|tj|otj|}|jr|stj|szH|rhtj|tj|ksRtttj	||nt||WdSt
k
rtd||YnXtj
tj	|\}}tjtjtdd||}tdstj|sD|dr
d|}|dd}|dkrd	}n|d
kr(d}tjtj|||}n|}tj|sl|shtd|dSt||dS)
rMNrNscriptsrLTZ_dpythonZvenvlauncherZpythonwZ
venvwlauncherzUnable to copy %r)rrlexistsr$rrrArOr=rPrQrRrSsplitextr__file__	sysconfigis_python_buildrendswithr!rT)rrUrVrWZbad_srcrPZextZsrcfnrrr
rXs>

cCs|j}|j}|j}|j}tjdkr||j|tj|sFt	|ddD]F}tj
||}tj|sJ||j|ddtj|sJt	|dqJn|jrddt
|D}tdrdd|D}nd	d
ddg}|D]2}tj
||}tj|r||tj
||qtdrt|jD]z\}	}
}d
|kr&tj|	}tj
|jd|}tj|spt|tj
|	d
}tj
|d
}
t||
qq&dS)z
        Set up a Python executable in the environment.

        :param context: The information for the environment creation request
                        being processed.
        rLi)r[Zpython3T)rWcSs,g|]$}tjtj|ddkr|qS)r)).exez.dll)rrnormcaser].0rKrrr

<listcomp>sz+EnvBuilder.setup_python.<locals>.<listcomp>cSs"g|]}tj|dr|qS))r[Z	vcruntime)rrrc
startswithrdrrr
rfsz
python.exezpython_d.exezpythonw.exez
pythonw_d.exezinit.tclr*N)r>r@rXr8rr<r7rrchmodrr$rrr_r`r\walkrPrr%r!rT)rrrBrZcopierrAsuffixsuffixesrUrootdirsfilesZtcldirrVrrr
rsP



zEnvBuilder.setup_pythoncCs$|jddddg}tj|tjddS)z1Installs or upgrades pip in a virtual environmentz-ImZ	ensurepip	--upgradez
--default-pip)stderrN)r@
subprocessZcheck_outputZSTDOUT)rrcmdrrr
rs
zEnvBuilder._setup_pipcCs2tjtjt}tj|d}|||dS)a
        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.
        rYN)rrrrAr^rinstall_scripts)rrrrrr
r$szEnvBuilder.setup_scriptscCsdS)a
        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.
        Nr)rrrrr
r3szEnvBuilder.post_setupc	s|j|j|j|j|jd}dd}dd}tj|j}|drF|n|drV|ntjfdd	|	D}|	D]\}}|
||}qz|S)
ai
        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.
        )Z__VENV_DIR__Z
__VENV_NAME__Z__VENV_PROMPT__Z__VENV_BIN_NAME__Z__VENV_PYTHON__cSs|dd}d|dS)a
            This should satisfy PowerShell quoting rules [1], unless the quoted
            string is passed directly to Windows native commands [2].
            [1]: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules
            [2]: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing#passing-arguments-that-contain-quote-characters
            'z'')replacesrrr
	quote_ps1Psz/EnvBuilder.replace_variables.<locals>.quote_ps1cSs|Srrrvrrr
	quote_batZsz/EnvBuilder.replace_variables.<locals>.quote_batz.ps1z.batcsi|]\}}||qSrr)rekeyrwquoterr

<dictcomp>hsz0EnvBuilder.replace_variables.<locals>.<dictcomp>)rr4r
r?r@shlexr|script_pathraitemsru)	rtextrZreplacementsrxryrrzZquotedrr{r
replace_variables=s&


zEnvBuilder.replace_variablescCs|j}t|}t|D]\}}}||krX|ddD]}|dtjfkr8||q8q|D]N}	tjdkr|	dr|	drq\tj	||	}
||d
tjdd}|s|}ntjj	|f|}tj|st
|tj	||	}
t|
d}	|	}W5QRX|
dsx|
|_z$|d}|||}|d}Wn6tk
rv}zd}td	|
|W5d}~XYnX|dk	r\t|
d
}	|	|W5QRXt|
|
q\qdS)as
        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.
        NcommonrLr[)rbz.pdbr-rbrDz+unable to copy script %r, may be binary: %swb)r>lenrrir<rrgrarrr3sepr$r%rIreadrdecoderencodeUnicodeErrorrRrSrJr!Zcopymode)rrrrBZplenrlrmrnr'rKZsrcfilerjZdstdirZdstfiledataerrr
rsmsN



zEnvBuilder.install_scripts)FFFFFN)F)F)__name__
__module____qualname____doc__rrr#rrrr<rXrrrrrrsrrrr
rs(
	4

+<	
0rFcCs t|||||d}||dS)z,Create a virtual environment in a directory.)rrrr	r
N)rr)rrrrr	r
builderrrr
rsrc	Cs^d}tjdkrd}nttds"d}|s2tdn(ddl}|jtddd	}|jd
ddd
d|jddddddtj	dkrd}nd}|
}|jd|dddd|jd|dddd|jdddddd|jddddd d|jd!d"ddd#d$|jd%d&d'||}|jr"|j
r"td(t|j|j
|j|j|j|jd)}|jD]}||qHdS)*NT)rGrGFbase_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.)progZdescriptionZepilogrmZENV_DIR+z)A directory to create the environment in.)metavarnargshelpz--system-site-packages
store_truesystem_sitezDGive the virtual environment access to the system site-packages dir.)defaultactiondestrrLz
--symlinksrz[Try to use symlinks rather than copies, when symlinks are not the default for the platform.z--copiesZstore_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.rorzlUpgrade 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))rrrrz--promptz;Provides an alternative prompt prefix for this environment.)rz1you cannot supply --upgrade and --clear together.r)r5r:hasattrr&argparseArgumentParserradd_argumentrr<Zadd_mutually_exclusive_group
parse_argsrrrrrr	r
rmr)	argsZ
compatiblerparserZuse_symlinksgroupZoptionsrr'rrr
mains|









r__main__r)z	Error: %s)file)FFFFN)N)rZloggingrr!rqr5r_r1r~Z	getLoggerrrRrrrZrcrQrprintrpexitrrrr
<module>s6


H$