Your IP : 216.73.216.52


Current Path : /snap/certbot/5451/lib/python3.12/site-packages/setuptools/__pycache__/
Upload File :
Current File : //snap/certbot/5451/lib/python3.12/site-packages/setuptools/__pycache__/discovery.cpython-312.pyc

�

\[�i&S����dZddlmZddlZddlZddlmZmZmZddl	m
Z
ddlmZddlm
Z
ddlmZmZddlZd	d
lmZddlmZddlmZerdd
lmZej6j8Zd%d�ZGd�d�ZGd�d�Z Gd�de �Z!Gd�de!�Z"Gd�de �Z#Gd�de"�Z$Gd�de#�Z%d&d�Z&Gd�d�Z'd'd �Z(d'd!�Z)								d(d"�Z*								d)d#�Z+d*d$�Z,y)+u_Automatic discovery of Python modules and packages (for inclusion in the
distribution) and other config values.

For the purposes of this module, the following nomenclature is used:

- "src-layout": a directory representing a Python project that contains a "src"
  folder. Everything under the "src" folder is meant to be included in the
  distribution when packaging the project. Example::

    .
    ├── tox.ini
    ├── pyproject.toml
    └── src/
        └── mypkg/
            ├── __init__.py
            ├── mymodule.py
            └── my_data_file.txt

- "flat-layout": a Python project that does not use "src-layout" but instead
  have a directory under the project root for each package::

    .
    ├── tox.ini
    ├── pyproject.toml
    └── mypkg/
        ├── __init__.py
        ├── mymodule.py
        └── my_data_file.txt

- "single-module": a project that contains a single Python script direct under
  the project root (no directory used)::

    .
    ├── tox.ini
    ├── pyproject.toml
    └── mymodule.py

�)�annotationsN)�Iterable�Iterator�Mapping��fnmatchcase)�glob)�Path)�
TYPE_CHECKING�ClassVar�)�StrPath)�log)�convert_path)�Distributionc�\�tjj|�j�S�N)�os�path�basename�isidentifier)rs ��/build/snapcraft-certbot-8ace4148c346cc61c23dfdbf9a13f72e/parts/certbot/install/lib/python3.12/site-packages/setuptools/discovery.py�_valid_namer?s ��
�7�7���D�!�.�.�0�0�c�(�eZdZdZdd�Zdd�Zdd�Zy)�_Filterz�
    Given a list of patterns, create a callable that will be true only if
    the input matches at least one of the patterns.
    c�8�tj|�|_yr)�dict�fromkeys�	_patterns)�self�patternss  r�__init__z_Filter.__init__Js�����x�0��rc�@��t�fd�|jD��S)Nc3�6�K�|]}t�|����y�wrr)�.0�pat�items  �r�	<genexpr>z#_Filter.__call__.<locals>.<genexpr>Ns�����D�c�;�t�S�)�D�s�)�anyr �r!r(s `r�__call__z_Filter.__call__Ms����D�T�^�^�D�D�Drc��||jvSr)r r+s  r�__contains__z_Filter.__contains__Ps���t�~�~�%�%rN)r"�str�return�None)r(r/r0�bool)�__name__�
__module__�__qualname__�__doc__r#r,r.�rrrrDs���
1�E�&rrc�x�eZdZUdZdZded<dZded<e			d								d
d��Ze								dd��Z	y)�_Finderz@Base class that exposes functionality for module/package findersr7zClassVar[tuple[str, ...]]�ALWAYS_EXCLUDE�DEFAULT_EXCLUDEc	��|xs|j}t|jtt	|��tg|j�|���t|���S)aZReturn a list of all Python items (packages or modules, depending on
        the finder implementation) found within directory ``where``.

        ``where`` is the root directory which will be searched.
        It should be supplied as a "cross-platform" (i.e. URL-style) path;
        it will be converted to the appropriate local path syntax.

        ``exclude`` is a sequence of names to exclude; ``*`` can be used
        as a wildcard in the names.
        When finding packages, ``foo.*`` will exclude all subpackages of ``foo``
        (but not ``foo`` itself).

        ``include`` is a sequence of names to include.
        If it's specified, only the named items will be included.
        If it's not specified, all found items will be included.
        ``include`` can contain shell style wildcard patterns just like
        ``exclude``.
        )r;�list�
