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

�

h0iX:�
���ddlZddlZddlZddlZddlmZddlmZddlmZ	ddl
mZmZm
Z
ddlmZmZmZmZmZmZddlmZerdd	lmZGd
�de�Zdeeefd
eddfd�Zd
edeeeffd�ZGd�de�ZGd�de�ZGd�de�Z		d!deedeedeeeefddfd�Z 		d!deedeedeeeefddfd�Z!dededefd�Z"Gd�d �Z#y)"�N)�contextmanager)�abspath)�join)�STDOUT�
check_call�check_output)�
TYPE_CHECKING�Any�Iterator�Mapping�Optional�Sequence�)�_in_proc_script_path)�Protocolc
�J�eZdZdZ		ddeedeedeeeefddfd�Zy)	�SubprocessRunnerz%A protocol for the subprocess runner.N�cmd�cwd�
extra_environ�returnc��y�N�)�selfrrrs    �D/opt/hc_python/lib/python3.12/site-packages/pyproject_hooks/_impl.py�__call__zSubprocessRunner.__call__s��
��NN)	�__name__�
__module__�__qualname__�__doc__r�strr
rrrrrrrsN��3�
"&�9=�		��#��	��#��	�$�G�C��H�$5�6�		�
�	rr�obj�pathrc�x�t|dd��5}tj||fi|��ddd�y#1swYyxYw)N�w�utf-8��encoding)�open�json�dump)r%r&�kwargs�fs    r�
write_jsonr1s/��	
�d�C�'�	*�a��	�	�#�q�#�F�#�
+�	*�	*�s�0�9c�r�t|d��5}tj|�cddd�S#1swYyxYw)Nr)r*)r,r-�load)r&r0s  r�	read_jsonr4!s%��	
�d�W�	%���y�y��|�
&�	%�	%�s�-�6c�X��eZdZdZ			d	dedeedeedeeeddf
�fd�
Z�xZS)
�BackendUnavailablezEWill be raised if the backend cannot be imported in the hook process.N�	traceback�message�backend_name�backend_pathrc�V��||_||_||_t�|�|xsd�y)NzError while importing backend)r9r:r7�super�__init__)rr7r8r9r:�	__class__s     �rr=zBackendUnavailable.__init__)s/���)���(���"���
����C�$C�Dr�NNN)	r r!r"r#r$r
rr=�
__classcell__�r>s@rr6r6&sc���O�
"&�&*�04�E��E��#��E��s�m�	E�
�x��}�-�E�
�
E�Err6c�,��eZdZdZdeddf�fd�Z�xZS)�HookMissingz>Will be raised on missing hooks (if a fallback can't be used).�	hook_namerNc�2��t�|�|�||_yr)r<r=rD)rrDr>s  �rr=zHookMissing.__init__:s���
����#�"��r)r r!r"r#r$r=r@rAs@rrCrC7s���H�#�#�#�$�#�#rrCc� �eZdZdZdeddfd�Zy)�UnsupportedOperationzDMay be raised by build_sdist if the backend indicates that it can't.r7rNc��||_yr)r7)rr7s  rr=zUnsupportedOperation.__init__Bs	��"��r)r r!r"r#r$r=rrrrGrG?s��N�#�#�#�$�#rrGrrrc��tjj�}|r|j|�t	|||��y)zwThe default method of calling the wrapper subprocess.

    This uses :func:`subprocess.check_call` under the hood.
    )r�envN)�os�environ�copy�updater�rrrrJs    r�default_subprocess_runnerrPFs/��
�*�*�/�/�
�C���
�
�=�!��s���%rc��tjj�}|r|j|�t	|||t
��y)zqCall the subprocess while suppressing output.

    This uses :func:`subprocess.check_output` under the hood.
    )rrJ�stderrN)rKrLrMrNrrrOs    r�quiet_subprocess_runnerrSVs1��
�*�*�/�/�
�C���
�
�=�!���#�3�v�6r�source_tree�	requestedc���tjj|�rtd��tjj	|�}tjjtjj
||��}tjj|�}tjj|�}tjj||g�|k7rtd��|S)z�Normalise and check a backend path.

    Ensure that the requested backend path is specified as a relative path,
    and resolves to a location under the given source tree.

    Return an absolute version of the requested path.
    zpaths must be relativez paths must be inside source tree)	rKr&�isabs�
ValueErrorr�normpathr�normcase�commonprefix)rTrU�
abs_source�
abs_requested�norm_source�norm_requesteds      r�norm_and_checkr`fs���
�w�w�}�}�Y���1�2�2�������-�J��G�G�$�$�R�W�W�\�\�*�i�%H�I�M��'�'�"�"�:�.�K��W�W�%�%�m�4�N�	�w�w���[�.�9�:�k�I��;�<�<��rc
��eZdZdZ			ddededeeededdeed	dfd
�Zeddd	e	dfd��Z
d	eefd�Z	dd
eeee
fd	eefd�Z		dded
eeee
fded	efd�Z		d ded
eeee
fdeed	efd�Z	dd
eeee
fd	eefd�Z		dded
eeee
fded	eefd�Z		d ded
eeee
fdeed	efd�Z	dd
eeee
fd	eefd�Z	dded
eeee
fd	efd�Zdedeee
fd	e
fd�Zy)!�BuildBackendHookCallerzAA wrapper to call the build backend hooks for a source directory.N�
source_dir�
build_backendr:�runnerr�python_executablerc���|�t}t|�|_||_|r#|D�cgc]}t	|j|���}}||_||_|stj}||_	ycc}w)a�
        :param source_dir: The source directory to invoke the build backend for
        :param build_backend: The build backend spec
        :param backend_path: Additional path entries for the build backend spec
        :param runner: The :ref:`subprocess runner <Subprocess Runners>` to use
        :param python_executable:
            The Python executable used to invoke the build backend
        N)
rPrrcrdr`r:�_subprocess_runner�sys�
executablerf)rrcrdr:rerf�ps       rr=zBuildBackendHookCaller.__init__�so�� �>�.�F�!�*�-���*����HT�U��1�N�4�?�?�A�>��L�U�(���"(��� � #����!2����Vs�A-c#�bK�|j}||_	d��||_y#||_wxYw�w)ayA context manager for temporarily overriding the default
        :ref:`subprocess runner <Subprocess Runners>`.

        :param runner: The new subprocess runner to use within the context.

        .. code-block:: python

            hook_caller = BuildBackendHookCaller(...)
            with hook_caller.subprocess_runner(quiet_subprocess_runner):
                ...
        N)rh)rre�prevs   r�subprocess_runnerz(BuildBackendHookCaller.subprocess_runner�s3�����&�&��"(���	+��&*�D�#��d�D�#�s�/�#�/�	,�/c�&�|jdi�S)z>Return the list of optional features supported by the backend.�_supported_features��
_call_hook)rs rrpz*BuildBackendHookCaller._supported_features�s�����4�b�9�9r�config_settingsc�*�|jdd|i�S)amGet additional dependencies required for building a wheel.

        :param config_settings: The configuration settings for the build backend
        :returns: A list of :pep:`dependency specifiers <508>`.

        .. admonition:: Fallback

            If the build backend does not defined a hook with this name, an
            empty list will be returned.
        �get_requires_for_build_wheelrsrq�rrss  rruz3BuildBackendHookCaller.get_requires_for_build_wheel�s �����*�->��,P�
�	
r�metadata_directory�_allow_fallbackc�@�|jdt|�||d��S)aSPrepare a ``*.dist-info`` folder with metadata for this project.

        :param metadata_directory: The directory to write the metadata to
        :param config_settings: The configuration settings for the build backend
        :param _allow_fallback:
            Whether to allow the fallback to building a wheel and extracting
            the metadata from it. Should be passed as a keyword argument only.

        :returns: Name of the newly created subfolder within
                  ``metadata_directory``, containing the metadata.

        .. admonition:: Fallback

            If the build backend does not define a hook with this name and
            ``_allow_fallback`` is truthy, the backend will be asked to build a
            wheel via the ``build_wheel`` hook and the dist-info extracted from
            that will be returned.
        � prepare_metadata_for_build_wheel�rwrsrx�rrr�rrwrsrxs    rrzz7BuildBackendHookCaller.prepare_metadata_for_build_wheel�s,��0���.�&-�.@�&A�#2�#2�
�
�	
r�wheel_directoryc�Z�|�t|�}|jdt|�||d��S)a�Build a wheel from this project.

        :param wheel_directory: The directory to write the wheel to
        :param config_settings: The configuration settings for the build backend
        :param metadata_directory: The directory to reuse existing metadata from
        :returns:
            The name of the newly created wheel within ``wheel_directory``.

        .. admonition:: Interaction with fallback

            If the ``build_wheel`` hook was called in the fallback for
            :meth:`prepare_metadata_for_build_wheel`, the build backend would
            not be invoked. Instead, the previously built wheel will be copied
            to ``wheel_directory`` and the name of that file will be returned.
        �build_wheel�r~rsrw�rrr�rr~rsrws    rr�z"BuildBackendHookCaller.build_wheel�s=��*�)�!(�);�!<������#*�?�#;�#2�&8�
�
�	
rc�*�|jdd|i�S)awGet additional dependencies required for building an editable wheel.

        :param config_settings: The configuration settings for the build backend
        :returns: A list of :pep:`dependency specifiers <508>`.

        .. admonition:: Fallback

            If the build backend does not defined a hook with this name, an
            empty list will be returned.
        �get_requires_for_build_editablersrqrvs  rr�z6BuildBackendHookCaller.get_requires_for_build_editable	s �����-�0A�?�/S�
�	
rc�@�|jdt|�||d��S)aUPrepare a ``*.dist-info`` folder with metadata for this project.

        :param metadata_directory: The directory to write the metadata to
        :param config_settings: The configuration settings for the build backend
        :param _allow_fallback:
            Whether to allow the fallback to building a wheel and extracting
            the metadata from it. Should be passed as a keyword argument only.
        :returns: Name of the newly created subfolder within
                  ``metadata_directory``, containing the metadata.

        .. admonition:: Fallback

            If the build backend does not define a hook with this name and
            ``_allow_fallback`` is truthy, the backend will be asked to build a
            wheel via the ``build_editable`` hook and the dist-info
            extracted from that will be returned.
        �#prepare_metadata_for_build_editabler{r|r}s    rr�z:BuildBackendHookCaller.prepare_metadata_for_build_editables,��.���1�&-�.@�&A�#2�#2�
�
�	
rc�Z�|�t|�}|jdt|�||d��S)a�Build an editable wheel from this project.

        :param wheel_directory: The directory to write the wheel to
        :param config_settings: The configuration settings for the build backend
        :param metadata_directory: The directory to reuse existing metadata from
        :returns:
            The name of the newly created wheel within ``wheel_directory``.

        .. admonition:: Interaction with fallback

            If the ``build_editable`` hook was called in the fallback for
            :meth:`prepare_metadata_for_build_editable`, the build backend
            would not be invoked. Instead, the previously built wheel will be
            copied to ``wheel_directory`` and the name of that file will be
            returned.
        �build_editabler�r�r�s    rr�z%BuildBackendHookCaller.build_editable;s=��,�)�!(�);�!<������#*�?�#;�#2�&8�
�
�	
rc�*�|jdd|i�S)z�Get additional dependencies required for building an sdist.

        :returns: A list of :pep:`dependency specifiers <508>`.
        �get_requires_for_build_sdistrsrqrvs  rr�z3BuildBackendHookCaller.get_requires_for_build_sdist\s �����*�->��,P�
�	
r�sdist_directoryc�>�|jdt|�|d��S)z�Build an sdist from this project.

        :returns:
            The name of the newly created sdist within ``wheel_directory``.
        �build_sdist)r�rsr|)rr�rss   rr�z"BuildBackendHookCaller.build_sdisths(������#*�?�#;�#2�
�
�	
rrDr/c
�n�d|ji}|jr.tjj	|j�}||d<tj�5}d|i}t|t|d�d��t�5}|j}|j|tt|��||g|j|��ddd�tt|d��}	|	j!d	�rt#|	j!d
d���|	j!d�rCt%|	j!d
d�|	j!d
d�|j|j���|	j!d�rt'|	j!d�xs|��|	dcddd�S#1swY��xYw#1swYyxYw)N�_PYPROJECT_HOOKS_BUILD_BACKEND�_PYPROJECT_HOOKS_BACKEND_PATHr/z
input.json�)�indent)rrzoutput.json�unsupportedr7��
no_backend�
backend_error)r8r9r:�hook_missing�missing_hook_name�
return_val)rdr:rK�pathsepr�tempfile�TemporaryDirectoryr1�pjoinrrfrhrr$rcr4�getrGr6rC)
rrDr/rr:�td�
hook_input�script�python�datas
          rrrz!BuildBackendHookCaller._call_hookzs{��9�4�;M�;M�N�
�����:�:�?�?�4�+<�+<�=�L�=I�M�9�:�
�
(�
(�
*�b�"�F�+�J��z�5��\�#:�1�E�&�'�6��/�/���'�'��W�S��[�1�9�b�A����"/�(��(��U�2�}�5�6�D��x�x�
�&�*�4�8�8�K��+D�E�E��x�x��%�(��H�H�[�"�-� �H�H�_�b�9�!%�!3�!3�!%�!2�!2�	���x�x��'�!�$�(�(�+>�"?�"L�9�M�M���%�3+�
*�
(�'��+�
*�s&�'F+�AF�CF+�F(	�$F+�+F4r?r)NTr)r r!r"r#r$r
rr=rrrnrprr
ru�boolrzr�r�r�r�r�r�rrrrrrbrb~s���K�15�/3�+/�
3��3��3��x��}�-�	3�
�+�,�3�$�C�=�
3�
�3�:�+�(:�+�x��~�+��+�&:�X�c�]�:�8<�
�!�'�#�s�(�"3�4�
�
�#��
�*8<� $�	
��
�"�'�#�s�(�"3�4�
��	
�


�
�H8<�,0�	
��
�"�'�#�s�(�"3�4�
�%�S�M�	
�


�
�D8<�
�!�'�#�s�(�"3�4�
�
�#��
�*8<� $�	
��
�"�'�#�s�(�"3�4�
��	
�

�#��
�F8<�,0�	
��
�"�'�#�s�(�"3�4�
�%�S�M�	
�


�
�F8<�

�!�'�#�s�(�"3�4�

�
�#��

�8<�
��
�"�'�#�s�(�"3�4�
�

�	
�$ &�C� &���c��1B� &�s� &rrbr)$r-rKrir��
contextlibr�os.pathrrr��
subprocessrrr�typingr	r
rrr
r�_in_processrrrr$r1r4�	Exceptionr6rCrGrPrSr`rbrrr�<module>r�sT���	�
��%��!�7�7�L�L�-���	�8�	�$�G�C��H�%�$�S�$�t�$�
�C��G�C��H�-��
E��E�"#�)�#�#�9�#��15�
&�	�#��
&�	�#��
&��G�C��H�-�.�
&�
�	
&�$�15�
7�	�#��
7�	�#��
7��G�C��H�-�.�
7�
�	
7� �������0\&�\&r
Back to Directory File Manager