o
    Zh(                  	   @  s  d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZmZmZ ejejejejedd Zejveg  ejd	d ddlZd
dlmZ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& d
dl'm(Z( ddl)Z*ddl+m,Z, g dZ-edddZ.dZ/ej0Z1e j0Z2dd Z3d(ddZ4dd Z5e*j6j5j e5_ erddl)m7Z8 ne9e*j6j7Z8G d d! d!e8Z7d"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    )annotationsN)abstractmethod)Mapping)TYPE_CHECKINGTypeVaroverload
setuptools_vendorZ	backports   )loggingmonkey)Require)PackageFinderPEP420PackageFinder)Distribution)	Extension)__version__)SetuptoolsDeprecationWarning)DistutilsOptionError)setupr   Commandr   r   r   find_packagesfind_namespace_packages	_CommandT_Command)boundc                 C  s>   G dd dt jj}|| }|jdd |jrt| d S d S )Nc                      s8   e Zd ZdZd 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.
        attrsMapping[str, object]returnNonec                   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r   r!   J/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/__init__.py
<dictcomp>A   s    zQ_install_setup_requires.<locals>.MinimalDistribution.__init__.<locals>.<dictcomp>)setsuper__init__set_defaults_disable)selfr   Z_inclfiltered	__class__r$   r%   r)   ?   s   z=_install_setup_requires.<locals>.MinimalDistribution.__init__Nc                   s6   zt  |\}}W |dfS  ty   |df Y S w )zAIgnore ``pyproject.toml``, they are not related to setup_requiresr!   )r(   Z _split_standard_project_metadata	Exception)r,   	filenamescfgZ_tomlr.   r!   r%   _get_project_config_filesF   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_optionsN   s    zE_install_setup_requires.<locals>.MinimalDistribution.finalize_options)r   r   r   r   N)__name__
__module____qualname____doc__r)   r3   r5   __classcell__r!   r!   r.   r%   MinimalDistribution9   s
    r<   T)Zignore_option_errors)	distutilscorer   Zparse_config_filesr    _fetch_build_eggs)r   r<   distr!   r!   r%   _install_setup_requires6   s   rA   r@   r   c              
   C  sf   z	|  | j W d S  ty2 } zd}d|jjv r-t|dr$||  | d| d  d }~ww )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    r0   r/   r7   hasattrrC   Zannounce)r@   exmsgr!   r!   r%   r?   \   s   	

r?   c                  K  s"   t   t|  tjjdi | S )Nr!   )r   	configurerA   r=   r>   r   r$   r!   r!   r%   r   q   s   r   )r   c                      s   e Zd ZU dZdZded< d! fdd	Zd"ddZd#ddZe		d$d%ddZ
e		d$d&ddZ
	d$d'ddZ
ed(ddZed(ddZe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:
    :meth:`initialize_options`, :meth:`finalize_options` and :meth:`run`.

    A useful analogy for command classes is to think of them as subroutines with local
    variables called "options".  The options are "declared" in :meth:`initialize_options`
    and "defined" (given their final values, aka "finalized") in :meth:`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 :meth:`run` method.
    Between :meth:`initialize_options` and :meth:`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
    :meth:`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 :meth:`initialize_options` and
    :meth:`finalize_options`. For example, all derived attributes (or attributes that
    depend on the value of other attributes) **SHOULD** be recomputed in
    :meth:`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.
    Fr   distributionr@   r   r   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,   r@   kwr.   r!   r%   r)      s   zCommand.__init__Nc                 C  sL   t | |}|d u rt| || |S t|ts$td| d| d| d|S )N'z' must be a z (got `z`))getattrsetattr
isinstancestrr   )r,   optionwhatdefaultvalr!   r!   r%   _ensure_stringlike   s   

zCommand._ensure_stringlikerR   rQ   c                 C  sx   t | |}|du rdS t|trt| |td| dS t|tr+tdd |D }nd}|s:td| d|d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 r6   )rP   rQ   )r"   vr!   r!   r%   	<genexpr>   s    z-Command.ensure_string_list.<locals>.<genexpr>FrM   z!' must be a list of strings (got ))	rN   rP   rQ   rO   resplitlistallr   )r,   rR   rU   okr!   r!   r%   ensure_string_list   s   


zCommand.ensure_string_listcommandreinit_subcommandsboolr   c                 K     d S r6   r!   r,   r`   ra   rL   r!   r!   r%   reinitialize_command      zCommand.reinitialize_commandr   c                 K  rc   r6   r!   rd   r!   r!   r%   re      rf   str | _Commandc                 K  s    t | ||}t|| |S r6   )r   re   rJ   rK   )r,   r`   ra   rL   cmdr!   r!   r%   re      s   c                 C     t )z
        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.
        NotImplementedErrorr4   r!   r!   r%   initialize_options      zCommand.initialize_optionsc                 C  ri   )z
        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``).
        rj   r4   r!   r!   r%   r5      rm   zCommand.finalize_optionsc                 C  ri   )z
        Execute the actions intended by the command.
        (Side effects **SHOULD** only take place when :meth:`run` is executed,
        for example, creating new files or writing to the terminal output).
        rj   r4   r!   r!   r%   run   rm   zCommand.run)r@   r   r   r   r6   )rR   rQ   r   r   )F)r`   rQ   ra   rb   r   r   )r`   r   ra   rb   r   r   )r`   rg   ra   rb   r   r   )r   r   )r7   r8   r9   r:   Zcommand_consumes_arguments__annotations__r)   rV   r_   r   re   r   rl   r5   rn   r;   r!   r!   r.   r%   r      s*   
 %

	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 r6   )ospathjoin)r"   basedirsfilesfiler!   r!   r%   rX     s    z#_find_all_simple.<locals>.<genexpr>T)followlinks)rp   walkfilterrq   isfile)rq   resultsr!   r!   r%   _find_all_simple  s   r|   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)	r|   rp   curdir	functoolspartialrq   relpathmapr\   )dirru   Zmake_relr!   r!   r%   findall  s
   

r   c                   @  s   e Zd ZdZdS )sicz;Treat this string as-is (https://en.wikipedia.org/wiki/Sic)N)r7   r8   r9   r:   r!   r!   r!   r%   r     s    r   )r@   r   )@r:   
__future__r   r   rp   rZ   sysabcr   collections.abcr   typingr   r   r   rq   extendrr   dirname__file__Zvendor_pathmodulespopZ_distutils_hack.override_distutils_hack r   r   Zdependsr   Z	discoveryr   r   r@   r   	extensionr   versionr   warningsr   Zdistutils.corer=   Zdistutils.errorsr   __all__r   Zbootstrap_install_fromfindr   r   rA   r?   r   r>   r   r   Zget_unpatchedr|   r~   r   rQ   r   Z	patch_allr!   r!   r!   r%   <module>   sN    8
& 