_find_iterrr/rr:��cls�where�exclude�includes    r�findz_Finder.findZsW��4�0�S�0�0����N�N��S��Z�(��6��+�+�6�g�6���!�
�
�	
rc��t�r)�NotImplementedErrorr?s    rr>z_Finder._find_iter}s
��"�!rN)�.r7)�*)rArrB�
Iterable[str]rCrIr0�	list[str]�rArrBrrCrr0z
Iterator[str])
r3r4r5r6r:�__annotations__r;�classmethodrDr>r7rrr9r9Ts���J�02�N�-�2�13�O�.�3���!#�!'�	 
�� 
�� 
��	 
�

� 
�� 
�D�"��"�&-�"�8?�"�	�"��"rr9c�H�eZdZdZdZe								dd��Zedd��Zy)�
PackageFinderzI
    Generate a list of all Python packages found within a directory
    )�ez_setupz*__pycache__c#��K�tjt|�d��D]�\}}}|dd}g|dd|D]�}tjj	||�}	tjj|	|�}
|
j
tjjd�}d|vs|j|	|�s��||�r||�s|��|�d�|vs|�d�|vr��|j|�����y�w)zy
        All the packages found in 'where' that pass the 'include' filter, but
        not the 'exclude' filter.
        T)�followlinksNrGrH�.*)
r�walkr/r�join�relpath�replace�sep�_looks_like_package�append)r@rArBrC�root�dirs�files�all_dirs�dir�	full_path�rel_path�packages            rr>zPackageFinder._find_iter�s�����"$����U���!F�	!��D�$���A�w�H��D��G��
!���G�G�L�L��s�3�	��7�7�?�?�9�e�<��"�*�*�2�7�7�;�;��<���#�:�S�%<�%<�Y��%P���7�#�G�G�,<�!�M��Y�a�=�G�+�'��"�~��/H�����C� �'
!�	!�s�C1C3c�|�tjjtjj|d��S)z%Does a directory look like a package?�__init__.py)rr�isfilerU)r�
_package_names  rrYz!PackageFinder._looks_like_package�s&���w�w�~�~�b�g�g�l�l�4��?�@�@rNrK)rrrfr/r0r2)	r3r4r5r6r:rMr>�staticmethodrYr7rrrOrO�sW���2�N��!��!�&-�!�8?�!�	�!��!�B�A��ArrOc��eZdZedd��Zy)�PEP420PackageFinderc��y)NTr7)�_pathrfs  rrYz'PEP420PackageFinder._looks_like_package�s��rN)rkrrfr/r0r2)r3r4r5rgrYr7rrriri�s�����rric�B�eZdZdZe								dd��Zee�Zy)�ModuleFinderzYFind isolated Python modules.
    This function will **not** recurse subdirectories.
    c#�6K�ttjj|d��D]i}tjj	tjj|��\}}|j
