o
    jbI                     @  sr  d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ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mZmZ erdddl m!Z! ddl"m#Z# e$e%Z&d8ddZ'd9ddZ(	d:d;d d!Z)	"		d<d=d&d'Z*			d>d?d*d+Z+G d,d- d-Z,d.d/ Z-ed@d0d1Z.G d2d3 d3ej/Z0G d4d5 d5eZ1G d6d7 d7eZ2dS )Aac  
Load setuptools configuration from ``pyproject.toml`` files.

**PRIVATE MODULE**: API reserved for setuptools internal usage only.

To read project metadata, consider using
``build.util.project_wheel_metadata`` (https://pypi.org/project/build/).
For simple scenarios, you can also try parsing the file directly
with the help of ``tomllib`` or ``tomli``.
    )annotationsN)Mapping)contextmanager)partial)TracebackType)TYPE_CHECKINGAnyCallable   )StrPath)	FileErrorInvalidConfigError)SetuptoolsWarning   )expand)_PREVIOUSLY_DEFINED_MissingDynamicapply)SelfDistributionfilepathr   returndictc                 C  sD   ddl m} t| d}||W  d    S 1 sw   Y  d S )Nr
   )tomllibrb)Zcompat.py310r   openload)r   r   file r   `/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py	load_file$   s   $r!   configboolc              
   C  s   ddl m} |jd}t|dr|  z|| W S  |jyR } z*d|j }|j	
ddkr=t| t|j d|j	 d	}t| d
| d d }~ww )Nr   )_validate_pyprojectztrove-classifier_disable_downloadzconfiguration error: `projectzinvalid pyproject.toml config: .
) r$   ZFORMAT_FUNCTIONSgethasattrr%   validateZValidationErrorsummarynamestrip_loggerdebugdetails
ValueError)r"   r   	validatorZtrove_classifierexr.   errorr   r   r    r-   +   s   

r-   Fdistr   ignore_option_errorsc                 C  s   t |d|| }t| ||S )zeApply the configuration from a ``pyproject.toml`` file into an existing
    distribution object.
    T)read_configuration_apply)r8   r   r9   r"   r   r   r    apply_configuration@   s   r<   Tr   Distribution | Nonedict[str, Any]c                   sv  t j| } t j| std| dt| pi }|di }|di }|di }|r2|s4|s4i S d|di v r@t  d|v rJt	jdd	 |rY|j
d
urY|d|j
 n|dd ||d< ||d< d|v rqt	jdd	 d}||dg f t fdd|D rtdt| |d|id}	t|	|  W d
   n1 sw   Y  |rt j| }
t||
||S |S )a  Read given configuration file and returns options from it as a dict.

    :param str|unicode filepath: Path to configuration file in the ``pyproject.toml``
        format.

    :param bool expand: Whether to expand directives and other computed values
        (i.e. post-process the given configuration)

    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.

    :param Distribution|None: Distribution object to which the configuration refers.
        If not given a dummy object will be created and discarded after the
        configuration is read. This is used for auto-discovery of packages and in the
        case a dynamic configuration (e.g. ``attr`` or ``cmdclass``) is expanded.
        When ``expand=False`` this object is simply ignored.

    :rtype: dict
    zConfiguration file z does not exist.r'   tool
