Viewing File: /opt/hc_python/lib/python3.12/site-packages/pip/_internal/__pycache__/build_env.cpython-312.pyc

�

T�*j�U��^�dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZmZmZddlmZddlmZdd
lm Z m!Z!ddl"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(m)Z)m*Z*ddl+m,Z,m-Z-ddl.m/Z/ddl0m1Z1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8m9Z9er+ddl:m;Z;ddl<m=Z=ddl>m?Z?ddl@mAZAddlBmCZCGd�ded��ZDej�eF�ZGd.d�ZHGd �d!�ZId/d"�ZJd0d#�ZKGd$�d%e�ZLGd&�d'�ZMGd(�d)�ZNGd*�d+�ZOGd,�d-eO�ZPy)1z:Build Environment used for isolation during sdist building�)�annotationsN)�OrderedDict)�Iterable�Sequence)�AbstractContextManager)�nullcontext)�StringIO)�
TracebackType)�
TYPE_CHECKING�Protocol�	TypedDict)�Version)�__file__)�open_rich_spinner�open_spinner)�BuildDependencyInstallError�DiagnosticPipError�InstallWheelBuildError�PipError)�get_platlib�get_purelib�
get_scheme)�get_default_environment�get_environment)�
deprecated)�VERBOSE�capture_logging)�get_requirement)�call_subprocess)�
TempDirectory�
tempdir_kinds)�
WheelCache)�
PackageFinder)�BuildTracker)�InstallRequirement)�BaseResolverc��eZdZUded<y)�ExtraEnvironzdict[str, str]�
extra_environN)�__name__�
__module__�__qualname__�__annotations__���F/opt/hc_python/lib/python3.12/site-packages/pip/_internal/build_env.pyr(r(,s��%�%r/r(F)�totalc��||k7r||fS|fS�Nr.)�a�bs  r0�_dedupr63s���!�V�A�q�6�%�!��%r/c��eZdZdd�Zy)�_Prefixc��||_d|_td|��}|j|_t|j|j�|_y)NF�)�prefix)	�path�setupr�scripts�bin_dirr6�purelib�platlib�lib_dirs)�selfr<�schemes   r0�__init__z_Prefix.__init__8s=����	���
��B�t�,���~�~����v�~�~�v�~�~�>��
r/N)r<�str�return�None)r*r+r,rEr.r/r0r8r87s��?r/r8c���tjt�j�j}|j�st
|�Stj|dz�S)z�Get a file to pass to a Python executable, to run the currently-running pip.

    This is used to run a pip subprocess, for installing requirements into the build
    environment.
    z__pip-runner__.py)	�pathlib�Path�pip_location�resolve�parent�is_dirrF�os�fsdecode)�sources r0�get_runnable_piprS@sK���\�\�,�
'�
/�
/�
1�
8�
8�F��=�=�?��6�{��
�;�;�v� 3�3�4�4r/c���ttd�rtj�}nt�t	�g}|D�chc]!}t
jj|���#c}Scc}w)z�Get system site packages

    Usually from site.getsitepackages,
    but fallback on `get_purelib()/get_platlib()` if unavailable
    (e.g. in a virtualenv created by virtualenv<20)

    Returns normalized set of strings.
    �getsitepackages)�hasattr�siterUrrrPr<�normcase)�system_sitesr<s  r0�_get_system_sitepackagesrZPsT���t�&�'��+�+�-��$�
�{�}�5��/;�<�|�t�B�G�G���T�"�|�<�<��<s�&A'c�,�eZdZdZ										dd�Zy)�BuildEnvironmentInstallerz]
    Interface for installing build dependencies into an isolated build
    environment.
    c��yr3r.)rC�requirementsr;�kind�for_reqs     r0�installz!BuildEnvironmentInstaller.installjs��r/N�
r^�
Iterable[str]r;r8r_rFr`�InstallRequirement | NonerGrH)r*r+r,�__doc__rar.r/r0r\r\ds<���
�#����
��+�
�
�r/r\c�P�eZdZdZ		d							dd�Zdd�Z										d	d�Zy)
�#SubprocessBuildEnvironmentInstallerzD
    Install build dependencies by calling pip in a subprocess.
    Nc�6�||_|xsg|_||_yr3)�finder�_build_constraints�!_build_constraint_feature_enabled)rCri�build_constraints� build_constraint_feature_enableds    r0rEz,SubprocessBuildEnvironmentInstaller.__init__ys �����"3�"9�r���1Q��.r/c��|js|jrytjj	d�}|r|j�syt
dddd��y)z�
        Check for deprecation warning: PIP_CONSTRAINT affecting build environments.

        This warns when build-constraint feature is NOT enabled and PIP_CONSTRAINT
        is not empty.
        N�PIP_CONSTRAINTzGSetting PIP_CONSTRAINT will not affect build constraints in the future,z�to specify build constraints using --build-constraint or PIP_BUILD_CONSTRAINT. To disable this warning without any build constraints set --use-feature=build-constraint or PIP_USE_FEATURE="build-constraint"z26.2)�reason�replacement�gone_in�issue)rkrjrP�environ�get�stripr)rC�pip_constraints  r0�_deprecation_constraint_checkzASubprocessBuildEnvironmentInstaller._deprecation_constraint_check�sV���1�1�T�5L�5L�������(8�9���^�%9�%9�%;���3�5�
��
	
r/c��|j�|j}tjt	�dddd|j
ddddd	g}tj�tjkr|jd
�n,tj�tkr|jd�dD][}t|j|�}|jd
|jdd�zdj!t#|xsdh��f��]|j$�H|j$j'�D]+\}	}
|jd
|	jdd�z|
f��-|j(}|r4|jd|dg�|ddD]}|jd|g��n|jd�|j*D]}
|jd|
g��|j,r|jd|j,g�|j.D]}|jd|g��|j0r|jd|j0g�|j2r|jd|j2g�|j4r|jd�|j6r|jddg�|j8r7|j8D](}|jd|g�|jd |g��*i}|j6r|j8sd!d"d#ii}|j:r+|jd$|j:j=�g�|jd
�|j|�|r|j>rd%|j>��nd	}tAd&|���5}tC|fd'|�|��|d(�|��ddd�y#1swYyxYw))Nraz--ignore-installedz	--no-userz--prefixz--no-warn-script-locationz--disable-pip-version-checkz--no-compilez--targetr:z-vvz-v)�	no_binary�only_binaryz--�_�-�,z:none:z-ir�z--extra-index-urlz
--no-indexz--find-linksz--proxyz--trusted-hostz--certz
--client-certz--prefer-binaryz
--use-featurezbuild-constraintz--constraintz--build-constraintr)� _PIP_IN_BUILD_IGNORE_CONSTRAINTS�1z--uploaded-prior-toz for �Installing zinstalling )�command_desc�spinner)"rxri�sys�
executablerSr<�logger�getEffectiveLevel�logging�DEBUG�appendr�getattr�format_control�extend�replace�join�sorted�release_control�get_ordered_args�
index_urls�
find_links�proxy�
trusted_hosts�custom_cert�client_cert�
prefer_binaryrkrj�uploaded_prior_to�	isoformat�namerr)rCr^r;r_r`ri�argsr��formats�	attr_name�valuer��extra_index�link�host�constraint_filer)�identify_requirementr�s                   r0raz+SubprocessBuildEnvironmentInstaller.install�s~��	
�*�*�,������N�N���� ����K�K�'�)�
�
��#
��&�#�#�%����6��K�K���
�
%�
%�
'�7�
2��K�K���:�N��f�3�3�^�D�G��K�K��>�1�1�#�s�;�;��H�H�V�G�$9��z�:�;��
�;��!�!�-�%+�$:�$:�$K�$K�$M� �	�5����T�I�$5�$5�c�3�$?�?��G�H�%N��&�&�
���K�K��z�!�}�-�.�)�!�"�~�����0�+�>�?� .�
�K�K��%��%�%�D��K�K���.�/�&��<�<��K�K��F�L�L�1�2��(�(�D��K�K�)�4�0�1�)�����K�K��6�#5�#5�6�7�����K�K��&�*<�*<�=�>�����K�K�)�*��1�1��K�K��*<�=�>��"�"�$(�#:�#:�����^�_�=�>����1�?�C�D�$;�')�
��1�1�$�:Q�:Q�-�/Q�SV�.W�X�M��#�#��K�K�.��0H�0H�0R�0R�0T�U�V����D�����L�!�'.�'�,�,�e�G�L�L�>�"�B�	��K��v�.�
/�7���
�*�4�&�1E�0F�G��
� �	
�0�
/�
/�s�N;�;O)NF)rir#rlzlist[str] | Nonerm�boolrGrH�rGrHrb)r*r+r,rerErxrar.r/r0rgrgts���/3�16�	R��R�,�R�+/�	R�

�R�
�:g�#�g��g�
�g�+�
g�
�gr/rgc�b�eZdZdZddd�											d
d�Z										dd�Zdd�Zd
d�Zy	)�"InprocessBuildEnvironmentInstallera
    Build dependency installer that runs in the same pip process.

    This contains a stripped down version of the install command with
    only the logic necessary for installing build dependencies. The
    finder, session, build tracker, and wheel cache are reused, but new
    instances of everything else are created as needed.

    Options are inherited from the parent install command unless
    they don't make sense for build dependencies (in which case, they
    are hard-coded, see comments below).
    r.r)rl�	verbosityc���ddlm}||_||_||_d|_t
dd��}||||jj|j||ddddddddd�	�|_
y)
Nr)�RequirementPreparerzbuild-env-installT�r_�globally_managedr:F�off)�build_isolation_installerri�session�	build_dir�
build_trackerr��src_dir�download_dir�build_isolation�check_build_deps�progress_bar�require_hashes�
use_user_site�
lazy_wheel�legacy_resolver)� pip._internal.operations.preparer��_finderrj�_wheel_cache�_levelr �_link_collectorr�r<�	_preparer)rCrir��wheel_cacherlr�r�r�s        r0rEz+InprocessBuildEnvironmentInstaller.__init__s~��	I����"3���'������!�':�T�R�	�,�&*���*�*�2�2��n�n�'���� �"��!���!�)
��r/c�"�tjt�xr|jdk(}|rt	�}td|���}n3t
t��t
�}}tjd|�	|xjdz
c_|5|5}|j||�ddd�ddd�|xjdzc_y#1swY�'xYw#1swY�+xYw#t$ry}	tjtjj���tjd|	ddi�	�tjd
�t|||	d���d}	~	wt $r�}	tjj��j#�}
|s>d}
t%|	t&�rtjd|	�ntj)d�t|||	|
���d}	~	wwxYw#|xjdzc_wxYw)
z@Install entrypoint. Manages output capturing and error handling.rr�zInstalling %s ...rNz%s�richT)�extrar:)�cause�	log_lineszpip crashed unexpectedly)r��isEnabledForrr�rrrr	�info�
_install_implr�textwrap�dedent�getvalue�errorr�	Exception�
splitlines�
isinstancer�	exception)rCr^r;r_r`�capture_logs�capture_ctxr��stream�exc�logss           r0raz*InprocessBuildEnvironmentInstaller.install@s���"�.�.�w�7�7�L�D�K�K�1�<L���5D�4E�K�,=��D�6�>R�,S�G�$/�x�z�#:�K�M��K��K�K�+�T�2�	��K�K�1��K��+���"�"�<��8�&��8
�K�K�1��K�9&�+�����"�	�
�K�K�������(9�:�;��L�L��s�6�4�.�L�9��K�K��O�-���S�D��
���	�%-�_�_�V�_�_�5F�%G�%R�%R�%T�D�����c�8�,��L�L��s�+��$�$�%?�@�-���S�D��
��	��
�K�K�1��K�sb�;C&�C�C�(C�0C&�C	�C�C#�C&�&	G4�/A4E#�#G4�/BG/�/G4�4G7�7Hc
��ddlm}ddlm}ddlm}ddlm}|D�cgc]}||d����}}|j|j�|j�}	|	j|d��}
|jj|
jj��|
j D�cgc]}|j"r�|��}}|||j$d�	�\}
}|rt'|��||	j)|
�|j*d
d
dddd�
�}t-t/|j0��}|||�x}rt2j5|�y
y
cc}wcc}w)z$Core build dependency install logic.r)�installed_packages_summary)�install_given_reqs)�install_req_from_line)�buildT)�
user_supplied)�check_supported_wheels)�verifyNFr�)r;�root�home�warn_script_locationr��	pycompiler�)�pip._internal.commands.installr��pip._internal.reqr��pip._internal.req.constructorsr��pip._internal.wheel_builderr�r�rj�_make_resolverrMr�� prepare_linked_requirements_morer^�values�requirements_to_install�is_wheelr�r�get_installation_orderr<r�listrBr�r�)rCr^r;r�r�r�r��req�ireqs�resolver�resolved_set�r�
reqs_to_buildr|�build_failures�	installed�env�summarys                  r0r�z0InprocessBuildEnvironmentInstaller._install_impltsN��M�8�H�5�KW�X�<�C�&�s�$�?�<��X�
���T�,�,�-��&�&�(���'�'��d�'�K�����7�7��%�%�,�,�.�	
�
$�;�;�
�;�!�1�:�:�A�;�	�
�"�-��1B�1B�4�P���>��(��8�8�&��+�+�L�9��;�;���!&����
�	��d�6�?�?�3�4��0��C�@�@�7�@��K�K�� �A��?Y��
s�E�/E�Ec
�|�ddlm}ddlm}|||j|j
|jddddddd��S)	z'Create a new resolver for one time use.r)�install_req_from_req_string)�ResolverFTzto-satisfy-onlyN)�make_install_req�preparerrir��ignore_requires_pythonr��ignore_dependencies�ignore_installed�force_reinstall�upgrade_strategy�py_version_info)r�r��,pip._internal.resolution.resolvelib.resolverr�r�r�r�)rCr�r�s   r0r�z1InprocessBuildEnvironmentInstaller._make_resolver�sG��	O�I��8��^�^��<�<��)�)�#(�� %�!�!�.� �
�	
r/N)rir#r�r$r�r"rlzSequence[InstallRequirement]r��intrGrHrb)r^rcr;r8rGrH)rGr&)r*r+r,rerErar�r�r.r/r0r�r�
s����&;=��&
��&
�$�	&
�
 �&
�8�
&
��&
�
�&
�P2�#�2��2�
�2�+�
2�
�2�h'!�R
r/r�c�h�eZdZdZd	d�Zd
d�Z								dd�Z				dd�Zdd�									d
d�Zy)�BuildEnvironmentzACreates and manages an isolated environment to install build depsc���||_ttjd���t	�fd�dD��|_g|_g|_tt|j
j���D]L}|jj|j�|jj|j��Nt�}t j"j%�j"d�|_t j"j)|j&�st!j*|j&�t-t j"j%|j&d�dd�	�5}|j/t1j2d
�j5||j���ddd�y#1swYyxYw)NTr�c3��K�|]9}|ttjj�j|��f���;y�wr3)r8rPr<r�)�.0r��temp_dirs  �r0�	<genexpr>z,BuildEnvironment.__init__.<locals>.<genexpr>�s6�����%
�-���7�2�7�7�<�<��
�
�t�<�=�>�-�s�?A)�normal�overlayrWzsitecustomize.py�wzutf-8)�encodinga�
                import os, site, sys

                # First, drop system-sites related paths.
                original_sys_path = sys.path[:]
                known_paths = set()
                for path in {system_sites!r}:
                    site.addsitedir(path, known_paths=known_paths)
                system_paths = set(
                    os.path.normcase(path)
                    for path in sys.path[len(original_sys_path):]
                )
                original_sys_path = [
                    path for path in original_sys_path
                    if os.path.normcase(path) not in system_paths
                ]
                sys.path = original_sys_path

                # Second, add lib directories.
                # ensuring .pth file are processed.
                for path in {lib_dirs!r}:
                    assert not path in sys.path
                    site.addsitedir(path)
                )rYrB)�	installerr r!�	BUILD_ENVr�	_prefixes�	_bin_dirs�	_lib_dirs�reversedr�r�r�r?r�rBrZrPr<r��	_site_dir�exists�mkdir�open�writer�r��format)rCrr;rY�fpr
s     @r0rEzBuildEnvironment.__init__�sB���"��� �m�&=�&=�PT�U��$�%
�-�%
�
���
%'���$&����t�D�N�N�$9�$9�$;�<�=�F��N�N�!�!�&�.�.�1��N�N�!�!�&�/�/�2�>�0�1�������h�m�m�V�<����w�w�~�~�d�n�n�-��H�H�T�^�^�$�
��G�G�L�L����);�<�c�G�
�
��H�H������2�&�l�T�^�^�&�L�5
�
�
�
�s
�=AG�Gc���dD�cic]#}|tjj|d���%c}|_|jdd}|jd}|r.|j|j
tj��|jg}tjjtjj|�dtjj|�d��ycc}w)N)�PATH�PYTHONNOUSERSITE�
PYTHONPATHr!r�)rPrtru�	_save_envrr��split�pathsepr�updater�)rCr�r<�old_path�
pythonpaths     r0�	__enter__zBuildEnvironment.__enter__�s���C�
�B��
�"�*�*�.�.��t�,�,�B�
���
�~�~�a� ���>�>�&�)����K�K����r�z�z�2�3��n�n�%�
�
�
�
����
�
����-�$'� �j�j�o�o�j�9�
�	
��
s�(C.c��|jj�D];\}}|�!tjj	|d��)|tj|<�=yr3)r$�itemsrPrt�pop)rC�exc_type�exc_val�exc_tb�varname�	old_values      r0�__exit__zBuildEnvironment.__exit__sF��#'�.�.�"6�"6�"8��G�Y�� ��
�
���w��-�&/��
�
�7�#�	#9r/c�|�t�}t�}|�r"t|d�rt|j�n	t	�}|D]�}t|�}|j�|jjddi�s�8|j|j�}|s|j|��gt|jt�r|j�d|j��}n|j�d|j��}|jj|jd��r��|j||f���||fS)z�Return 2 sets:
        - conflicting requirements: set of (installed, wanted) reqs tuples
        - missing requirements: set of reqs
        rr�r:z==z===T)�prereleases)�setrVrrrr�marker�evaluate�get_distributionr��addr��versionr�	specifier�contains)	rC�reqs�missing�conflictingr��req_strr��dist�installed_req_strs	         r0�check_requirementsz#BuildEnvironment.check_requirementss���%���e����4��-� ����/�,�.�
�
 ��%�g�.���:�:�)�#�*�*�2E�2E�w�PR�m�2T���+�+�C�H�H�5����K�K��(���d�l�l�G�4�+.�8�8�*�B�t�|�|�n�(E�%�+.�8�8�*�C����~�(F�%��}�}�-�-�d�l�l��-�M��O�O�%6��$@�A� �"�G�#�#r/N�r`c��|j|}|jrJ�d|_|sy|jj||||��y)NT)r_r`)rr=rra)rCr^�prefix_as_stringr_r`r;s      r0�install_requirementsz%BuildEnvironment.install_requirements2sH����� 0�1���<�<�������������|�V�$���Pr/)rr\rGrHr��r.ztype[BaseException] | Noner/zBaseException | Noner0zTracebackType | NonerGrH)r>rcrGz%tuple[set[tuple[str, str]], set[str]]�
r^rcrGrFr_rFr`rdrGrH)	r*r+r,rerEr*r3rDrHr.r/r0r	r	�s���K�5�n
�*
0�,�
0�&�
0�%�	
0�

�
0� $�!� $�	.� $�P.2�

Q�#�
Q��
Q�
�
Q�+�

Q�
�
Qr/r	c�`�eZdZdZd	d�Zd	d�Z								d
d�Zd	d�Zdd�									dd�Zy)�NoOpBuildEnvironmentz0A no-op drop-in replacement for BuildEnvironmentc��yr3r.�rCs r0rEzNoOpBuildEnvironment.__init__E���r/c��yr3r.rNs r0r*zNoOpBuildEnvironment.__enter__HrOr/c��yr3r.)rCr.r/r0s    r0r3zNoOpBuildEnvironment.__exit__Ks��	
r/c��yr3r.rNs r0�cleanupzNoOpBuildEnvironment.cleanupSrOr/NrEc��t��r3)�NotImplementedError)rCr^rGr_r`s     r0rHz)NoOpBuildEnvironment.install_requirementsVs
��"�#�#r/r�rIrJ)	r*r+r,rerEr*r3rSrHr.r/r0rLrLBsy��:�
�
�
�,�
�&�
�%�	
�

�
�
�.2�
$�#�$��$�
�$�+�
$�
�$r/rL)r4rFr5rFrGztuple[str] | tuple[str, str])rGrF)rGzset[str])Qre�
__future__rr�rPrJrWr�r��collectionsr�collections.abcrr�
contextlibr�ContextManagerr�ior	�typesr
�typingrrr
�pip._vendor.packaging.versionr�piprrL�pip._internal.cli.spinnersrr�pip._internal.exceptionsrrrr�pip._internal.locationsrrr�pip._internal.metadatarr�pip._internal.utils.deprecationr�pip._internal.utils.loggingrr�pip._internal.utils.packagingr�pip._internal.utils.subprocessr�pip._internal.utils.temp_dirr r!�pip._internal.cacher"�"pip._internal.index.package_finderr#�,pip._internal.operations.build.build_trackerr$�pip._internal.req.req_installr%�pip._internal.resolution.baser&r(�	getLoggerr*r�r6r8rSrZr\rgr�r	rLr.r/r0�<module>ros���@�"��	���
��#�.�?�"���5�5�1�(�F���I�H�K�6�@�9�:�E��.�@�I�@�:�&�y��&�
��	�	�8�	$��&�?�?�
5� =�(
��
� S�S�lh
�h
�VJQ�JQ�Z$�+�$r/
Back to Directory File Manager