HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/relenv/__pycache__/runtime.cpython-310.pyc
o

�N�gow�
@s"dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
dd�Zdd�Zdd�Zd	d
�Zejdd��Zd
d�Zdd�Zdd�Zdd�Zdddddddddddd�Zdad d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�ZGd,d-�d-�Z Gd.d/�d/�Z!d0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&d:d;�Z'd<d=�Z(Gd>d?�d?�Z)d@dA�Z*dBdC�Z+dDdE�Z,dFdG�Z-e!e dHe"�e dIe#�e dJe$�e dKe%�e dLe&�e dMe(�e dNe*�e dOe+�e dPe,�e dQe-�g
dR�Z.dSdT�Z/dUdV�Z0dWdX�Z1dYdZ�Z2d[d\�Z3d]d^�Z4d_d`�Z5dS)aa�
This code is run when initializing the python interperter in a Relenv environment.

- Point Relenv's Openssl to the system installed Openssl certificate path
- Make sure pip creates scripts with a shebang that points to the correct
  python using a relative path.
- On linux, provide pip with the proper location of the Relenv toolchain
  gcc. This ensures when using pip any c dependencies are compiled against the
  proper glibc version.
�NcCs<ddl}|j�||�}|j�|�}|j�|�|tj|<|S)z�
    Import module from a path.

    This causes hashlib to be imported because of importing importlib.util so
    it can not be used until after openssl has been configured.
    rN)�importlib.util�util�spec_from_file_location�module_from_spec�loader�exec_module�sys�modules)�name�path�	importlib�spec�module�r�B/opt/saltstack/salt/lib/python3.10/site-packages/relenv/runtime.py�path_import#s
rcC�,ttd�stdtt�t�jd��t_tjS)z$
    Late import relenv common.
    �commonz
relenv.commonz	common.py)�hasattrrr�str�pathlib�Path�__file__�parentrrrrr3�

�rcCr)z&
    Late import relenv relocate.
    �relocatezrelenv.relocatezrelocate.py)rrrrrrrrrrrrr>rrcCsdjtj�S)z'
    Current python major version.
    z{}.{})�formatr�version_inforrrr�get_major_versionI�rc	cs8�t��}t�|�zdVWt�|�dSt�|�w)z
    Changedir context.
    N)�os�getcwd�chdir)Znew_dirZold_dirrrr�pushdPs�
r#cCs&tj�d�rt|�tj��dSdS)z�
    Prints the provided message if RELENV_DEBUG is truthy in the environment.

    :param string: The message to print
    :type string: str
    ZRELENV_DEBUGN)r �environ�get�printr�stdout�flush)�stringrrr�debug]s�r*cCs0t�t���j}tjdkr|jjjS|jjjjS)z(
    Return the relenv module root.
    �win32)rrr�resolverr�platform)Z
MODULE_DIRrrr�relenv_rootis

r.cst����fdd��}|S)zf
    Build a shebang to point to the proper location.

    :return: The shebang
    :rtype: bytes
    cs�t�|j�}tjrt�tj���d}zt��tj	|t�tj
����}Wnty@t
d|j����|g|�Ri|��YSwt
d|�d|���tjdkr]tt�d�|���dSt��d|���S)	N�binz$Relenv Value Error - _build_shebang zRelenv - _build_shebang � r+z#!<launcher_dir>s
�/)rr�
target_dir�TARGET�PATH�absoluterZrelative_interpreterr�RELENV�
executabler,�
ValueErrorr*r-r�encodeZformat_shebang)�self�args�kwargs�scriptsZinterpreter��funcrr�wrapped~s ��
�z_build_shebang.<locals>.wrapped��	functools�wraps)r?r;r<r@rr>r�_build_shebangvsrDc�t����fdd��}|S)�H
    Return a wrapper to resolve paths relative to the relenv root.
    csl|dkr&�|�}tj�d�rt�}nt�d}td|�d|�d|���|S�|�}td|�d|���|S)NZBINDIR�RELENV_PIP_DIRZScriptszget_config_var call z old: z new: r0)r r$r%r.r*)r
Zorig�valr>rrr@�s
z'get_config_var_wrapper.<locals>.wrappedrA)r?r@rr>r�get_config_var_wrapper�srIZar�gccz?-Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wallz-I. -I./Includezg++z/usr/local/lib/python3.8z/usr/local/libzgcc -shared�zg++ -shared�ZARZCCZCFLAGSZCPPFLAGSZCXXZLIBDESTZ	SCRIPTDIRZ	BLDSHAREDZLDFLAGSZLDCXXSHAREDZLDSHAREDcCs�trtSt�d�}|��r<tjt|�ddgdd�}zt�|j	�
��aWtStjy;td|j	�
����t
aYtSwtd�t
atS)z�
    Read the system python's sysconfig values.

    Th system python isthe one installed by your package manager. Memoize them
    to avoid the overhead of shelling out.
    z/usr/bin/python3z-czFimport json, sysconfig; print(json.dumps(sysconfig.get_config_vars()))T)�capture_outputzFailed to load JSON from: zSystem python not found)�_SYSTEM_CONFIG_VARSrr�exists�
subprocess�runr�json�loadsr'�stripZJSONDecodeErrorr*�_CONFIG_VARS_DEFAULTS)Zpyexec�prrr�system_sysconfig�s,
����rWcst�����fdd��}|S)rFcsLtjdks
dtjvr�|�S��}t�}dD]}||||<q|�_�|�S)Nr+�RELENV_BUILDENVrL)rr-r r$rW�_CONFIG_VARS)r;rYrNr
�r?�modrrr@�s
z(get_config_vars_wrapper.<locals>.wrappedrA)r?r[r@rrZr�get_config_vars_wrapper�sr\cs"t���|ddf�fdd�	�}|S)rFNTcs4�|||d�}dtjvrtt��|d<|dt_|S)N)�scheme�vars�expandrGr=)r r$rr.r�exec_prefix)r]r^r_�pathsr>rrr@s


z"get_paths_wrapper.<locals>.wrappedrA)r?Zdefault_schemer@rr>r�get_paths_wrapper�srbcrE)zl
    Wrapper around build_ext.finalize_options.

    Used to add the relenv environment's include path.
    cs<�|g|�Ri|��dtjvr|j�t��d��dSdS)NrXz/include)r r$Zinclude_dirs�appendr.)r:r;r<r>rr�wrappers
�z)finalize_options_wrapper.<locals>.wrapperrA�r?rdrr>r�finalize_options_wrappersrfcrE)z{
    Wrap pip's wheel install function.

    This method determines any newly installed files and checks their RPATHs.
    c	sddlm}ddlm}	||��}
|	|
|�\}}Wd�n1s"wY�||||||||�t�|j�}
t�}t|
|d��@}|�	�D]2}|
|�
dd�d}|��s`td|���qHt
��|�rztd|���t
��|
||d	d
|�qHWd�dS1s�wYdS)Nr)�ZipFile)�parse_wheelZRECORD�,��Relenv - File not found �Relenv - Found elf �libT)ZzipfilergZpip._internal.utils.wheelrhrr�platlibr.�open�	readlines�splitrOr*r�is_elf�
handle_elf)r
Z
wheel_pathr]�req_description�	pycompile�warn_script_locationZ
direct_urlZ	requestedrgrhZzfZinfo_dirZmetadata�plat�rootdir�fp�line�filer>rrrd"s:
��
��"�z&install_wheel_wrapper.<locals>.wrapperrArerr>r�install_wheel_wrappers&r|crE)z|
    Wrap pip's legacy install function.

    This method determines any newly installed files and checks their RPATHs.
    csTt�|�jd}t|��}|��}Wd�n1swYd}d}|��D]&}|�d�r<|�d�d��}|r<n|�d�rN|�d�d��}|rNnq(�||||||||||	|
|||
�d}|r�t�|�ddt	���d	}t
|�d
��D]}|j�|�d|���r�|}nqzt
t�|j
��d
��D]}|j�|�d|���r�|}nq�|dur�td|
���dSt�|j�}t�}t|��\td
��>}|��D]1}t�|�����}|��s�td|���q�t��|�r�td|���t��|||dd|�q�Wd�n1�s
wYWd�dSWd�dS1�s#wYdS)NzPKG-INFOzVersion:z	Version: rjzName:zName: rm�python�
site-packagesz
*.egg-info�-z*Relenv was not able to find egg info for: zinstalled-files.txtrkrlT)rrrro�read�
splitlines�
startswithrqrTr�sorted�globr
�purelibr*rnr.r#rpr,rOrrrrs)�install_options�global_options�root�home�prefix�
use_user_siterur]Z
setup_py_path�isolatedZreq_nameZ	build_envZunpacked_source_directoryrtZpkginforyZpkg_info�versionr
rzZegginfoZsitepackrrwrxr{r>rrrdUs�

�

���
�����

��� ��$�z'install_legacy_wrapper.<locals>.wrapperrArerr>r�install_legacy_wrapperLs	Qr�c@s*eZdZdZddd�Zdd�Zdd	�Zd
S)�Wrapperz-
    Wrap methods of an imported module.
    �equalsFcCs||_||_||_||_dS�N)rrd�matcher�loading)r:rrdr�Z_loadingrrr�__init__�s