|�s�T||�s�]||�r�f|���ky�w)Nz*.py)r	rrrU�splitextr�_looks_like_module)r@rArBrC�file�module�_exts       rr>zModuleFinder._find_iter�su����������e�V�4�5�	�D��7�7�+�+�B�G�G�,<�,<�T�,B�C�L�F�D��)�)�&�1���v��w�v����	�s�BB�	B�BNrK)	r3r4r5r6rMr>rgrrpr7rrrmrm�sH����
��
�&-�
�8?�
�	�
��
�&�k�2�rrmc�N�eZdZdZeed�eD���Z	edd��Zy)�FlatLayoutPackageFinder)#�ci�bin�debian�doc�docs�
documentation�manpages�news�
newsfragments�	changelog�test�tests�	unit_test�
unit_tests�example�examples�scripts�tools�util�utils�python�build�dist�venv�env�requirements�tasks�fabfile�
site_scons�	benchmark�
benchmarks�exercise�	exercises�htmlcov�[._]*c#�*K�|]}||�d�f���
y�w)rSNr7)r&�ps  rr)z!FlatLayoutPackageFinder.<genexpr>�s����&G���a�S��8�}�&G�s�c��|jd�}|dj�xs|djd�}|xrtd�|ddD��S)NrGr�-stubsc3�<K�|]}|j����y�wr)r)r&�names  rr)z>FlatLayoutPackageFinder._looks_like_package.<locals>.<genexpr>s����(S���):�):�)<�(S�s�r
)�splitr�endswith�all)rk�package_name�names�root_pkg_is_valids    rrYz+FlatLayoutPackageFinder._looks_like_package�sU���"�"�3�'��!�!�H�1�1�3�R�u�Q�x�7H�7H��7R�� �S�S�(S��q�r��(S�%S�SrN)rkrr�r/r0r2)	r3r4r5�_EXCLUDE�tuple�
chain_iterr;rgrYr7rrruru�s8��'�H�R�J�&G�h�&G�G�H�O� ��T��Trruc��eZdZdZy)�FlatLayoutModuleFinder)�setup�conftestr�r�r�r�r��toxfile�noxfile�pavement�dodor�r�z[Ss][Cc]onstruct�	conanfile�manager�r�r�r�r�N)r3r4r5r;r7rrr�r�s���O�4*rr�c��tj|�}|g|D�cgc]}dj||f���c}zScc}w)NrG)rirDrU)�root_pkg�pkg_dir�nested�ns    r�_find_packages_withinr�%s:��
 �
%�
%�g�
.�F��:�&�A�Q����8�Q�-�0�A�A�A��As�;c��eZdZdZdd�Zd�Zd�Zedd��Zedd��Z		d							dd�Z
dd�Zdd	�Zdd
�Z
dd�Zdd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zy)�ConfigDiscoveryz�Fill-in metadata and options that can be automatically derived
    (from other metadata/options, the file system or conventions)
    c�<�||_d|_d|_d|_y)NF)r��_called�	_disabled�_skip_ext_modules)r!�distributions  rr#zConfigDiscovery.__init__/s�� ��	�������!&��rc��d|_y)z+Internal API to disable automatic discoveryTN)r��r!s r�_disablezConfigDiscovery._disable5s	����rc��d|_y)a�Internal API to disregard ext_modules.

        Normally auto-discovery would not be triggered if ``ext_modules`` are set
        (this is done for backward compatibility with existing packages relying on
        ``setup.py`` or ``setup.cfg``). However, ``setuptools`` can call this function
        to ignore given ``ext_modules`` and proceed with the auto-discovery if
        ``packages`` and ``py_modules`` are not given (e.g. when using pyproject.toml
        metadata).
        TN)r�r�s r�_ignore_ext_modulesz#ConfigDiscovery._ignore_ext_modules9s��"&��rc�R�|jjxstjSr)r��src_rootr�curdirr�s r�	_root_dirzConfigDiscovery._root_dirEs���y�y�!�!�.�R�Y�Y�.rc�^�|jj�iS|jjSr)r��package_dirr�s r�_package_dirzConfigDiscovery._package_dirJs'���9�9� � �(��I��y�y�$�$�$rc��|dur|js|jry|j|�|r|j�d|_y)a�Automatically discover missing configuration fields
        and modifies the given ``distribution`` object in-place.

        Note that by default this will only have an effect the first time the
        ``ConfigDiscovery`` object is called.

        To repeatedly invoke automatic discovery (e.g. when the project
        directory changes), please use ``force=True`` (or create a new
        ``ConfigDiscovery`` instance).
        FNT)r�r��_analyse_package_layout�analyse_name)r!�forcer��ignore_ext_moduless    rr,zConfigDiscovery.__call__Ps?���E�>�t�|�|�t�~�~���$�$�%7�8��������rc�(�|xs|j}|jjduxs|}|jjduxsL|jjduxs2|xs.t|jd�xr|jjS)zF``True`` if the user has specified some form of package/module listingN�
