a
    ñ»jö"  ã                   @   s@  d Z ddlZddlZddlZddlmZ ddlZddlZ	ddl
mZ ddlmZmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZ ddlmZ ddlmZ g d¢ZejZdZejZ ejZ!dd„ Z"dd„ Z#dd„ Z$e	j%j$j e$_ erðe	j%j&Z'ne (e	j%j&¡Z'G dd„ de'ƒZ&dd„ Z)ej*fdd„Z+G dd„ de,ƒZ-e .¡  dS )z@Extensions to the 'distutils' for large or complex distributionsé    N)ÚTYPE_CHECKING)ÚDistutilsOptionErroré   )ÚloggingÚmonkey)Úversion)ÚRequire)ÚPackageFinderÚPEP420PackageFinder)ÚDistribution)Ú	Extension)ÚSetuptoolsDeprecationWarning)Úsetupr   ÚCommandr   r   r   Úfind_packagesÚfind_namespace_packagesc                 C   s:   G dd„ dt jjƒ}|| ƒ}|jdd� |jr6t|ƒ d S )Nc                       s6   e Zd ZdZ‡ fdd„Zd	‡ fdd„	Zdd„ Z‡  ZS )
z4_install_setup_requires.<locals>.MinimalDistributionzl
        A minimal version of a distribution for supporting the
        fetch_build_eggs interface.
        c                    s<   d}‡ fdd„t |ƒt ˆ ƒ@ D ƒ}tƒ  |¡ | j ¡  d S )N)Zdependency_linksÚsetup_requiresc                    s   i | ]}|ˆ | “qS © r   )Ú.0Úk©Úattrsr   ú9E:\soccer\ml_env\Lib\site-packages\setuptools/__init__.pyÚ
<dictcomp>3   ó    zQ_install_setup_requires.<locals>.MinimalDistribution.__init__.<locals>.<dictcomp>)ÚsetÚsuperÚ__init__Úset_defaultsÚ_disable)Úselfr   Z_inclÚfiltered©Ú	__class__r   r   r   1   s    z=_install_setup_requires.<locals>.MinimalDistribution.__init__Nc                    s8   zt ƒ  |¡\}}W n ty.   |df Y S 0 |dfS )zAIgnore ``pyproject.toml``, they are not related to setup_requiresr   )r   Z _split_standard_project_metadataÚ	Exception)r    Ú	filenamesÚcfgÚtomlr"   r   r   Ú_get_project_config_files8   s
    zN_install_setup_requires.<locals>.MinimalDistribution._get_project_config_filesc                 S   s   dS )zl
            Disable finalize_options to avoid building the working set.
            Ref #2158.
            Nr   )r    r   r   r   Úfinalize_options@   s    zE_install_setup_requires.<locals>.MinimalDistribution.finalize_options)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r(   r)   Ú__classcell__r   r   r"   r   ÚMinimalDistribution+   s   r/   T)Zignore_option_errors)Ú	distutilsÚcorer   Úparse_config_filesr   Ú_fetch_build_eggs)r   r/   Údistr   r   r   Ú_install_setup_requires(   s
    r5   c              
   C   st   z|   | j¡ W n^ tyn } zFd}d|jjv rXt|dƒrF| |¡ n|  d|› d�¡ ‚ W Y d }~n
d }~0 0 d S )Na–  
        It is possible a package already installed in your system
        contains an version that is invalid according to PEP 440.
        You can try `pip install --use-pep517` as a workaround for this problem,
        or rely on a new virtual environment.

        If the problem refers to a package that is not installed yet,
        please contact that package's maintainers or distributors.
        ÚInvalidVersionÚadd_noteÚ
)Zfetch_build_eggsr   r$   r#   r*   Úhasattrr7   Úannounce)r4   ÚexÚmsgr   r   r   r3   N   s    	
r3   c                  K   s"   t  ¡  t| ƒ tjjf i | ¤ŽS ©N)r   Ú	configurer5   r0   r1   r   r   r   r   r   r   c   s    r   c                       sP   e Zd ZU dZdZeed< edœ‡ fdd„Zddd	„Zd
d„ Z	ddd„Z
‡  ZS )r   a›
  
    Setuptools internal actions are organized using a *command design pattern*.
    This means that each action (or group of closely related actions) executed during
    the build should be implemented as a ``Command`` subclass.

    These commands are abstractions and do not necessarily correspond to a command that
    can (or should) be executed via a terminal, in a CLI fashion (although historically
    they would).

    When creating a new command from scratch, custom defined classes **SHOULD** inherit
    from ``setuptools.Command`` and implement a few mandatory methods.
    Between these mandatory methods, are listed:

    .. method:: initialize_options(self)

        Set or (reset) all options/attributes/caches used by the command
        to their default values. Note that these values may be overwritten during
        the build.

    .. method:: finalize_options(self)

        Set final values for all options/attributes used by the command.
        Most of the time, each option/attribute/cache should only be set if it does not
        have any value yet (e.g. ``if self.attr is None: self.attr = val``).

    .. method:: run(self)

        Execute the actions intended by the command.
        (Side effects **SHOULD** only take place when ``run`` is executed,
        for example, creating new files or writing to the terminal output).

    A useful analogy for command classes is to think of them as subroutines with local
    variables called "options".  The options are "declared" in ``initialize_options()``
    and "defined" (given their final values, aka "finalized") in ``finalize_options()``,
    both of which must be defined by every command class. The "body" of the subroutine,
    (where it does all the work) is the ``run()`` method.
    Between ``initialize_options()`` and ``finalize_options()``, ``setuptools`` may set
    the values for options/attributes based on user's input (or circumstance),
    which means that the implementation should be careful to not overwrite values in
    ``finalize_options`` unless necessary.

    Please note that other commands (or other parts of setuptools) may also overwrite
    the values of the command's options/attributes multiple times during the build
    process.
    Therefore it is important to consistently implement ``initialize_options()`` and
    ``finalize_options()``. For example, all derived attributes (or attributes that
    depend on the value of other attributes) **SHOULD** be recomputed in
    ``finalize_options``.

    When overwriting existing commands, custom defined classes **MUST** abide by the
    same APIs implemented by the original class. They also **SHOULD** inherit from the
    original class.
    FÚdistribution)r4   c                    s   t ƒ  |¡ t| ƒ |¡ dS )zj
        Construct the command for dist, updating
        vars(self) with any keyword parameters.
        N)r   r   ÚvarsÚupdate)r    r4   Úkwr"   r   r   r   ­   s    zCommand.__init__Nc                 C   sB   t | |ƒ}|d u r"t| ||ƒ |S t|tƒs>td|||f ƒ‚|S )Nz'%s' must be a %s (got `%s`))ÚgetattrÚsetattrÚ