zWrapper.__init__cCs |jdkr|�|j�S|j|kS)zA
        Check if wrapper metches module being imported.
        r�)r�r�r�r:rrrr�matches�s

zWrapper.matchescCs
|�|�S)z0
        Preform the wrapper operation.
        )rd)r:�module_namerrr�__call__�s
zWrapper.__call__N)r�F)�__name__�
__module__�__qualname__�__doc__r�r�r�rrrrr��s

r�c@sFeZdZdZddd�Zddd�Zddd�Zd	d
�Zdd�Zd
d�Z	dS)�RelenvImporterz4
    Handle runtime wrapping of module methods.
    NcCs,|durg}t|�|_|duri}||_dSr�)�set�wrappers�_loads)r:r�r�rrrr��s

zRelenvImporter.__init__cCsR|jD]#}|�|�r&|js&td|�d|�d|���d|_tj�||�SqdS)�.
        Find modules being imported.
        �RelenvImporter - match r0TN)r�r�r�r*rr�spec_from_loader)r:r��package_path�targetrdrrr�	find_spec�s
��zRelenvImporter.find_speccCs<|jD]}|�|�r|jstd|���d|_|SqdS)r�r�TN)r�r�r�r*)r:r�r�rdrrr�find_module�s
��zRelenvImporter.find_modulecCsD|jD]}|�|�rtd|���||�}d|_nq|tj|<|S)z*
        Load an imported module.
        zRelenvImporter - load_module F)r�r�r*r�rr	)r:r
