Current File : //usr/lib/python3/dist-packages/setuptools/command/__pycache__/editable_wheel.cpython-312.pyc
�


_�dց�
�2�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZddlmZdd	lmZmZmZmZmZmZmZmZmZmZd
dlmZm Z m!Z!m"Z"m#Z#d
dl$m%Z%d
d
l&m'Z'd
dl(m)Z)m*Z*m+Z+ddl,m,Z-erddl.m/Z/ej`dk\rddlm1Z1nerddl2m1Z1nddl3m4Z1ee5efZ6ede6��Z7ejpe9�Z:Gd�de
�Z;dZ<dZ=Gd�de�Z>Gd�de1�Z?Gd�d �Z@Gd!�d"e@�ZAGd#�d$�ZBd%e5d&eCfd'�ZDd(ed&eEfd)�ZFd*ee5d+ee5e5fd,ed&eEfd-�ZGd.�ZHd/e'd&ee5fd0�ZId/e'd&ee5fd1�ZJd*ee5d+ee5e5fd2e6d&ee5e5ffd3�ZKd4e6d&e5fd5�ZLd6ee5e5fd&ee5fd7�ZMd*ee5d6ee5e5fd&eee5ee5ffd8�ZNd6ee5e5fd&ee5e5ffd9�ZOd:e5d;e5d<e5d=e5d&eEf
d>�ZPd?e7d&e7fd@�ZQGdA�dBe#j��ZSdCZTdDe5dEee5e5fdFee5ee5fd&e5fdG�ZUGdH�dIe"j��ZWGdJ�dKe+�ZXy)La�
Create a wheel that, when installed, will make the source package 'editable'
(add it to the interpreter's path, including metadata) per PEP 660. Replaces
'setup.py develop'.

.. note::
   One of the mechanisms briefly mentioned in PEP 660 to implement editable installs is
   to create a separated directory inside ``build`` and use a .pth file to point to that
   directory. In the context of this file such directory is referred as
   *auxiliary build directory* or ``auxiliary_dir``.
�N)�suppress)�Enum)�cleandoc)�chain)�Path)�TemporaryDirectory)
�
TYPE_CHECKING�Dict�Iterable�Iterator�List�Mapping�Optional�Tuple�TypeVar�Union�)�Command�_normalization�_path�errors�
namespaces)�find_package_path)�Distribution)�InformationOnly�SetuptoolsDeprecationWarning�SetuptoolsWarning�)�build_py��	WheelFile)��)�Protocol)�ABC�_P)�boundc�<�eZdZdZdZdZdZedee	ddfd��Z
y)	�
_EditableModea
    Possible editable installation modes:
    `lenient` (new files automatically added to the package - DEFAULT);
    `strict` (requires a new installation when files are added/removed); or
    `compat` (attempts to emulate `python setup.py develop` - DEPRECATED).
    �strict�lenient�compat�mode�returnc���|stjS|j�}|tjvrt	j
d|�d���|dk(rt
jddd��t|S)NzInvalid editable mode: z. Try: 'strict'.�COMPATzCompat editable installsa

                The 'compat' editable mode is transitional and will be removed
                in future versions of `setuptools`.
                Please adapt your code accordingly to use either the 'strict' or the
                'lenient' modes.
                �userguide/development_mode.html)�see_docs)r)�LENIENT�upper�__members__r�OptionErrorr�emit)�clsr-�_modes   �C/usr/lib/python3/dist-packages/setuptools/command/editable_wheel.py�convertz_EditableMode.convertQsv��� �(�(�(��
�
����
�1�1�1��$�$�'>�t�h�FV�%W�X�X��H��(�-�-�*��;�
� �U�#�#�N)�__name__�
__module__�__qualname__�__doc__�STRICTr3r0�classmethodr�strr;�r<r:r)r)Es<����F��G�
�F��$�8�C�=�$�_�$��$r<r)zU
New or renamed files may not be automatically picked up without a new installation.
zt
Options like `package-data`, `include/exclude-package-data` or
`packages.find.exclude/include` may have no effect.
c�2�eZdZdZdZddddeejxsd�fgZd�Zd	�Z	d
�Z
d�Zd�Zd
e
efd�Zdedededefd�Zd�Zd
eeeeeefffd�Zdedededed
eeeeeefff
d�Zd�Zdefd�Zd�Zdefd�Zdededed
dfd �Zy)!�editable_wheelz�Build 'editable' wheel for development.
    This command is private and reserved for internal use of setuptools,
    users should rely on ``setuptools.build_meta`` APIs.
    zBDO NOT CALL DIRECTLY, INTERNAL ONLY: create PEP 660 editable wheel)z	dist-dir=�dz-directory to put final built distributions in)zdist-info-dir=�Iz(path to a pre-build .dist-info directoryzmode=N�c�<�d|_d|_d|_d|_y�N)�dist_dir�
dist_info_dir�project_dirr-��selfs r:�initialize_optionsz!editable_wheel.initialize_options�s ����
�!��������	r<c��|j}|jxstj|_|j
xsi|_t
|jxs*tjj|jd��|_y)N�dist)
�distribution�src_root�os�curdirrN�package_dirrrL�path�join)rPrSs  r:�finalize_optionszeditable_wheel.finalize_options�s_��� � ���=�=�5�B�I�I����+�+�1�r����T�]�]�T�b�g�g�l�l�4�;K�;K�V�.T�U��
r<c���	|jjd��|j�|jd�|j	d�}|j|j�|j|�y#t$r^tj�|jjxs|jj�}tj|���wxYw)NT)�exist_ok�bdist_wheel)�project)rL�mkdir�_ensure_dist_info�reinitialize_command�get_finalized_command�write_wheelfilerM�_create_wheel_file�	Exception�	traceback�	print_excrT�name�get_name�_DebuggingTipsr7)rPr^r_s   r:�runzeditable_wheel.run�s���	��M�M�����.��"�"�$�
�%�%�m�4��4�4�]�C�K��'�'��(:�(:�;��#�#�K�0���	����!��'�'�,�,�L��0A�0A�0J�0J�0L�G������0��		�s
�A:A=�=A'C$c�\�|j�T|jd�}|j|_|j	�|j�|j|_yt
|j�jd�sJ�t|jd�j�sJ�y)N�	dist_infoz
.dist-info�METADATA)
rMrbrL�
output_dir�ensure_finalizedrlrC�endswithr�exists)rPrns  r:raz editable_wheel._ensure_dist_info�s������%��1�1�+�>�I�#'�=�=�I� ��&�&�(��M�M�O�!*�!8�!8�D���t�)�)�*�3�3�L�A�A�A���*�*�J�7�>�>�@�@�@r<c���|j}|jsyt|j|jjdd��j
�}t||||�}|j�y)NrI�.)	rT�namespace_packagesrrNrX�get�resolve�_NamespaceInstaller�install_namespaces)rP�installation_dir�
pth_prefixrSrU�	installers      r:�_install_namespacesz"editable_wheel._install_namespaces�sd��� � ���&�&����(�(�$�*:�*:�*>�*>�r�3�*G�H�P�P�R��'��.>�
�H�U�	��$�$�&r<r.c���|jrt|j�jn	t�}tt|jd��}t
|d�S)Nz
*.egg-info)rMr�parent�maprC�glob�next)rP�
parent_dir�
candidatess   r:�_find_egg_info_dirz!editable_wheel._find_egg_info_dir�sH��8<�8J�8J�T�$�,�,�-�4�4�PT�PV�
���j�o�o�l�;�<�
��J��%�%r<ri�unpacked_wheel�	build_lib�tmp_dirc��|j}t|�}t|�}tt||�d�d��}tt||�d�d��}tt||�d�d��}	|jdd��}
t|�|
_d|
_|jdd��}|jd	d��}|x|_x|_|_|x|_	x|_
|_|	x|_|_
||_||_|j!d
�}
d|
_t|�|_|j!d�}d|_|j)�|_|j-�|j/�|j/�y
)a�Configure commands to behave in the following ways:

        - Build commands can write to ``build_lib`` if they really want to...
          (but this folder is expected to be ignored and modules are expected to live
          in the project directory...)
        - Binary extensions should be built in-place (editable_mode = True)
        - Data/header/script files are not part of the "editable" specification
          so they are written directly to the unpacked_wheel directory.
        z.data�data�headers�scripts�egg_infoT)�reinit_subcommands�build�install�install_scriptsrFN)rTrCrrb�egg_base�ignore_egg_info_in_manifest�
build_platlib�
build_purelibr��install_purelib�install_platlib�install_libr��
build_scripts�install_headers�install_data�get_command_obj�no_ep�
build_temp�compiler��existing_egg_info_dir�_set_editable_moderq)rPrir�r�r�rS�wheelr�r�r�r�r�r�r�rs               r:�_configure_buildzeditable_wheel._configure_build�s���� � ���N�#���	�N�	��4��4�&����?�@���d�>�d�V�5�>�9�E�F���d�>�d�V�5�>�9�E�F���,�,�Z�D�,�Q����L���/3��,��)�)�'�d�)�K���+�+�I�$�+�O��FO�O���O�e�1�E�O�RW�W���W�'�"9�G�<O�8?�?���%�"5�")���#����.�.�/@�A�� $����w�<����'�'�
�3�� ���)-�)@�)@�)B��&����!�
��� �� � �"r<c���|j}|jd�}|j�D];}|j|�}t|d�rd|_�(t|d�s�5d|_�=y)z8Set the ``editable_mode`` flag in the build sub-commandsr��
editable_modeT�inplaceN)rTr��get_sub_commands�hasattrr�r�)rPrSr��cmd_name�cmds     r:r�z!editable_wheel._set_editable_mode�sh��� � ���$�$�W�-���.�.�0�	#�H��&�&�x�0�C��s�O�,�$(��!���i�(�"���	#r<c�>�g}i}|jd�}|j�D]r}|j|�}t|d�r#|j|j	�xsg�t|d�s�P|j|j
�xsi��t||fS)Nr��get_outputs�get_output_mapping)rcr�r��extendr��updater�)rP�files�mappingr�r�r�s      r:�_collect_build_outputsz%editable_wheel._collect_build_outputs�s�����"$���*�*�7�3���.�.�0�	?�H��,�,�X�6�C��s�M�*����S�_�_�.�4�"�5��s�0�1����s�5�5�7�=�2�>�	?��g�~�r<�	dist_namec���|j||||�|j�|j�\}}|jd�|jd�|jd�||fS)Nr�r�r�)r��_run_build_subcommandsr��_run_install)rPr�r�r�r�r�r�s       r:�_run_build_commandsz"editable_wheel._run_build_commandssj��	
���i���G�L��#�#�%��4�4�6���w����)�$����)�$����&�!��g�~�r<c���|jd�}|j�D]M}|j|�}|dk(r$t|�tk7r|j	|��=|j|��Oy)a}
        Issue #3501 indicates that some plugins/customizations might rely on:

        1. ``build_py`` not running
        2. ``build_py`` always copying files to ``build_lib``

        However both these assumptions may be false in editable_wheel.
        This method implements a temporary workaround to support the ecosystem
        while the implementations catch up.
        r�rN)rcr��type�build_py_cls�_safely_run�run_command)rPr�rir�s    r:r�z%editable_wheel._run_build_subcommandssk���3�3�G�<���*�*�,�	'�D��,�,�T�2�C��z�!�d�3�i�<�&?�� � ��&�� � ��&�	'r<r�c��	|j|�S#t$r5tjddt	j
��d|�d|�d��YywxYw)Nz0Customization incompatible with editable installz
                z�

                If you are seeing this warning it is very likely that a setuptools
                plugin or customization overrides the `a` command, without
                taking into consideration how editable installs run build steps
                starting from setuptools v64.0.0.

                Plugin authors and developers relying on custom build steps are
                encouraged to update their `ab` implementation considering the
                information about editable installs in
                https://setuptools.pypa.io/en/latest/userguide/extension.html.

                For the time being `setuptools` will silence this error and ignore
                the faulty command, but this behaviour will change in future versions.
                )r�rfrr7rg�
format_exc)rPr�s  r:r�zeditable_wheel._safely_run)sp��	��#�#�H�-�-���	�(�-�-�B���%�%�'�(�)8�9A�z�B-�
.6�J�7��
�	�s��;A�Ac
��ddlm}|jd�}|j}dj	|j��}d}|�d|�d|�d�}t
|j|�}|j�r|j�t|��}	td��}
td	��}|	5}|
5}
|5}t
|t
|j�j�}tj|j|�|j||j�|j|||
|�\}}|j!|||
�}|5||d
�5}||||�|j#|�ddd�ddd�ddd�ddd�ddd�|S#1swY�+xYw#1swY�/xYw#1swY�3xYw#1swY�7xYw#1swY|SxYw)Nrr rn�-z
0.editablez.whl)�suffixz
.build-libz.build-temp�w)�wheel.wheelfiler!rcrirZ�get_tagrrLrs�unlinkrrM�shutil�copytreer~r��_select_strategy�write_files)rPr^r!rnr��tag�	build_tag�archive_name�
wheel_pathr�r��	build_tmp�unpacked�lib�tmp�unpacked_dist_infor�r��strategy�	wheel_objs                    r:rez!editable_wheel._create_wheel_fileEs���-��.�.�{�;�	��N�N�	��h�h�{�*�*�,�-�� �	�#��A�i�[��#��d�;���$�-�-��6�
���������+�<�@��&�l�;�	�&�m�<�	�
�	0�x��	0�c�9�	0��!%�h��T�5G�5G�0H�0M�0M�!N���O�O�D�.�.�0B�C��$�$�X�y�~�~�>�!�5�5�i��3�PS�T�N�E�7��,�,�Y��S�A�H��
0�9�Z��5�
0����E�7�3��%�%�h�/�
0�
0�
	0�	0�	0���	
0�
0��
0�
0��
	0�	0��	0�	0��	0���sm�,G�/F8�2BF,�
F 	�F�*F 	�2F,�:F8�G�F�F 	� F)
�%F,�,F5�1F8�8G	�=G�G�categoryc��t|jd|��d�}|r6|�r.tjd|�d��|j	d|���yyy)N�has_zInstalling z as non editable�install_)�getattrrT�_logger�infor�)rPr��has_categorys   r:r�zeditable_wheel._run_installasV���t�0�0�D��
�2C�T�J���L�N��L�L�;�x�j�0@�A�B����x��z�2�3�+�<r<r��EditableStrategyc�l�d|�d|��}t|j�}tj|j�}|tj
ur8t
t|jd|��}t|j|||�St|j�}t||j|�}	|tju}
t|j�dhk(r|	s|
r>|jjdd�}t|j|t||�g�St!|j|�S)zDDecides which strategy to use to implement an editable installation.�
__editable__.r�r�rIru)rrNr)r;r-rA�
_empty_dir�	_LinkTreerT�_find_packages�_simple_layoutrXr0�setrw�
_StaticPth�_TopLevelFinder)rPrir�r��
build_namerNr-�
auxiliary_dir�packages�has_simple_layout�is_compat_mode�src_dirs            r:r�zeditable_wheel._select_strategygs��%�T�F�!�C�5�1�
��4�+�+�,���$�$�T�Y�Y�/���=�'�'�'�&�t�D�,<�,<�g�z�'R�S�M��T�.�.��m�Y�O�O�!�$�"3�"3�4��*�8�T�5E�5E�{�S����!5�!5�5���t��� �R�D�(�->�.��&�&�*�*�2�s�3�G��d�/�/���[�'�8R�7S�T�T��t�0�0�$�7�7r<)r=r>r?r@�descriptionrr)�user_optionsrQr[rlrar~rrCr��_Pathr�r�rr
r
r�r�r�r�rer�r�rDr<r:rFrFxsA���
W�K�	L�K�	�$���!6�!6�!<�"�=�>��L��V��"	A�'�&�H�S�M�&�
0#��0#�).�0#�;@�0#�KP�0#�d	#���d�3�i��c�3�h��.G�(H��	��	�.3�	�@E�	�PU�	�	�t�C�y�$�s�C�x�.�(�	)�	�'�,�C��8�84�S�4�8��8��8��	8�

�8r<rFc�<�eZdZdddeedeeeffd�Zd�Zd�Zy)	r�r�r!r�r�c��yrKrD)rPr�r�r�s    r:�__call__zEditableStrategy.__call__����r<c��yrKrDrOs r:�	__enter__zEditableStrategy.__enter__�r�r<c��yrKrD�rP�	_exc_type�
_exc_value�
_tracebacks    r:�__exit__zEditableStrategy.__exit__�r�r<N)	r=r>r?r
rCr
r�r�r�rDr<r:r�r��s3���k��$�s�)��d�3�PS�8�n���r<r�c�V�eZdZdededeefd�Zdddeedeeeffd	�Z	d
�Z
d�Zy)
r�rSri�path_entriesc�.�||_||_||_yrK)rSrir�)rPrSrir�s    r:�__init__z_StaticPth.__init__�s����	���	�(��r<r�r!r�r�c��djd�|jD��}t|�d��}|jd|j�d�|�y)N�
c3�NK�|]}t|j�����y�wrK)rCrx)�.0�ps  r:�	<genexpr>z&_StaticPth.__call__.<locals>.<genexpr>�s����I�!�S�����-�I�s�#%r��.pth)rZr��_encode_pth�writestrri)rPr�r�r��entries�contentss      r:r�z_StaticPth.__call__�sG���)�)�I�t�7H�7H�I�J���'��"�~�.��
����t�y�y�k��6��Ar<c��dtttj|j���d�}t
j
|tz�|S)Nz_
        Editable install will be performed using .pth file to extend `sys.path` with:
        z	
        )�listr�rV�fspathr�r��warning�_LENIENT_WARNING�rP�msgs  r:r�z_StaticPth.__enter__�sH��	�	
�c�"�)�)�T�.�.�/�	0�3�4	���	����.�.�/��r<c��yrKrDr�s    r:r�z_StaticPth.__exit__�r�r<N)r=r>r?rrCr
rrr
r�r�r�rDr<r:r�r��sU��)�\�)��)�D��J�)�
B�k�B�$�s�)�B�d�3�PS�8�n�B�
�r<r�c���eZdZdZdedededef�fd�Zddd	eed
e	eeff�fd�Z
ded
eefd�Zddedefd�Z
d�Zd�Zd�Z�xZS)r�a`
    Creates a ``.pth`` file that points to a link tree in the ``auxiliary_dir``.

    This strategy will only link files (not dirs), so it can be implemented in
    any OS, even if that means using hardlinks instead of symlinks.

    By collocating ``auxiliary_dir`` and the original source code, limitations
    with hardlinks should be avoided.
    rSrir�r�c����t|�|_t|�j�|_|j	d�j