configuration)r�r��ext_modules�packages�
py_modules�hasattrr�)r!r�r�s   r�_explicitly_specifiedz%ConfigDiscovery._explicitly_specifiedgs���/�I�4�3I�3I���9�9�0�0�D�8�N�<N�O���I�I���d�*�
(��y�y�#�#�4�/�
(��
(��t�y�y�/�2�(��	�	�'�'�	
rc��|j|�rytjd�|j�xs"|j	�xs|j�S)NTzLNo `packages` or `py_modules` configuration, performing automatic discovery.)r�r�debug�_analyse_explicit_layout�_analyse_src_layout�_analyse_flat_layout)r!r�s  rr�z'ConfigDiscovery._analyse_package_layoutts^���%�%�&8�9���	�	�
#�	
�
�)�)�+�
+��'�'�)�
+��(�(�*�		
rc�|��|jj�}|jdd�|j�|syt	j
d|���t
�fd�|j�D��}t|�|j_
t	j
d|jj���y)zAThe user can explicitly give a package layout via ``package_dir``�NFz(`explicit-layout` detected -- analysing c3�x�K�|]1\}}t|tjj�|�����3y�wr)r�rrrU)r&�pkg�
parent_dir�root_dirs   �rr)z;ConfigDiscovery._analyse_explicit_layout.<locals>.<genexpr>�s3�����
���Z�
"�#�r�w�w�|�|�H�j�'I�J�
�s�7:�discovered packages -- T)r��copy�popr�rr�r��itemsr=r�r�)r!r��pkgsr�s   @rr�z(ConfigDiscovery._analyse_explicit_layout�s�����'�'�,�,�.������D�!��>�>�����	�	�<�[�M�J�K��
�#.�#4�#4�#6�
�
��"�$�Z��	�	���	�	�+�D�I�I�,>�,>�+?�@�A�rc��|j}tjj|j|jdd��}tjj
|�sytjd|���|jdtjj|��||j_tj|�|j_t j|�|j_tjd|jj���tjd|jj"���y)a�Try to find all packages or modules under the ``src`` directory
        (or anything pointed by ``package_dir[""]``).

        The "src-layout" is relatively safe for automatic discovery.
        We assume that everything within is meant to be included in the
        distribution.

        If ``package_dir[""]`` is not given, but the ``src`` directory exists,
        this function will set ``package_dir[""] = "src"``.
        r��srcFz#`src-layout` detected -- analysing r��discovered py_modules -- T)r�rrrUr��get�isdirrr��
setdefaultrr�r�rirDr�rmr�)r!r��src_dirs   rr�z#ConfigDiscovery._analyse_src_layout�s����'�'���'�'�,�,�t�~�~�{���r�5�/I�J���w�w�}�}�W�%���	�	�7��y�A�B����r�2�7�7�#3�#3�G�#<�=� +��	�	��0�5�5�g�>��	�	��+�0�0��9��	�	���	�	�+�D�I�I�,>�,>�+?�@�A��	�	�-�d�i�i�.B�.B�-C�D�E�rc��tjd|j���|j�xs|j	�S)a�Try to find all packages and modules under the project root.

        Since the ``flat-layout`` is more dangerous in terms of accidentally including
        extra files/directories, this function is more conservative and will raise an
        error if multiple packages or modules are found.

        This assumes that multi-package dists are uncommon and refuse to support that
        use case in order to be able to prevent unintended errors.
        z$`flat-layout` detected -- analysing )rr�r��_analyse_flat_packages�_analyse_flat_modulesr�s rr�z$ConfigDiscovery._analyse_flat_layout�s:��	�	�	�8����8H�I�J��*�*�,�L��0J�0J�0L�Lrc�@�tj|j�|j_tt