setuptoolsZtools	distutilsz[tool.distutils])subjectNzinclude-package-dataTzext-modulesz[tool.setuptools.ext-modules])zimport-nameszimport-namespacesdynamicc                 3  s"    | ]} D ]}||v V  qqd S Nr   ).0fieldZplaceZplacesr   r    	<genexpr>   s     z%read_configuration.<locals>.<genexpr>zSetuptools does not support `import-names` and `import-namespaces` in `pyproject.toml` yet. If your are interested in this feature,  please consider submitting a contribution via pull requests.)r'   r?   )ospathabspathisfiler   r!   r+   _ToolsTypoInMetadataemit_ExperimentalConfigurationZinclude_package_data
setdefaultanyNotImplementedError_ignore_errorsr-   dirnameexpand_configuration)r   r   r9   r8   asdictZproject_tableZ
tool_tableZsetuptools_tablefieldsZsubsetroot_dirr   rG   r    r:   L   sD   
r:   rX   StrPath | Nonec                 C  s   t | ||| S )a  Given a configuration with unresolved fields (e.g. dynamic, cmdclass, ...)
    find their final values.

    :param dict config: Dict containing the configuration for the distribution
    :param str root_dir: Top-level directory for the distribution/project
        (the same directory where ``pyproject.toml`` is place)
    :param bool ignore_option_errors: see :func:`read_configuration`
    :param Distribution|None: Distribution object to which the configuration refers.
        If not given a dummy object will be created and discarded after the
        configuration is read. Used in the case a dynamic configuration
        (e.g. ``attr`` or ``cmdclass``).

    :rtype: dict
    )_ConfigExpanderr   )r"   rX   r9   r8   r   r   r    rU      s   rU   c                   @  s   e Zd Z			d=d>ddZd?ddZd@ddZdAddZdd Zdd Zd d! Z	dBd$d%Z
dCd&d'ZdDd(d)ZdEd+d,ZdFd-d.ZdCd/d0ZdGd2d3ZdHd5d6ZdId7d8ZdId9d:ZdId;d<ZdS )JrZ   NFr"   r   rX   rY   r9   r#   r8   r=   r   Nonec                 C  st   || _ |pt | _|di | _| jdg | _|di di | _| jdi | _|| _	|| _
tt  | _d S )Nr'   rC   r?   r@   )r"   rI   getcwdrX   r+   project_cfgrC   setuptools_cfgdynamic_cfgr9   _distsetstr_referenced_files)selfr"   rX   r9   r8   r   r   r    __init__   s   z_ConfigExpander.__init__r   c                 C  s0   ddl m} | j| jdd d}| jp||S )Nr   r   r/   )Zsrc_rootr/   )setuptools.distr   rX   r]   r+   r`   )rd   r   attrsr   r   r    _ensure_dist   s   z_ConfigExpander._ensure_dist	containerrF   rb   fnr	   c                 C  sL   ||v r$t | j ||| ||< W d    d S 1 sw   Y  d S d S rD   )rS   r9   )rd   ri   rF   rj   r   r   r    _process_field   s
   "z_ConfigExpander._process_fieldpackage-datac                 C  s   | j |i }t|S rD   )r^   r+   _expandZcanonic_package_data)rd   rF   package_datar   r   r    _canonic_package_data   s   
z%_ConfigExpander._canonic_package_datac                 C  s   |    |   | d |  }t|| j| j}|}|j}|   | | | 	|| W d    n1 s8w   Y  |j
| j
 | jS )Nzexclude-package-data)_expand_packagesro   rh   _EnsurePackagesDiscoveredr]   r^   package_dir_expand_data_files_expand_cmdclass_expand_all_dynamicrc   updater"   )rd   r8   ctxZensure_discoveredrr   r   r   r    r      s   

z_ConfigExpander.expandc                 C  s   | j d}|d u st|ttfrd S |d}t|trN| j|d< | j di |d< t| j	 t
jdi || j d< W d    d S 1 sGw   Y  d S d S )NpackagesfindrX   package-dirZfill_package_dirr   )r^   r+   
isinstancelisttupler   rX   rP   rS   r9   rm   Zfind_packages)rd   rx   ry   r   r   r    rp      s   


"z _ConfigExpander._expand_packagesc                 C  s$   t tj| jd}| | jd| d S )N)rX   z
data-files)r   rm   Zcanonic_data_filesrX   rk   r^   )rd   Z
data_filesr   r   r    rs      s   z"_ConfigExpander._expand_data_filesrr   Mapping[str, str]c                 C  s*   | j }ttj||d}| | jd| d S )N)rr   rX   cmdclass)rX   r   rm   r   rk   r^   )rd   rr   rX   r   r   r   r    rt      s   z _ConfigExpander._expand_cmdclassc              	     s   d fddj D }|j pi      d dd | D }j	| d S )N)versionreadmeentry-pointsscriptsgui-scriptsclassifiersdependenciesoptional-dependenciesc                   s$   i | ]}|vr|  |qS r   )_obtainrE   rF   r8   rr   rd   Zspecialr   r    
<dictcomp>  s
    z7_ConfigExpander._expand_all_dynamic.<locals>.<dictcomp>)r   r   r   r   Zoptional_dependenciesc                 S  s   i | ]\}}|d ur||qS rD   r   )rE   kvr   r   r    r     s    )