rdr[rrr�load_module�s

�
zRelenvImporter.load_modulecCs|�|j�S)z/
        Create the module via a spec.
        )r�r
)r:r
rrr�
create_module�rzRelenvImporter.create_modulecCsdS)z#
        Exec module noop.
        Nrr�rrrr�szRelenvImporter.exec_module�NNr�)
r�r�r�r�r�r�r�r�r�rrrrrr��s





r�cCsdt�d�}t|j�|_t|j|�|_d|_z|��}Wn
ty(|�	�}Ynwt
|j|�|_|S)z
    Sysconfig wrapper.
    �	sysconfigT)r�
import_modulerIZget_config_varr\Zget_config_varsZ_PIP_USE_SYSCONFIGZget_default_scheme�AttributeErrorZ_get_default_schemerbZ	get_paths)r
r[r]rrr�wrap_sysconfig�s
�r�cCst�|�}t|jj�|j_|S)z&
    pip.distlib.scripts wrapper.
    )rr�rDZScriptMaker�r
r[rrr�wrap_pip_distlib_scriptss
r�cCst�|�}t|jj�|j_|S)z$
    distutils.command wrapper.
    )rr�rfZ	build_extZfinalize_optionsr�rrr�wrap_distutils_commands

�r�cC�t�|�}t|j�|_|S)z9
    pip._internal.operations.install.wheel wrapper.
    )rr�r|Z
install_wheelr�rrr�wrap_pip_install_wheel%�
r�cCr�)z:
    pip._internal.operations.install.legacy wrapper.
    )rr�r��installr�rrr�wrap_pip_install_legacy.r�r�cCsX|tjvrtj||krtd|�d|�dtj|���dStd|���|tj|<dS)z�
    Set an environment variable if not already set.

    If the environment variable is already set and not equal to value, warn the
    user.
    z	Warning: z1 environment not set to relenv's root!
expected: z

current: zRelenv set N)r r$r&r*)r
�valuerrr�set_env_if_not_set7s���r�cC�"t�|�}dd�}||j�|_|S)z1
    pip._internal.operations.build wrapper.
    crE)Ncs�t���}|jt���}|��std�n&ttj�}d|�d|�d|�d�}t|d�}t	d|�t	d|�t	d|��|i|��S)	N�,Unable to set CARGO_HOME no toolchain existsz-C link-arg=-Wl,-rpath,z/lib -C link-arg=-Lz/sysroot/lib�cargoZ
CARGO_HOMEZOPENSSL_DIRZ	RUSTFLAGS)
r�	work_dirs�	toolchain�get_tripletrOr*rrr6r�)r;r<�dirsr�Z
relenvrootZ	rustflags�
cargo_homer>rrrdOs 