|_t�|�!|||jg�y)Nr)	rr�rxr�r��	copy_file�_file�superr)rPrSrir�r��	__class__s     �r:rz_LinkTree.__init__�sX���"�-�0����i��0�0�2����)�)�*�5�?�?��
�
����t�d�&8�&8�%9�:r<r�r!r�r�c�L��|j||�t�|�	|||�yrK)�
_create_linksrr�)rPr�r�r�rs    �r:r�z_LinkTree.__call__�s$������5�'�*�
�����w�/r<�filer.c��tt�5t|�j�j	|j
�}t
|�jtjd�cddd�S#1swYyxYw)N�/)
r�
ValueErrorrrx�relative_tor�rC�replacerV�sep)rPrrYs   r:�_normalize_outputz_LinkTree._normalize_output�s]��
�j�
!�	2���:�%�%�'�3�3�D�N�N�C�D��t�9�$�$�R�V�V�S�1�	2�	2�	2��s�AA5�5A>�relative_output�src_filec��|j|z}|jj�s|jjd��|j	|||��y)NT)�parents��link)r�r��is_dirr`r)rPr$r%r)�dests     r:�_create_filez_LinkTree._create_file�sI���!�!�O�3���{�{�!�!�#��K�K���d��+��
�
�8�T��
�-r<c��|jjdd��t|j�rdnd}|j�D��cic]\}}|j	|�|��}}}|jdd�|D]-}|j	|�}|s�||vs�|j
||��/|j�D]\}}	|j
||	|���ycc}}w)NT)r'r]�sym�hardr()r�r`�_can_symlink_files�itemsr#�popr,)
rP�outputs�output_mapping�	link_type�k�v�mappings�output�relative�srcs
          r:rz_LinkTree._create_links�s������ � ��� �=�/��0B�0B�C�E��	�=K�=Q�=Q�=S�T�T�Q��D�*�*�1�-�q�0�T��T����T�4� ��	4�F��-�-�f�5�H��H�H�4��!�!�(�F�3�	4�
&�^�^�-�	=�M�H�c����h��)��<�	=��Us�
Cc�B�d}tj|tz�|S)Nz=Strict editable install will be performed using a link tree.
)r�r�_STRICT_WARNINGrs  r:r�z_LinkTree.__enter__�s��N������o�-�.��r<c�P�d|j�d�}tjd|�y)Nz\

        Strict editable installation performed using the auxiliary directory:
            z�

        Please be careful to not remove this directory, otherwise you might not be able
        to import/use your package.
        �Editable installation.)r�rr7�rPr�r�r�rs     r:r�z_LinkTree.__exit__�s2��
�
�
�
� �!	���	���5�s�;r<rK)r=r>r?r@rrCr�rr
r
r�rr#r,rr�r��
__classcell__)rs@r:r�r��s�����
;��
;��
;��	
;�
�
;�0�k�0�$�s�)�0�d�3�PS�8�n�0��c��h�s�m��.�C�.�3�.�=��
<r<r�c�L�eZdZdedefd�Zdddeedeeeffd�Zd	�Z	d
�Z
y)r�rSric� �||_||_yrK)rSri)rPrSris   r:rz_TopLevelFinder.__init__�s����	���	r<r�r!r�r�c	��|jjxstj}t	t|j�t
|j��}|jjxsi}t|||�}tt	t|jjxsg|�d�t|�D���}d|j�d�}	tj|	�}
t!t#|	||�d�}|j%|
�d�|�t'd|
�d|
�d��}|j%d|j�d	�|�y)
Nc3�$K�|]}|gf���
y�wrKrD)r�nss  r:rz+_TopLevelFinder.__call__.<locals>.<genexpr>�s����D�b�"�b��D�s�r�z.finder�utf-8z.pyzimport z; z
.install()r)rSrUrVrWrr��_find_top_level_modulesrX�_find_package_roots�dict�_find_namespacesr��_find_virtual_namespacesrir�safe_identifier�bytes�_finder_templater	r)rPr�r�r�rU�	top_levelrX�roots�namespaces_ri�finder�contents            r:r�z_TopLevelFinder.__call__�s���9�9�%�%�2������.����3�5L�T�Y�Y�5W�X�	��i�i�+�+�1�r��#�I�{�H�E��,0�� ����!3�!3�!9�r�5�A�D�$<�U�$C�D�
�-
���t�y�y�k��1���/�/��5���(��u�k�B�G�L��
���&���~�w�/����x�r�&���D�E��
����t�y�y�k��6��@r<c�B�d}tj|tz�|S)Nz=Editable install will be performed using a meta path finder.
)r�rrrs  r:r�z_TopLevelFinder.__enter__s��N������.�.�/��r<c�4�d}tjd|�y)Nz�

        Please be careful with folders in your working directory with the same
        name as your package as they may take precedence during imports.
        r?)rr7r@s     r:r�z_TopLevelFinder.__exit__	s����	���5�s�;r<N)r=r>r?rrCrr