rC   rv   _obtain_entry_points_obtain_version_obtain_readme_obtain_classifiers_obtain_dependencies_obtain_optional_dependenciesitemsr]   )rd   r8   rr   Zobtained_dynamicZupdatesr   r   r    ru      s   

z#_ConfigExpander._expand_all_dynamicc                 C  s6   t | |}|d u r| jsd|d}t|d S d S )Nz#No configuration found for dynamic z.
Some dynamic fields need to be specified via `tool.setuptools.dynamic`
others must be specified via the equivalent attribute in `setup.py`.)r   r9   r   )rd   r8   rF   previousmsgr   r   r    _ensure_previously_set  s   
z&_ConfigExpander._ensure_previously_set	specifierc                 C  s   ddl m} t| j? | j}d|v r,| j||d  t|d |W  d    S d|v r@t	|d ||W  d    S t
d| d|1 sMw   Y  d S )Nr   )always_iterabler   attrz	invalid `z`: )Zmore_itertoolsr   rS   r9   rX   rc   rv   rm   Z
read_filesZ	read_attrr4   )rd   r   	directiverr   r   rX   r   r   r    _expand_directive$  s   z!_ConfigExpander._expand_directivec                 C  s4   || j v r| d| | j | |S | || d S )Nztool.setuptools.dynamic.)r_   r   r   )rd   r8   rF   rr   r   r   r    r   3  s   
z_ConfigExpander._obtainc                 C  s,   d| j v rd| jv rt| |d|S d S )Nr   )rC   r_   rm   r   r   )rd   r8   rr   r   r   r    r   =  s
   z_ConfigExpander._obtain_versiondict[str, str] | Nonec                 C  sL   d| j vrd S | j}d|v r| |di |d dddS | |d d S )Nr   content-typez
text/x-rst)textr   )rC   r_   r   r+   r   )rd   r8   r_   r   r   r    r   F  s   
z_ConfigExpander._obtain_readme dict[str, dict[str, Any]] | Nonec                   st   d}t fdd|D sd S |d|}|d u rd S t|di d fdd	}|d
d |dd  S )N)r   r   r   c                 3  s    | ]}| j v V  qd S rD   )rC   r   rd   r   r    rH   Y  s    z7_ConfigExpander._obtain_entry_points.<locals>.<genexpr>r   rF   rb   groupc                   s<   |v r |}| jvrtt| || | < d S d S rD   )poprC   r   r   r3   )rF   r   valueexpandedgroupsrd   r   r    _set_scriptsd  s   

z:_ConfigExpander._obtain_entry_points.<locals>._set_scriptsr   console_scriptsr   gui_scripts)rF   rb   r   rb   )rQ   r   rm   entry_points)rd   r8   rr   rW   r   r   r   r   r    r   U  s   


z$_ConfigExpander._obtain_entry_pointsc                 C  s(   d| j v r| |di }|r| S d S )Nr   )rC   r   
splitlinesrd   r8   r   r   r   r    r   p  
   
z#_ConfigExpander._obtain_classifiersc                 C  s(   d| j v r| |di }|rt|S d S )Nr   )rC   r   _parse_requirements_listr   r   r   r    r   w  r   z$_ConfigExpander._obtain_dependenciesc                   sV   d j vrd S d jv r# jd }t|tsJ  fdd| D S  |d d S )Nr   c              	     s*   i | ]\}}|t  d | |i qS )z.tool.setuptools.dynamic.optional-dependencies.)r   r   )rE   r   r   r   r   r    r     s    zA_ConfigExpander._obtain_optional_dependencies.<locals>.<dictcomp>)rC   r_   r{   r   r   r   )rd   r8   Zoptional_dependencies_mapr   r   r    r   ~  s   




