Viewing File: /opt/hc_python/lib/python3.12/site-packages/build/__pycache__/_builder.cpython-312.pyc

�

i0i�4��,�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZmZddlZddlmZmZddlmZddlmZmZmZmZdd	lmZmZmZmZdd
l m!Z!m"Z"edd�
�Z#ddgd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)Gd�d�Z*y)�)�annotationsN)�Iterator�Mapping�Sequence)�Any�TypeVar�)�_ctx�env)�tomllib)�BuildBackendException�BuildException�BuildSystemTableValidationError�TypoWarning)�ConfigSettings�Distribution�StrPath�SubprocessRunner)�check_dependency�parse_wheel_filename�_TProjectBuilder�ProjectBuilder)�boundz setuptools.build_meta:__legacy__zsetuptools >= 40.8.0)�
build-backend�requiresc��|D]N}tjd||�j�dk\s�,tjd|�d|�d�t
d���Py)Ng�������?zFound 'z#' in pyproject.toml, did you mean 'z'?�)�
stacklevel)�difflib�SequenceMatcher�ratio�warnings�warnr)�
dictionary�expected�objs   �=/opt/hc_python/lib/python3.12/site-packages/build/_builder.py�
_find_typor('sQ�����"�"�4��3�7�=�=�?�3�F��M�M��#��A�(��2�N���
��c��tjj|�sd|�d�}t|��tjj	|d�}tjj	|d�}tjj|�s1tjj|�sd|�d�}t|��yy)NzSource z is not a directory�pyproject.tomlzsetup.pyzF does not appear to be a Python project: no pyproject.toml or setup.py)�os�path�isdirr�join�exists)�
source_dir�msg�pyproject_toml�setup_pys    r'�_validate_source_directoryr51s���
�7�7�=�=��$��
�|�#6�7���S�!�!��W�W�\�\�*�.>�?�N��w�w�|�|�J�
�3�H�
�7�7�>�>�.�)�"�'�'�.�.��2J��
�|�#i�j���S�!�!�3K�)r)c��	t|d�5}tj|j�j	��cddd�S#1swYyxYw#t
$ricYSt$r-}|j�d|j�d�}t|�d�d}~wtj$r}d|�d|�d�}t|�d�d}~wwxYw)N�rbz: 'z' zFailed to parse z: � )�openr�loads�read�decode�FileNotFoundError�PermissionError�strerror�filenamer�TOMLDecodeError)r-�f�er2s    r'�_read_pyproject_tomlrD<s���
,�
�$��
���=�=�������!2�3��
�
�����	��,�����C��
�
�|�2�.���S�!�t�+���"�"�,� ���b���1�-���S�!�t�+��,�sE�A�1A	�	A�	A�A�A�C�"C�*(B�C�(B=�=Cc�J�d|vrt|d�tSt|d�}d|vrt|d�d}t|��t	|dt
�rt
d�|dD��s
d}t|��d|vrt|d�td|d<n t	|dt�s
d}t|��d|vr5t	|dt
�rt
d	�|dD��s
d
}t|��|j�hd�z
}|rdd
j|���}t|��|S)Nzbuild-systemrz!`requires` is a required propertyc3�<K�|]}t|t����y�w�N��
isinstance�str��.0�is  r'�	<genexpr>z,_parse_build_system_table.<locals>.<genexpr>Xs����I�$B�q�
�1�c��$B���z&`requires` must be an array of stringsrz `build-backend` must be a string�backend-pathc3�<K�|]}t|t����y�wrGrHrKs  r'rNz,_parse_build_system_table.<locals>.<genexpr>is����R�/Q�!�:�a��%�/Q�rOz*`backend-path` must be an array of strings>rrPrzUnknown properties: z, )
r(�_DEFAULT_BACKEND�dictrrI�list�allrJ�keysr/)r3�build_system_tabler2�
unknown_propss    r'�_parse_build_system_tablerYJsQ���^�+��>�>�2����n�^�<�=���+�+��%�z�2�1��-�c�2�2�
�*�:�6��
=�S�I�$6�z�$B�I�F�7��-�c�2�2��0�0��%��7�/?��.O��?�+�
�*�?�;�S�
A�0��-�c�2�2��+�+��)�.�9�4�@��R�/A�.�/Q�R�R�:��-�c�2�2�&�+�+�-�0]�]�M��$�T�Y�Y�}�%=�$>�?��-�c�2�2��r)c�*���	d							d��fd�
}|S)Nc�P���||i�j�xsi�|xsi��yrG)�make_extra_environ)�cmd�cwd�
extra_environr�runners   ��r'�_invoke_wrapped_runnerz7_wrap_subprocess_runner.<locals>._invoke_wrapped_runnerws3���	�s�C�V�3�S�3�3�5�;��V��AT�RT�V�Wr)�NN)r]z
Sequence[str]r^�
str | Noner_zMapping[str, str] | None�return�None�)r`rras`` r'�_wrap_subprocess_runnerrgvs8���^b�X�
�X�!+�X�C[�X�	
�X�
"�!r)c�x�eZdZdZej
ejf							dd�Ze	ejf									dd��Z
edd��Zedd��Z
edd��Z	d					dd�Z	d					dd	�Z	d							dd
�Z		d									dd�Zdd�Z	d									dd
�Zej,dd��Zy)rz#
    The PEP 517 consumer API.
    c���tjj|�|_t	|�||_||_tjj|d�}tt|��|_
|jd|_tj|j|j|jjd�|j
|j��|_y)aA
        :param source_dir: The source directory
        :param python_executable: The python executable where the backend lives
        :param runner: Runner for backend subprocesses

        The ``runner``, if provided, must accept the following arguments:

        - ``cmd``: a list of strings representing the command and arguments to
          execute, as would be passed to e.g. 'subprocess.check_call'.
        - ``cwd``: a string representing the working directory that must be
          used for the subprocess. Corresponds to the provided source_dir.
        - ``extra_environ``: a dict mapping environment variable names to values
          which must be set for the subprocess execution.

        The default runner simply calls the backend hooks in a subprocess, writing backend output
        to stdout/stderr.
        r+rrP)�backend_path�python_executabler`N)r,r-�abspath�_source_dirr5�_python_executable�_runnerr/rYrD�
_build_system�_backend�pyproject_hooks�BuildBackendHookCaller�get�_hook)�selfr1rkr`�pyproject_toml_paths     r'�__init__zProjectBuilder.__init__�s���.!#�����
� ;���"�:�.�"3������ �g�g�l�l�:�7G�H��6�7K�L_�7`�a����*�*�?�;��
�$�;�;�����M�M��+�+�/�/��?�"�5�5��<�<�
��
r)c�@�|||jt||���S)N)r1rkr`)rkrg)�clsrr1r`s    r'�from_isolated_envz ProjectBuilder.from_isolated_env�s'���!�!�3�3�*�6�3�7�
�	
r)c��|jS)zProject source directory.)rm�rvs r'r1zProjectBuilder.source_dir�s�����r)c��|jS)zC
        The Python executable used to invoke the backend.
        )rnr}s r'rkz ProjectBuilder.python_executable�s��
�&�&�&r)c�2�t|jd�S)z�
        The dependencies defined in the ``pyproject.toml``'s
        ``build-system.requires`` field or the default build dependencies
        if ``pyproject.toml`` is missing or ``build-system`` is undefined.
        r)�setrpr}s r'�build_system_requiresz$ProjectBuilder.build_system_requires�s���4�%�%�j�1�2�2r)Nc���tjd|�d��d|��}t|j|�}|j	|�5t||��cddd�S#1swYyxYw)a@
        Return the dependencies defined by the backend in addition to
        :attr:`build_system_requires` for a given distribution.

        :param distribution: Distribution to get the dependencies of
            (``sdist`` or ``wheel``)
        :param config_settings: Config settings for the build backend
        zGetting build dependencies for �...�get_requires_for_build_N)r
�log�getattrru�_handle_backendr�)rv�distribution�config_settings�	hook_name�get_requiress     r'�get_requires_for_buildz%ProjectBuilder.get_requires_for_build�s]��	
���2�<�.��D�E�-�l�^�<�	��t�z�z�9�5��
�
!�
!�)�
,��|�O�4�5�-�
,�
,�s�A!�!A*c��|j||�j|j�}|D��chc]}t|�D]}|���c}}Scc}}w)a�
        Return the dependencies which are not satisfied from the combined set of
        :attr:`build_system_requires` and :meth:`get_requires_for_build` for a given
        distribution.

        :param distribution: Distribution to check (``sdist`` or ``wheel``)
        :param config_settings: Config settings for the build backend
        :returns: Set of variable-length unmet dependency tuples
        )r��unionr�r)rvr�r��dependencies�d�us      r'�check_dependenciesz!ProjectBuilder.check_dependencies�sO���2�2�<��Q�W�W�X\�Xr�Xr�s��'�E�<�a�1A�!�1D�A��1D��<�E�E��Es�Ac���tjd|�d��	|jd|��||d��S#t$r/}t	|j
tj�rYd}~y�d}~wwxYw)aR
        Prepare metadata for a distribution.

        :param distribution: Distribution to build (must be ``wheel``)
        :param output_directory: Directory to put the prepared metadata in
        :param config_settings: Config settings for the build backend
        :returns: The full path to the prepared metadata directory
        zGetting metadata for r��prepare_metadata_for_build_F)�_allow_fallbackN)r
r��
_call_backendr
rI�	exceptionrr�HookMissing)rvr��output_directoryr�r�s     r'�preparezProjectBuilder.prepare�sx��	
���(���c�:�;�
	��%�%�-�l�^�<� �� %�	&��
��%�	��)�-�-��/J�/J�K����	�s�3�	A+�$A&�%A&�&A+c�t�tjd|�d��|�ind|i}|jd|��||fi|��S)a�
        Build a distribution.

        :param distribution: Distribution to build (``sdist`` or ``wheel``)
        :param output_directory: Directory to put the built distribution in
        :param config_settings: Config settings for the build backend
        :param metadata_directory: If provided, should be the return value of a
            previous ``prepare`` call on the same ``distribution`` kind
        :returns: The full path to the built distribution
        z	Building r��metadata_directory�build_)r