isinstanceÚstrr   )r    ÚoptionÚwhatÚdefaultÚvalr   r   r   Ú_ensure_stringlikeµ   s    

ÿzCommand._ensure_stringlikec                 C   sp   t | |ƒ}|du rdS t|tƒr6t| |t d|¡ƒ n6t|tƒrTtdd„ |D ƒƒ}nd}|sltd||f ƒ‚dS )a¼  Ensure that 'option' is a list of strings.  If 'option' is
        currently a string, we split it either on /,\s*/ or /\s+/, so
        "foo bar baz", "foo,bar,baz", and "foo,   bar baz" all become
        ["foo", "bar", "baz"].

        ..
           TODO: This method seems to be similar to the one in ``distutils.cmd``
           Probably it is just here for backward compatibility with old Python versions?

        :meta private:
        Nz,\s*|\s+c                 s   s   | ]}t |tƒV  qd S r=   )rE   rF   )r   Úvr   r   r   Ú	<genexpr>Ó   r   z-Command.ensure_string_list.<locals>.<genexpr>Fz''%s' must be a list of strings (got %r))	rC   rE   rF   rD   ÚreÚsplitÚlistÚallr   )r    rG   rJ   Úokr   r   r   Úensure_string_listÀ   s    



ÿzCommand.ensure_string_listc                 K   s    t  | ||¡}t|ƒ |¡ |S r=   )Ú_CommandÚreinitialize_commandr@   rA   )r    ÚcommandÚreinit_subcommandsrB   Úcmdr   r   r   rU   Û   s    zCommand.reinitialize_command)N)F)r*   r+   r,   r-   Zcommand_consumes_argumentsr   Ú__annotations__r   rK   rS   rU   r.   r   r   r"   r   r   s   s   
6
r   c                 C   s&   dd„ t j| dd�D ƒ}tt jj|ƒS )z%
    Find all files under 'path'
    c                 s   s,   | ]$\}}}|D ]}t j ||¡V  qqd S r=   )ÚosÚpathÚjoin)r   ÚbaseÚdirsÚfilesÚfiler   r   r   rM   å   s   þz#_find_all_simple.<locals>.<genexpr>T)Úfollowlinks)rZ   ÚwalkÚfilterr[   Úisfile)r[   Úresultsr   r   r   Ú_find_all_simpleá   s    þrf   c                 C   s6   t | ƒ}| tjkr.tjtjj| d�}t||ƒ}t|ƒS )zŒ
    Find all files under 'dir' and return the list of full filenames.
    Unless dir is '.', return full filenames with dir prepended.
    )Ústart)	rf   rZ   ÚcurdirÚ	functoolsÚpartialr[   ÚrelpathÚmaprP   )Údirr_   Zmake_relr   r   r   Úfindallí   s
    

rn   c                   @   s   e Zd ZdZdS )Úsicz;Treat this string as-is (https://en.wikipedia.org/wiki/Sic)N)r*   r+   r,   r-   r   r   r   r   ro   ù   s   ro   )/r-   ri   rZ   rN   Útypingr   Z_distutils_hack.overrideÚ_distutils_hackÚdistutils.corer0   Údistutils.errorsr   Ú r   r   r   Z_version_moduleÚdependsr   Z	discoveryr	   r
   r4   r   Ú	extensionr   Úwarningsr   Ú__all__Ú__version__Zbootstrap_install_fromÚfindr   r   r5   r3   r   r1   r   rT   Zget_unpatchedrf   rh   rn   rF   ro   Z	patch_allr   r   r   r   Ú<module>   s>   &
n