z-_ConfigExpander._obtain_optional_dependenciesNFN)
r"   r   rX   rY   r9   r#   r8   r=   r   r[   )r   r   )ri   r   rF   rb   rj   r	   )rl   )rr   r~   )r8   r   rr   r~   )r8   r   rF   rb   )r   rb   rr   r~   )r8   r   rF   rb   rr   r~   )r8   r   r   r   )r8   r   rr   r~   r   r   )r8   r   )__name__
__module____qualname__re   rh   rk   ro   r   rp   rs   rt   ru   r   r   r   r   r   r   r   r   r   r   r   r   r    rZ      s,    











	


rZ   c                 C  s   dd |   D S )Nc                 S  s&   g | ]}|  r|  d s|qS )#)r0   
startswith)rE   liner   r   r    
<listcomp>  s    z,_parse_requirements_list.<locals>.<listcomp>)r   )r   r   r   r    r     s   r   c              
   c  s^    | sd V  d S zd V  W d S  t y. } ztd|jj d|  W Y d }~d S d }~ww )Nzignored error: z - )	Exceptionr1   r2   	__class__r   )r9   r6   r   r   r    rS     s   (rS   c                      s:   e Zd Zd fdd	Zd fddZd fddZ  ZS )rq   distributionr   r]   r   r^   r   r[   c                   s   t  | || _|| _d S rD   )superre   _project_cfg_setuptools_cfg)rd   r   r]   r^   r   r   r    re     s   
z"_EnsurePackagesDiscovered.__init__r   c                   s   | j | j}}|di }||jpi  ||_|j  |jjdu r+| j	
d|j_|jdu r6|
d|_|jdu rA|
d|_t  S )zWhen entering the context, the values of ``packages``, ``py_modules`` and
        ``package_dir`` that are missing in ``dist`` are copied from ``setuptools_cfg``.
        rz   Nr/   
py-modulesrx   )r`   r   rP   rv   rr   set_defaultsZ_ignore_ext_modulesmetadatar/   r   r+   
py_modulesrx   r   	__enter__)rd   r8   cfgrr   r   r   r    r     s   



z#_EnsurePackagesDiscovered.__enter__exc_typetype[BaseException] | None	exc_valueBaseException | None	tracebackTracebackType | Nonec                   s4   | j d| jj | j d| jj t |||S )zWhen exiting the context, if values of ``packages``, ``py_modules`` and
        ``package_dir`` are missing in ``setuptools_cfg``, copy from ``dist``.
        rx   r   )r   rP   r`   rx   r   r   __exit__)rd   r   r   r   r   r   r    r     s   
z"_EnsurePackagesDiscovered.__exit__)r   r   r]   r   r^   r   r   r[   )r   r   )r   r   r   r   r   r   r   r[   )r   r   r   re   r   r   __classcell__r   r   r   r    rq     s    rq   c                   @     e Zd ZdZdS )rO   z``{subject}` in `pyproject.toml` is still *experimental* and likely to change in future releases.Nr   r   r   Z_SUMMARYr   r   r   r    rO         rO   c                   @  r   )rM   zNIgnoring [tools.setuptools] in pyproject.toml, did you mean [tool.setuptools]?Nr   r   r   r   r    rM     r   rM   )r   r   r   r   )r"   r   r   r   r   r#   )F)r8   r   r   r   r9   r#   r   r   )TFN)
r   r   r   r#   r9   r#   r8   r=   r   r>   r   )
r"   r   rX   rY   r9   r#   r8   r=   r   r   )r9   r#   )3__doc__
__future__r   loggingrI   collections.abcr   
contextlibr   	functoolsr   typesr   typingr   r   r	   _pathr   errorsr   r   warningsr   r*   r   rm   Z_apply_pyprojecttomlr   r   r   r;   Ztyping_extensionsr   rf   r   	getLoggerr   r1   r!   r-   r<   r:   rU   rZ   r   rS   ZEnsurePackagesDiscoveredrq   rO   rM   r   r   r   r    <module>   sL    


T ^-