r�r�)rvr�r�r�r��kwargss      r'�buildzProjectBuilder.buildsQ��"	
���9�\�N�#�.�/�)�1��8L�N`�7a��!�t�!�!�F�<�.�"9�;K�_�g�`f�g�gr)c����|jd|�}|�|S|jd|�}ttjj|��}|s
d}t
|��|d�d|d�d�}|�d��tj|�5}|j|�fd	�|j�D��ddd�tjj||�S#1swY�)xYw)
a
        Generate the metadata directory of a distribution and return its path.

        If the backend does not support the ``prepare_metadata_for_build_wheel``
        hook, a wheel will be built and the metadata will be extracted from it.

        :param output_directory: Directory to put the metadata distribution in
        :returns: The path of the metadata directory
        �wheelNz
Invalid wheelr��-�versionz
.dist-info�/c3�F�K�|]}|j��s�|���y�wrG)�
startswith)rL�member�
member_prefixs  �r'rNz/ProjectBuilder.metadata_path.<locals>.<genexpr>?s�����W�l�F�f�6G�6G�
�6V��l�s�!�!)r�r�rr,r-�basename�
ValueError�zipfile�ZipFile�
extractall�namelistr/)	rvr��metadatar��matchr2�distinfo�wr�s	        @r'�
metadata_pathzProjectBuilder.metadata_path%s�����<�<��)9�:�����O��
�
�7�$4�5��$�R�W�W�%5�%5�e�%<�=���!�C��S�/�!��N�+�,�A�e�I�.>�-?�z�J��#�*�A��
�
�_�_�U�
#�q�
�L�L� �W�a�j�j�l�W�
�$�
�w�w�|�|�,�h�7�7�$�
#�s�	*C�C$c���tjj|�}t|j|�}tjj|�r0tjj
|�s&d|�d�}t|��tj|�|j|�5|||fi|��}ddd�tjj|�S#1swY�)xYw)NzBuild path 'z' exists and is not a directory)r,r-rlr�rur0r.r�makedirsr�r/)rvr��outdirr�r��callbackr2r�s        r'r�zProjectBuilder._call_backendCs���������(���4�:�:�y�1��
�7�7�>�>�&�!��7�7�=�=��(�$�V�H�,K�L��$�S�)�)��K�K���
�
!�
!�)�
,�$�V�_�G��G�H�-��w�w�|�|�F�H�-�-�-�
,�s�+C�C'c#�LK�	d��y#tj$r3}t|d|j�d�t	j
��d�d}~wtj$r}t|d|���d�d}~wt$r%}t|t	j
���d�d}~wwxYw�w)Nz	Backend 'z' is not available.z0Backend subprocess exited when trying to invoke )�exc_info)	rr�BackendUnavailabler
rq�sysr��
subprocess�CalledProcessError�	Exception)rv�hookr�s   r'r�zProjectBuilder._handle_backendVs�����	V����1�1�	�'���D�M�M�?�*=�>�������	
��
�,�,�	x�'�	�5e�fj�ek�3l�m�sw�w���	V�'�	�C�L�L�N�K�QU�U��	V�s<�B$�	�B$�B!�.A
�
B!� A0�0B!�< B�B!�!B$)r1rrkrJr`rrdre)
rzztype[_TProjectBuilder]r�env.IsolatedEnvr1rr`rrdr)rdrJ)rd�set[str]rG)r�rr��ConfigSettings | Nonerdr�)r�rr�r�rdzset[tuple[str, ...]])r�rr�rr�r�rdrcrb)
r�rr�rr�r�r�rcrdrJ)r�rrdrJ)
r�rJr�rr�r�r�rrdrJ)r�rJrdzIterator[None])�__name__�
__module__�__qualname__�__doc__r��
executablerr�default_subprocess_runnerrx�classmethodr{�propertyr1rkr�r�r�r�r�r�r��
contextlib�contextmanagerr�rfr)r'rrs����"%���#2�#L�#L�	(
��(
��(
�!�	(
�

�(
�T�
$3�#L�#L�	

�
#�

�
�

��

�!�	

�

�

��

�� �� ��'��'��3��3�26�6�"�6�/�6�
�	6�.26�F�"�F�/�F�
�	F�*26�	�"��"��/�	�

��>26�)-�h�"�h�"�h�/�	h�
'�h�

�
h�*8�>Y]�.��.�&-�.�@U�.�hk�.�	�.�&���V��Vr))r$zMapping[str, str]r%rJrdre)r1rrdre)r-rrd�Mapping[str, Any])r3r�rdr�)r`rrr�rdr)+�
__future__rr�rr,r�r�r"r��collections.abcrrr�typingrrrr�r
r�_compatr�_exceptionsr
rrr�_typesrrrr�_utilrrrrRr(r5rDrYrgrrfr)r'�<module>r�s���#���	��
���7�7�������L�K�9��-�5E�F��8�'�(����"�,�)�X"�dV�dVr)
Back to Directory File Manager