|jj��}tjd|jj���|j|d�t|�S)Nr�r�)rurDr�r�r��remove_nested_packages�remove_stubsrr��_ensure_no_accidental_inclusionr2)r!�	top_levels  rr�z&ConfigDiscovery._analyse_flat_packages�so��4�9�9�$�.�.�I��	�	��*�<��	�	�8J�8J�+K�L�	��	�	�+�D�I�I�,>�,>�+?�@�A��,�,�Y�
�C��I��rc�@�tj|j�|j_tjd|jj���|j|jjd�t|jj�S)Nr��modules)	r�rDr�r�r�rr�r�r2r�s rr�z%ConfigDiscovery._analyse_flat_modules�sk��5�:�:�4�>�>�J��	�	���	�	�-�d�i�i�.B�.B�-C�D�E��,�,�T�Y�Y�-A�-A�9�M��D�I�I�(�(�)�)rc�l�t|�dkDr&ddlm}ddlm}d|�d|�d|�d�}|||���y)	Nr
r)�cleandoc)�PackageDiscoveryErrorzMultiple top-level z discovered in a flat-layout: z�.

            To avoid accidental inclusion of unwanted files or directories,
            setuptools will not proceed with this build.

            If you are trying to create a single distribution with multiple a�
            on purpose, you should not rely on automatic discovery.
            Instead, consider the following options:

            1. set up custom discovery (`find` directive with `include` or `exclude`)
            2. use a `src-layout`
            3. explicitly set `py_modules` or `packages` with a list of names

            To find more information, look for "package discovery" on setuptools docs.
            )�len�inspectr��setuptools.errorsr�)r!�detected�kindr�r��msgs      rr�z/ConfigDiscovery._ensure_no_accidental_inclusion�sU���x�=�1��(�?�)�$��/M�h�Z�XM�
NR�F�	S
��C�(���
�6�6�)rc��|jjjs|jjrytjd�|j�xs|j
�}|r||jj_yy)z�The packages/modules are the essential contribution of the author.
        Therefore the name of the distribution can be derived from them.
        Nz7No `name` configuration, performing automatic discovery)r��metadatar�rr��#_find_name_single_package_or_module�_find_name_from_packages)r!r�s  rr�zConfigDiscovery.analyse_name�sq���9�9���"�"�d�i�i�n�n���	�	�K�L�
�4�4�6�
/��,�,�.�	
��&*�D�I�I���#�rc��dD]P}t|j|d�xsg}|s�!t|�dk(s�0tjd|d���|dcSy)zExactly one module or package)r�r�Nr
z&Single module/package detected, name: r)�getattrr�r�rr�)r!�fieldr�s   rrz3ConfigDiscovery._find_name_single_package_or_module�s[��/�	 �E��D�I�I�u�d�3�9�r�E���U��q���	�	�B�5��8�*�M�N��Q�x��		 �rc�R�|jjsytt|jjt���}|jj
xsi}t
|||j�}|rtjd|���|Stjd�y)z<Try to find the root package that is not a PEP 420 namespaceN��keyz&Common parent package detected, name: z7No parent package detected, impossible to derive `name`)r�r�r��sortedr�r��find_parent_packager�rr��warn)r!r�r��
parent_pkgs    rrz(ConfigDiscovery._find_name_from_packages�s����y�y�!�!����t�y�y�'9�'9�s� C�D���i�i�+�+�1�r��(��;����O�
���I�I�>�z�l�K�L������J�K�rN)r�rr0r1)r0r)r0�dict[str, str])FTF)r�r2r�r2r�r2r0r1)r�r2r0r2)r0r2)r�rJr�r/)r0r1)r0�
str | None)r3r4r5r6r#r�r��propertyr�r�r,r�r�r�r�r�r�r�r�r�rrr7rrr�r�*s����'��
&��/��/��%��%�RW����)-��JN��	
��.
�
�$�$�2M��*�7�.+�"�rr�c����t|t��}|dd}t|�}tt|��D]1\}�t	�fd�|D��s�|j||z
dz
��3|S)z�Remove nested packages from a list of packages.

    >>> remove_nested_packages(["a", "a.b1", "a.b2", "a.b1.c1"])
    ['a']
    >>> remove_nested_packages(["a", "b", "c.d", "c.d.e.f", "g.h", "a.a1"])
    ['a', 'b', 'c.d', 'g.h']
    r	Nc3�F�K�|]}�j|�d�����y�w�rGN��
startswith)r&�otherr�s  �rr)z)remove_nested_packages.<locals>.<genexpr>s �����C��t���%���{�+�C���!r
)rr��	enumerate�reversedr*r�)r�r�r��size�ir�s     @rr�r�si����(��$�D��Q��I��t�9�D��X�d�^�,�(���4��C��C�C��M�M�$��(�Q�,�'�(��rc�t�|D�cgc](}|jd�djd�r�'|��*c}Scc}w)z�Remove type stubs (:pep:`561`) from a list of packages.

    >>> remove_stubs(["a", "a.b", "a-stubs", "a-stubs.b.c", "b", "c-stubs"])
    ['a', 'a.b', 'b']
    rGrr�)r�r�)r�r�s  rr�r� s2��$�P�C�3�9�9�S�>�!�+<�+E�+E�h�+O�C�P�P��Ps�(5�5c�Z��t|t��}g}t|�D]2\}�t�fd�||dzdD��sn|j	���4|D]R�t�||�}tjj|d�}tjj|�s�P�cSy)z0Find the parent package that is not a namespace.r	c3�F�K�|]}|j��d�����y�wrr)r&r�r�s  �rr)z&find_parent_package.<locals>.<genexpr>0s �����G��1�<�<�4�&��
�+�G�rr
Nrd)
rr�rr�rZ�find_package_pathrrrUre)r�r�r��common_ancestorsr�pkg_path�initr�s       @rrr)s�����h�C�(�H����X�&�&���4��G�X�a�!�e�g�5F�G�G�

�����%�&�!���$�T�;��A���w�w�|�|�H�m�4��
�7�7�>�>�$���K�	�rc�l�|jd�}tt|�dd�D]E}dj|d|�}||vs�||}t	j
j||g||d���cS|j
d�xsd}t	j
j|g|jd��|���S)a�Given a package name, return the path where it should be found on
    disk, considering the ``package_dir`` option.

    >>> path = find_package_path("my.pkg", {"": "root/is/nested"}, ".")
    >>> path.replace(os.sep, "/")
    './root/is/nested/my/pkg'

    >>> path = find_package_path("my.pkg", {"my": "root/is/nested"}, ".")
    >>> path.replace(os.sep, "/")
    './root/is/nested/pkg'

    >>> path = find_package_path("my.pkg", {"my.pkg": "root/is/nested"}, ".")
    >>> path.replace(os.sep, "/")
    './root/is/nested'

    >>> path = find_package_path("other.pkg", {"my.pkg": "root/is/nested"}, ".")
    >>> path.replace(os.sep, "/")
    './other/pkg'
    rGr���Nr��/)r��ranger�rUrrr�)r�r�r��partsr�partial_name�parents       rr r As���,
�J�J�s�O�E�
�3�u�:�q�"�
%�>���x�x��b�q�	�*���;�&� ��.�F��7�7�<�<��&�=�5���9�=�=�>��_�_�R�
 �
&�B�F�
�7�7�<�<��=�6�<�<��#4�=�u�=�=rc
��t|�}t|�j}|D�cic]'}|djg|�|j	d�����)c}Scc}w)Nr&rG)r�r
r(rUr�)r��package_path�parent_pkgs�prefixr�s     r�construct_package_dirr/csQ��(��2�K�
�,�
�
%�
%�F�AL�M�#�C����4�F�4�S�Y�Y�s�^�4�5�5�M�M��Ms�,A)rrr0r2)r�r/r�rr0rJ)r�rJr0rJ)r�rJr��Mapping[str, str]r�rr0r)r�r/r�r0r�rr0r/)r�rJr,rr0r)-r6�
__future__r�	itertoolsr�collections.abcrrr�fnmatchrr	�pathlibr
�typingrr�_distutils_hack.override�_distutils_hackrkr�	distutilsr�distutils.utilr�
setuptoolsr�chain�
from_iterabler�rrr9rOrirmrur�r�r�r�r�rr r/r7rr�<module>r>s��%�N#��	�7�7����*����'��'�
�_�_�
*�
*�
�1�

&�
&� -"�-"�`,A�G�,A�^�-��3�7�3�22T�1�2T�j*�\�*�<B�
a�a�H�$Q����&7��CJ����0>�

�>�-�>�9@�>��>�DNr