���


z3wrap_pip_build_wheel.<locals>.wrap.<locals>.wrapperrArerr>r�wrapNsz"wrap_pip_build_wheel.<locals>.wrap)rr�Zbuild_wheel_pep517�r
r[r�rrr�wrap_pip_build_wheelHs
r�c@s eZdZdZdZdZdZdZdS)r3z0
    Container for global pip target state.
    FN)r�r�r�r�r3ZTARGET_PATH�IGNORE�INSTALLrrrrr3hsr3cCsJt�|�}dd�}||jj�|j_dd�}t|jd�r#||jj�|j_|S)zB
    Wrap pip install command to store target argument state.
    crE)Ncs.|js|jrdt_|jt_|jt_�|||�S)NT)r�r2r3r4�ignore_installedr�)r:�optionsr;r>rrrdzs�/wrap_cmd_install.<locals>.wrap.<locals>.wrapperrArerr>rr�yszwrap_cmd_install.<locals>.wrapcSst�|�dd��}|S)NcSsddlm}|S)Nr)�SUCCESS)Zpip._internal.cli.status_codesr�)r:r2Ztarget_temp_dirZupgrader�rrrrd�sr�rArerrrr��s
�_handle_target_dir)rr�ZInstallCommandrQrr�r�rrr�wrap_cmd_installss
	�r�cCr�)zJ
    Wrap pip locations to fix locations when installing with target.
    cst���	d�fdd�	�}|S)NFcsJ�||||||�}tjr#tjr#ddlm}|tjtj|j|j|jd�}|S)Nr)�Scheme)rnr��headersr=�data)r3r�Zpip._internal.models.schemer�r4r�r=r�)Z	dist_name�userr�r�r�r�r]r�r>rrrd�s�z-wrap_locations.<locals>.wrap.<locals>.wrapper)FNNFNrArerr>rr��s�zwrap_locations.<locals>.wrap)rr�Z
get_schemer�rrr�wrap_locations�s
r�cCs&t�|�}dd�}||jj�|j_|S)�5
    Honor ignore installed option from pip cli.
    cs t���		d�fdd�	�}|S)Ncstjrtj|_�|||||�Sr�)r3r�r�)r:r�ZsessionZ
target_pythonZignore_requires_pythonr>rrrd�sz/wrap_req_command.<locals>.wrap.<locals>.wrapperr�rArerr>rr��s
�zwrap_req_command.<locals>.wrap)rr�ZRequirementCommandZ_build_package_finderr�rrr�wrap_req_command�s
�r�cs*t�|���fdd�}|�jj��j_�S)r�csd�jjjjdkrt���							d�fdd�	�}|St���							d�fdd�	�}|S)N�	TFc		
s<ztjr
dt_tj}�|||||||||�	Wdt_Sdt_w�NTF�r3r�r4)	r:r�r�r�r�r�rvr�rur>rrrd�s �z/wrap_req_install.<locals>.wrap.<locals>.wrapperc	s:ztjr
dt_tj}�||||||||�Wdt_Sdt_wr�r�)r:r�r�r�r�rvr�rur>rrrd�s�)NNNNTFT)�InstallRequirementr��__code__�co_argcountrBrCre�r[r>rr��s*�;��zwrap_req_install.<locals>.wrap)rr�r�r�)r
r�rr�r�wrap_req_install�s
Ar�r�zpip._vendor.distlib.scriptszdistutils.command.build_extz&pip._internal.operations.install.wheelz'pip._internal.operations.install.legacyz$pip._internal.operations.build.wheelzpip._internal.commands.installzpip._internal.locationszpip._internal.cli.req_commandzpip._internal.req.req_install)r�cCs�tjdkrdSt���}t���}|j|}|��s td�dS|d}|��s,|��|d}|��sj|dkr;d}nd}|d	|�d
�}t	|d��}|�
t�d��
||��Wd�dS1scwYdSdS)
z
    Setup cargo config.
    ZlinuxNr�r�zconfig.tomlzx86_64-linux-gnuzx86_64-unknown-linux-gnuzaarch64-unknown-linux-gnur/z-gcc�wz>            [target.{}]
            linker = "{}"
            )rr-rr�r�r�rOr*�mkdirro�write�textwrap�dedentr)Ztripletr�r�r�Zcargo_configZ
cargo_tripletrJryrrr�install_cargo_config+s4