r
r�r�r�rDr<r:r�r��sJ���\����A�k�A�$�s�)�A�d�3�PS�8�n�A�*�
<r<r�rTr.c�4�tjdk\rdnd}tj�5}tj||�}|j|�|j
�|jd�|j�cddd�S#1swYyxYw)a!.pth files are always read with 'locale' encoding, the recommendation
    from the cpython core developers is to write them as ``open(path, "w")``
    and ignore warnings (see python/cpython#77102, pypa/setuptools#3937).
    This function tries to simulate this behaviour without having to create an
    actual file, in a way that supports a range of active Python versions.
    (There seems to be some variety in the way different version of Python handle
    ``encoding=None``, not all of them use ``locale.getpreferredencoding(False)``).
    )r"�
�localeNr)	�sys�version_info�io�BytesIO�
TextIOWrapper�write�flush�seek�read)rT�encoding�buffer�wrappers    r:rrss���+�+�w�6�x�D�H�	�������"�"�6�8�4���
�
�g���
�
�����A���{�{�}����s�AB�B�base_dirc�.�tt|j����5}t|d�t|d�}}|j	dd��tttt�5tj||�|j�r'|jd��dk(r	ddd�ddd�yddd�	tj||�	ddd�y	#1swY�*xYw#t$r}d}t|�|�d}~wwxYw#1swYyxYw)
N)�dirz	file1.txtz	file2.txt�file1rG)rcTz�File system does not seem to support either symlinks or hard links. Strict editable installs require one of them to be supported.F)rrCrxr�
write_textr�AttributeError�NotImplementedError�OSErrorrV�symlink�
is_symlink�	read_textr)rf�LinksNotSupported)rfr��path1�path2�exrs      r:r0r0#s��	��H�$4�$4�$6� 7�	8��C��C��-�t�C��/E�u��
����7��3�
�n�&9�7�
C�	��J�J�u�e�$����!�e�o�o�w�o�&G�7�&R��	���	�
	1��G�G�E�5�!��!��	�	���	1�P�
�$�C�(�b�0��	1����sN�AD�)=C �&D�7D�C,�D� C)	�%D�,	D�5D�D�D�Dr�rXrNc
�L��|D�cic]}|t|||���}}|st|�idhfvStjj	|j�D��cgc]\}}t
||���c}}��t�fd�|j�D��Scc}wcc}}w)a[Return ``True`` if:
    - all packages are contained by the same parent directory, **and**
    - all packages become importable if the parent directory is added to ``sys.path``.

    >>> _simple_layout(['a'], {"": "src"}, "/tmp/myproj")
    True
    >>> _simple_layout(['a', 'a.b'], {"": "src"}, "/tmp/myproj")
    True
    >>> _simple_layout(['a', 'a.b'], {}, "/tmp/myproj")
    True
    >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"": "src"}, "/tmp/myproj")
    True
    >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "a", "b": "b"}, ".")
    True
    >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "_a", "b": "_b"}, ".")
    False
    >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a": "_a"}, "/tmp/myproj")
    False
    >>> _simple_layout(['a', 'a.a1', 'a.a1.a2', 'b'], {"a.a1.a2": "_a2"}, ".")
    False
    >>> _simple_layout(['a', 'a.b'], {"": "src", "a.b": "_ab"}, "/tmp/myproj")
    False
    >>> # Special cases, no packages yet:
    >>> _simple_layout([], {"": "src"}, "/tmp/myproj")
    True
    >>> _simple_layout([], {"a": "_a", "": "src"}, "/tmp/myproj")
    False
    rIc	3��K�|]6\}}tjt�g|jd����|����8y�w�ruN)r�	same_pathr�split)r�key�valuer�s   �r:rz!_simple_layout.<locals>.<genexpr>Zs:�������C��	����V�5�c�i�i��n�5�u�=��s�<?)rr�rVrY�
commonpathr1�_parent_path�all)r�rXrN�pkg�layoutr6r7r�s       @r:r�r�7s����>PX�
X��c�$�S�+�{�C�C�
X�F�
X���;��B���:�-�-�
�W�W�
�
����� O���1��a��!3� O�
P�F��� �,�,�.�����	Y��!Ps�B�B 
c��|j|�r|dt|�n|}|jdtjz�S)a7Infer the parent path containing a package, that if added to ``sys.path`` would
    allow importing that package.
    When ``pkg`` is directly mapped into a directory with a different name, return its
    own path.
    >>> _parent_path("a", "src/a")
    'src'
    >>> _parent_path("b", "src/c")
    'src/c'
    Nr)rr�len�rstriprVr")r�pkg_pathr�s   r:r}r}`s<��'/�&7�&7��&<�X�k��S��	�
"�(�F��=�=��r�v�v��&�&r<rSc#�K�t|jxsg�Ed{���|jxsg}|D�cgc]	}d|vs�|��}}|jr|j��n<|jxsg}||D�cgc]}d|j
vs�|j
��c}z
}|D]}|j
d�\}}}|���y7��cc}wcc}w�w)Nru)�iterr��
py_modules�ext_package�ext_modulesri�
rpartition)	rSr��mod�nested_modulesr��x�module�package�_s	         r:r�r�ns������D�M�M�'�R�(�(�(����&�B�J�%/�>�c�3�#�:�c�>�N�>���������&�&�,�"���;�H�a�#����-�1�6�6�H�H�� ����)�)�#�.�
���A��
��)��?��
I�s8�C�C�C�	C�C�2C�8C�C�'C�
Cc#�K�|jxsg}d�|D�Ed{���|js"|jxsg}d�|D�Ed{���yy7�37��w)Nc3�*K�|]}d|vs�|���
y�wrwrD)rr�s  r:rz*_find_top_level_modules.<locals>.<genexpr>�s����<��S��^��<�s�	�c3�RK�|]}d|jvs�|j���!y�wrw)ri)rr�s  r:rz*_find_top_level_modules.<locals>.<genexpr>�s����E�q�3�a�f�f�3D�A�F�F�E�s�'�')r�r�r�)rSr�r�s   r:rHrH~sZ�������&�B�J�<�z�<�<�<�����&�&�,�"��E�K�E�E�E��=��	F�s!�A�A�,A�A�
A�ArUc�|�t|�D�cic]}|tt|||����}}t|�Scc}wrK)�sorted�_absolute_rootr�_remove_nested)r�rXrUr�	pkg_rootss     r:rIrI�sL���(�#�!��	�^�-�c�;��I�
J�J�!�I�!�
�)�$�$��!s�9rYc���t|�}|j}|j�rt|j	��St|j	�|j
z�S)z(Works for packages and top-level modules)rr�rsrCrxri)rY�path_r�s   r:r�r��sI����J�E�
�\�\�F��|�|�~��5�=�=�?�#�#��6�>�>�#�e�j�j�0�1�1r<r�c	#�K�|D]y}d|vr�|jd�}tt|�dz
dd�D]E}dj|d|�}t	t||d��}|j
�r||vs�B|���G�{y�w)a8By carefully designing ``package_dir``, it is possible to implement the logical
    structure of PEP 420 in a package without the corresponding directories.

    Moreover a parent package can be purposefully/accidentally skipped in the discovery
    phase (e.g. ``find_packages(include=["mypkg.*"])``, when ``mypkg.foo`` is included
    by ``mypkg`` itself is not).
    We consider this case to also be a virtual namespace (ignoring the original
    directory) to emulate a non-editable installation.

    This function will try to find these kinds of namespaces.
    rurr���NrI)ry�ranger�rZrrrs)r�r�parts�i�partial_namerYs      r:rLrL�s������	#���c�>���	�	�#����s�5�z�A�~�q�"�-�	#�A��8�8�E�"�1�I�.�L��)�,�	�2�F�G�D��;�;�=�L�	�$A�"�"�	#�		#�s�A6B�9	Bc#�K�|D]K}t||d�}t|�j�s�*t|d�j�r�E||gf���My�w)NrIz__init__.py)rrrs)r�r�rrYs    r:rKrK�sS����� �� ��i��4����:����t�D�-�'@�'G�'G�'I����-�� �s�,A�A�

Ac����t|j��}tt|j	���D]:\��t��fd�|j	�D��s�*|j
���<|S)Nc3�N�K�|]\}}�|k7xrt��||����y�wrK)�
_is_nested)r�other�
other_pathrYrs   ��r:rz!_remove_nested.<locals>.<genexpr>�s4�����
�!��z�
�5�L�E�Z��T�5�*�E�E�
�s�"%)rJ�copy�reversedr
r1�anyr2)r�r9rYrs  @@r:r�r��sh���
�)�.�.�"�
#�F��d�9�?�?�#4�5�6��	��T��
�%.�_�_�%6�
�
�
�J�J�s�O���Mr<rr�r��parent_pathc��tj|�}|j|dd�jd�j	d�}|j|�xr"|tjt
|g|����k(S)a�
    Return ``True`` if ``pkg`` is nested inside ``parent`` both logically and in the
    file system.
    >>> _is_nested("a.b", "path/a/b", "a", "path/a")
    True
    >>> _is_nested("a.b", "path/a/b", "a", "otherpath/a")
    False
    >>> _is_nested("a.b", "path/a/b", "c", "path/c")
    False
    >>> _is_nested("a.a", "path/a/a", "a", "path/a")
    True
    >>> _is_nested("b.a", "path/b/a", "a", "path/a")
    False
    rIrru)r�normpathr!�stripry�
startswithr)rr�r�r��
norm_pkg_path�rests      r:r�r��so���N�N�8�,�M��;�;�v�r�1�%�+�+�C�0�6�6�s�;�D��>�>�&�!��m�u�~�~��[� �4� �8�'�r<�dir_c�^�tj|d��tj|�|S)zFCreate a directory ensured to be empty. Existing files may be removed.T)�
ignore_errors)r��rmtreerV�makedirs)r�s r:r�r��s!��
�M�M�$�d�+��K�K����Kr<c��eZdZd�Zd�Zd�Zy)ryc�X�||_||_||_||_g|_d|_y)NF)rTrUr{�
editable_namer3�dry_run)rPrTr{r�rUs     r:rz_NamespaceInstaller.__init__�s/��(��� ��
� 0���*��������r<c�j�tjj|j|j�S)zInstallation target.)rVrYrZr{r�rOs r:�_get_targetz_NamespaceInstaller._get_target�s#���w�w�|�|�D�1�1�4�3E�3E�F�Fr<c�>�tt|j��S)z1Where the modules/packages should be loaded from.)�reprrCrUrOs r:�	_get_rootz_NamespaceInstaller._get_root�s���C��
�
�&�'�'r<N)r=r>r?rr�r�rDr<r:ryry�s���G�(r<rya�
import sys
from importlib.machinery import ModuleSpec, PathFinder
from importlib.machinery import all_suffixes as module_suffixes
from importlib.util import spec_from_file_location
from itertools import chain
from pathlib import Path

MAPPING = {mapping!r}
NAMESPACES = {namespaces!r}
PATH_PLACEHOLDER = {name!r} + ".__path_hook__"


class _EditableFinder:  # MetaPathFinder
    @classmethod
    def find_spec(cls, fullname, path=None, target=None):
        # Top-level packages and modules (we know these exist in the FS)
        if fullname in MAPPING:
            pkg_path = MAPPING[fullname]
            return cls._find_spec(fullname, Path(pkg_path))

        # Handle immediate children modules (required for namespaces to work)
        # To avoid problems with case sensitivity in the file system we delegate
        # to the importlib.machinery implementation.
        parent, _, child = fullname.rpartition(".")
        if parent and parent in MAPPING:
            return PathFinder.find_spec(fullname, path=[MAPPING[parent]])

        # Other levels of nesting should be handled automatically by importlib
        # using the parent path.
        return None

    @classmethod
    def _find_spec(cls, fullname, candidate_path):
        init = candidate_path / "__init__.py"
        candidates = (candidate_path.with_suffix(x) for x in module_suffixes())
        for candidate in chain([init], candidates):
            if candidate.exists():
                return spec_from_file_location(fullname, candidate)


class _EditableNamespaceFinder:  # PathEntryFinder
    @classmethod
    def _path_hook(cls, path):
        if path == PATH_PLACEHOLDER:
            return cls
        raise ImportError

    @classmethod
    def _paths(cls, fullname):
        # Ensure __path__ is not empty for the spec to be considered a namespace.
        return NAMESPACES[fullname] or MAPPING.get(fullname) or [PATH_PLACEHOLDER]

    @classmethod
    def find_spec(cls, fullname, target=None):
        if fullname in NAMESPACES:
            spec = ModuleSpec(fullname, None, is_package=True)
            spec.submodule_search_locations = cls._paths(fullname)
            return spec
        return None

    @classmethod
    def find_module(cls, fullname):
        return None


def install():
    if not any(finder == _EditableFinder for finder in sys.meta_path):
        sys.meta_path.append(_EditableFinder)

    if not NAMESPACES:
        return

    if not any(hook == _EditableNamespaceFinder._path_hook for hook in sys.path_hooks):
        # PathEntryFinder is needed to create NamespaceSpec without private APIS
        sys.path_hooks.append(_EditableNamespaceFinder._path_hook)
    if PATH_PLACEHOLDER not in sys.path:
        sys.path.append(PATH_PLACEHOLDER)  # Used just to trigger the path hook
rir�rc�|�tt|j�d����}tj	|||��S)z_Create a string containing the code for the``MetaPathFinder`` and
    ``PathEntryFinder``.
    c��|dS)NrrD)rs r:�<lambda>z"_finder_template.<locals>.<lambda>Ss
���1��r<)rz�rir�r)rJr�r1�_FINDER_TEMPLATE�formatr�s   r:rOrOMs3���6�'�-�-�/�~�>�?�G��"�"��g�*�"�U�Ur<c��eZdZdZy)rqzCFile system does not seem to support either symlinks or hard links.N)r=r>r?r@rDr<r:rqrqWs��Mr<rqc��eZdZdZdZdZy)rkz!Problem in editable installation.a
    An error happened while installing `{project}` in editable mode.

    The following steps are recommended to help debug this problem:

    - Try to install the project normally, without using the editable mode.
      Does the error still persist?
      (If it does, try fixing the problem before attempting the editable mode).
    - If you are using binary extensions, make sure you have all OS-level
      dependencies installed (e.g. compilers, toolchains, binary libraries, ...).
    - Try the latest version of setuptools (maybe the error was already fixed).
    - If you (or your project dependencies) are using any setuptools extension
      or customization, make sure they support the editable mode.

    After following the steps above, if the problem still persists and
    you think this is related to how setuptools handles editable installations,
    please submit a reproducible example
    (see https://stackoverflow.com/help/minimal-reproducible-example) to:

        https://github.com/pypa/setuptools/issues
    r1N)r=r>r?�_SUMMARY�_DETAILS�	_SEE_DOCSrDr<r:rkrk[s��2�H��H�*2�Ir<rk)Yr@�loggingr\rVr�rZrg�
contextlibr�enumr�inspectr�	itertoolsr�pathlibr�tempfiler�typingr	r
rrr
rrrrrrIrrrrr�	discoveryrrSr�warningsrrrrr�r�r!r[r$�typing_extensions�abcr%rCr�r&�	getLoggerr=r�r)r=rrFr�r�r�r�rNr�boolr0r�r}r�rHrIr�rLrKr�r�r��	Installerryr�rO�	FileErrorrqrkrDr<r:�<module>r�s��
��	�	�
�
�������'������*����
/��)����v����*�#�
�c�4�i����T����
�'�
�
�H�
%��&$�D�&$�R����G8�W�G8�T�x����.C<�
�C<�L$<�$<�N�����$���$��(&��s�m�&�*.�s�C�x�.�&�GK�&�	�&�R'�
��
�(�3�-�
� F�,�F�8�C�=�F�
%��s�m�
%���c��"�
%��
%�
�#�s�(�^�	
%�2��2�3�2�#��S�#�X��#�8�C�=�#�0 ��3�i� �$(��c��N� �
�e�C��c��N�#�$� �
�d�3��8�n�
��c�3�h��
��C��3����#��$��,�R��B��(�*�.�.�(�$N��bV�

�V���S��)�V�7;�C��c��N�7K�V��V�N��(�(�N�2�&�2r<