��"��r�cCst�d�}|s
td�dSdtjvr�tjdkr�tj|ddgdd	d	dd
�}|j	dkr;d}|j
r6|d
|j
��7}t|�n.z
|j�d�\}}Wnt
yStd�YdSw|���d�}t|�td�dkritd�tttjdd��td�dkr~td�td�dkr�td�dtjv�rtjdk�rtj|ddgdd	d	dd
�}|j	dkr�d}|j
r�|d
|j
��7}t|�dSz
|j�d�\}}Wnt
y�td�YdSwt�|���d��}tj�d�s�t|d�tjd<|d}|���rtj�d��s
t|�tjd<dSdSdSdSdS) z2
    Configure openssl certificate locations.
    Zopensslz/Could not find the 'openssl' binary in the pathNZOPENSSL_MODULESr+r�z-mTF)Zuniversal_newlines�shellZcheckrMrz0Unable to get the modules directory from opensslz: �:zUnable to parse modules dir�"Zfipsz(Unable to load the fips openssl providerrmzossl-modules�defaultz+Unable to load the default openssl providerZlegacyz*Unable to load the legacy openssl providerZSSL_CERT_DIRz-dz5Unable to get the certificates directory from opensslzUnable to parse openssldirZcertszcert.pemZ
SSL_CERT_FILE)�shutil�whichr*r r$rr-rPrQ�
returncode�stderrr'rqr8rT�set_openssl_modules_dir�load_openssl_providerrr6rrr%rO)Zopenssl_bin�proc�msg�_Z	directoryrZ	cert_filerrr�
setup_opensslLsv
�

��
��r�cCsltjdkrttjdd�}n	ttjdd�}t�|�}tj}|j}|tjf|_	tj
|_|d|���dS)z>
    Set the default search location for openssl modules.
    �darwinrm�libcrypto.dylib�libcrypto.soN)
rr-rr6�ctypes�CDLL�c_void_p�%OSSL_PROVIDER_set_default_search_path�c_char_p�argtypes�c_int�restyper9)r�
cryptopath�	libcrypto�
POSSL_LIB_CTXr�rrrr��s

�r�cCshtjdkrttjdd�}n	ttjdd�}t�|�}tj}|j}|tjf|_	tj
|_|d|���S)z!
    Load an openssl module.
    r�rmr�r�N)
rr-rr6r�r�r��OSSL_PROVIDER_loadr�r�r�r�r9)r
r�r�r�r�rrrr��s

r�cCs�tj�dd�}|rLt�|���}t|�t_t|�t_	dtj
j�dtj
j��}t|d|�t|d|d�t|d|d�gdd	�tj
D�t_
d
Sd
S)z%
    Setup cross root if needed.
    ZRELENV_CROSSrKr}�.rmzlib-dynloadr~cSsg|]}d|vr|�qS)r~r)�.0r�rrr�
<listcomp>�sz#setup_crossroot.<locals>.<listcomp>N)r r$r%rrr,rrr�r`r�major�minorr)ZcrossZ	crossrootZpyverrrr�setup_crossroot�s

�
��rcrE)z�
    Wrap site.execsitecustomize.

    This allows relenv a hook to be the last thing that runs when pythong is
    setting itself up.
    c
s���d}zddl}Wnty#}z|jdkr�WYd}~nd}~ww|dus-d|jvrPtjdd�}t��tj�tjdd�<td|���tdtj���ntd�dt	_
td�dS)	Nr�
sitecustomizez
pip-build-envzoriginal sys.path was znew sys.path is zSkip path mungingFzAfter site customize wrapper)r�ImportErrorr
rrrrZsanitize_sys_pathr*�site�ENABLE_USER_SITE)r�excZ_origr>rrrd�s$
���z"wrapsitecustomize.<locals>.wrapperrArerr>r�wrapsitecustomize�sr	cCsLtjddtddd�t�t_t�ttj	�t_	t
�t�tgtj
t_
dS)z+
    Bootstrap the relenv environment.
    �ignorez.*falling back to find_module.*zimportlib._bootstrapi�)�message�categoryr�linenoN)�warnings�filterwarnings�
ImportWarningr.rr6r�r	r�execsitecustomizerr��importer�	meta_pathrrrr�	bootstrap�s�r)6r��
contextlibr�rBrrRr rr�rrPrr�rrrrr�contextmanagerr#r*r.rDrIrUrNrWr\rbrfr|r�r�r�r�r�r�r�r�r�r�r3r�r�r�r�rr�r�r�r�rr	rrrrr�<module>s�



� 1^;			 $K��!L&