a
    ñ»jõD  ã                   @  s€  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
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 ddlmZ e
r¸ddlmZ ddlmZ e  e!¡Z"dddœdd„Z#ddddœdd„Z$d5ddddœdd„Z%d6dd d!œd"d#„Z&d7dd$dd dd%œd&d'„Z'G d(d)„ d)ƒZ(d*d+„ Z)edd,œd-d.„ƒZ*G d/d0„ d0ej+ƒZ,G d1d2„ d2eƒZ-G d3d4„ d4eƒZ.dS )8ac  
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)Úcontextmanager)Úpartial)ÚTYPE_CHECKINGÚCallableÚMappingé   )ÚStrPath)Ú	FileErrorÚInvalidConfigError)ÚSetuptoolsWarningé   )Úexpand)Ú_PREVIOUSLY_DEFINEDÚ_MissingDynamic)Úapply©ÚDistribution)ÚSelfr	   Údict)ÚfilepathÚreturnc                 C  sD   ddl m} t| dƒ�}| |¡W  d   ƒ S 1 s60    Y  d S )Nr   )ÚtomllibÚrb)Zcompat.py310r   ÚopenÚload)r   r   Úfile© r   úEE:\soccer\ml_env\Lib\site-packages\setuptools/config/pyprojecttoml.pyÚ	load_file"   s    r   Úbool)Úconfigr   r   c              
   C  s¶   ddl m} |j d¡}t|dƒr*| ¡  z| | ¡W S  |jy° } z`d|j› �}|j	 
d¡dkrzt |¡ t |j¡ d|j	› d	�}t|› d
|› �ƒd ‚W Y d }~n
d }~0 0 d S )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+   Fr   )Údistr   r   c                 C  s   t |d|| ƒ}t| ||ƒS )zeApply the configuration from a ``pyproject.toml`` file into an existing
    distribution object.
    T)Úread_configurationÚ_apply)r6   r   Úignore_option_errorsr!   r   r   r   Úapply_configuration>   s    r:   TúDistribution | None)r   r6   c           
      C  s:  t j | ¡} t j | ¡s(td| ›d�ƒ‚t| ƒp2i }| di ¡}| di ¡}| di ¡}|rd|sh|shi S d| di ¡v r€t ¡  d|v r”t	jdd	� |r¸t
|d
dƒdur¸| d|j¡ n| dd¡ ||d< ||d< t|ƒ�( |d|idœ}t|| ƒ W d  ƒ n1 �s0    Y  |�r6t 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])ÚsubjectÚinclude_package_dataNzinclude-package-dataT)r%   r<   )ÚosÚpathÚabspathÚisfiler
   r   r)   Ú_ToolsTypoInMetadataÚemitÚ_ExperimentalConfigurationÚgetattrÚ
setdefaultr@   Ú_ignore_errorsr+   ÚdirnameÚexpand_configuration)
r   r   r9   r6   ÚasdictZproject_tableZ
tool_tableZsetuptools_tableZsubsetÚroot_dirr   r   r   r7   J   s2    
*r7   úStrPath | None)r!   rN   r9   r6   r   c                 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!   rN   r9   r6   r   r   r   rL   �   s    rL   c                   @  s  e Zd Zd=dddddœdd	„Zd
dœdd„Zddddœdd„Zd>dd„Zdd„ Zdd„ Zdd„ Z	ddœdd„Z
d
dd œd!d"„Zd
dd#œd$d%„Zddd&œd'd(„Zd
ddd)œd*d+„Zd
dd œd,d-„Zd
d.d/œd0d1„Zd
dd2d3œd4d5„Zd
d6œd7d8„Zd
d6œd9d:„Zd
d6œd;d<„ZdS )?rP   NFr   rO   r    r;   rQ   c                 C  sp   || _ |pt ¡ | _| di ¡| _| j dg ¡| _| di ¡ di ¡| _| j di ¡| _|| _	|| _
tƒ | _d S )Nr%   Údynamicr<   r=   )r!   rA   ÚgetcwdrN   r)   Úproject_cfgrR   Úsetuptools_cfgÚdynamic_cfgr9   Ú_distÚsetÚ_referenced_files)Úselfr!   rN   r9   r6   r   r   r   Ú__init__¨   s    z_ConfigExpander.__init__r   ©r   c                 C  s0   ddl m} | j| j dd ¡dœ}| jp.||ƒS )Nr   r   r-   )Zsrc_rootr-   )Úsetuptools.distr   rN   rT   r)   rW   )rZ   r   Úattrsr   r   r   Ú_ensure_dist¹   s    z_ConfigExpander._ensure_distÚstrr   )Ú	containerÚfieldÚfnc                 C  sF   ||v rBt | jƒ�  ||| ƒ||< W d   ƒ n1 s80    Y  d S ©N)rJ   r9   )rZ   ra   rb   rc   r   r   r   Ú_process_field¿   s    z_ConfigExpander._process_fieldúpackage-datac                 C  s   | j  |i ¡}t |¡S rd   )rU   r)   Ú_expandZcanonic_package_data)rZ   rb   Úpackage_datar   r   r   Ú_canonic_package_dataÄ   s    z%_ConfigExpander._canonic_package_datac                 C  sŽ   |   ¡  |  ¡  |  d¡ |  ¡ }t|| j| jƒ}|�4}|j}|  ¡  |  |¡ |  	||¡ W d   ƒ n1 sp0    Y  |j
 | j
¡ | jS )Nzexclude-package-data)Ú_expand_packagesri   r_   Ú_EnsurePackagesDiscoveredrT   rU   Úpackage_dirÚ_expand_data_filesÚ_expand_cmdclassÚ_expand_all_dynamicrY   Úupdater!   )rZ   r6   ÚctxZensure_discoveredrl   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ƒr–| j|d< | j  di ¡|d< t| j	ƒ�& t
jf i |¤Ž| j d< W d   ƒ n1 sŒ0    Y  d S )NÚpackagesÚfindrN   úpackage-dirZfill_package_dir)rU   r)   Ú
isinstanceÚlistÚtupler   rN   rI   rJ   r9   rg   Zfind_packages)rZ   rr   rs   r   r   r   rj   Ù   s    


z _ConfigExpander._expand_packagesc                 C  s$   t tj| jd�}|  | jd|¡ d S )N)rN   z
data-files)r   rg   Zcanonic_data_filesrN   re   rU   )rZ   Ú
data_filesr   r   r   rm   å   s    z"_ConfigExpander._expand_data_fileszMapping[str, str])rl   c                 C  s*   | j }ttj||d�}|  | jd|¡ d S )N)rl   rN   Úcmdclass)rN   r   rg   ry   re   rU   )rZ   rl   rN   ry   r   r   r   rn   é   s    z _ConfigExpander._expand_cmdclass)r6   rl   c              	     s‚   d‰‡ ‡‡‡fdd„ˆj D ƒ}|jˆ ˆ ˆ¡p0i ˆ ˆ ˆ¡ˆ ˆ ¡ˆ ˆ ¡ˆ ˆ ¡ˆ ˆ ¡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©Ú.0rb   ©r6   rl   rZ   Zspecialr   r   Ú
<dictcomp>ú   s   þz7_ConfigExpander._expand_all_dynamic.<locals>.<dictcomp>)rz   r{   r   r€   Zoptional_dependenciesc                 S  s   i | ]\}}|d ur||“qS rd   r   )r„   ÚkÚvr   r   r   r†   	  ó    )
rR   rp   Ú_obtain_entry_pointsÚ_obtain_versionÚ_obtain_readmeÚ_obtain_classifiersÚ_obtain_dependenciesÚ_obtain_optional_dependenciesÚitemsrT   )rZ   r6   rl   Zobtained_dynamicZupdatesr   r…   r   ro   î   s    þ
ú
z#_ConfigExpander._expand_all_dynamic)r6   rb   c                 C  s2   t | |ƒ}|d u r.| js.d|›d�}t|ƒ‚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   )rZ   r6   rb   ÚpreviousÚmsgr   r   r   Ú_ensure_previously_set  s
    
ÿz&_ConfigExpander._ensure_previously_set)Ú	specifierrl   c                 C  s¶   ddl m} t| jƒ�Œ | j}d|v rX| j ||d ƒ¡ t |d |¡W  d   ƒ S d|v r€t 	|d ||¡W  d   ƒ S t
d|› d|›�ƒ‚W d   ƒ n1 s¨0    Y  d S )Nr   )Úalways_iterabler   Úattrz	invalid `z`: )Z setuptools.extern.more_itertoolsr•   rJ   r9   rN   rY   rp   rg   Z
read_filesZ	read_attrr2   )rZ   r”   Ú	directiverl   r•   rN   r   r   r   Ú_expand_directive  s     2z!_ConfigExpander._expand_directive)r6   rb   rl   c                 C  s4   || j v r$|  d|› �| j | |¡S |  ||¡ d S )Nztool.setuptools.dynamic.)rV   r˜   r“   )rZ   r6   rb   rl   r   r   r   r‚   %  s    
ýz_ConfigExpander._obtainc                 C  s,   d| j v r(d| jv r(t |  |d|¡¡S d S )Nrz   )rR   rV   rg   rz   r‚   )rZ   r6   rl   r   r   r   r‹   /  s    z_ConfigExpander._obtain_versionzdict[str, str] | None)r6   r   c                 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™   )rR   rV   r‚   r)   r“   )rZ   r6   rV   r   r   r   rŒ   5  s    
þz_ConfigExpander._obtain_readmezdict[str, dict] | None)r6   rl   r   c                   sz   d}t ‡fdd„|D ƒƒsd S ˆ |d|¡}|d u r8d S t |¡‰dˆi‰ dddœ‡ ‡‡fdd„}|d	d
ƒ |ddƒ ˆ S )N)r|   r}   r~   c                 3  s   | ]}|ˆ j v V  qd S rd   )rR   rƒ   ©rZ   r   r   Ú	<genexpr>G  r‰   z7_ConfigExpander._obtain_entry_points.<locals>.<genexpr>r|   r`   )rb   Úgroupc                   s8   |ˆv r4ˆ  |¡}| ˆjvr,tt | |¡ƒ‚|ˆ | < d S rd   )ÚpoprR   r   r   r1   )rb   r�   Úvalue©ÚexpandedÚgroupsrZ   r   r   Ú_set_scriptsQ  s
    

z:_ConfigExpander._obtain_entry_points.<locals>._set_scriptsr}   Úconsole_scriptsr~   Úgui_scripts)Úanyr‚   rg   Úentry_points)rZ   r6   rl   Úfieldsrš   r£   r   r    r   rŠ   C  s    


z$_ConfigExpander._obtain_entry_points)r6   c                 C  s(   d| j v r$|  |di ¡}|r$| ¡ S d S )Nr   )rR   r‚   Ú
splitlines©rZ   r6   rŸ   r   r   r   r�   ]  s
    
z#_ConfigExpander._obtain_classifiersc                 C  s(   d| j v r$|  |di ¡}|r$t|ƒS d S )Nr€   )rR   r‚   Ú_parse_requirements_listrª   r   r   r   rŽ   d  s
    
z$_ConfigExpander._obtain_dependenciesc                   sV   dˆ j vrd S dˆ jv rFˆ jd }t|tƒs0J ‚‡ 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˜   )r„   r�   r—   r›   r   r   r†   q  s   ùýÿzA_ConfigExpander._obtain_optional_dependencies.<locals>.<dictcomp>)rR   rV   ru   r   r�   r“   )rZ   r6   Zoptional_dependencies_mapr   r›   r   r�   k  s    



ø
z-_ConfigExpander._obtain_optional_dependencies)NFN)rf   )Ú__name__Ú
__module__Ú__qualname__r[   r_   re   ri   r   rj   rm   rn   ro   r“   r˜   r‚   r‹   rŒ   rŠ   r�   rŽ   r�   r   r   r   r   rP   §   s*      û


rP   c                 C  s   dd„ |   ¡ D ƒS )Nc                 S  s&   g | ]}|  ¡ r|  ¡  d ¡s|‘qS )ú#)r.   Ú
startswith)r„   Úliner   r   r   Ú
<listcomp>€  s   þz,_parse_requirements_list.<locals>.<listcomp>)r©   )rŸ   r   r   r   r«     s    þr«   )r9   c              
   c  s\   | sd V  d S z
d V  W n> t yV } z&t d|jj› d|› �¡ W Y d }~n
d }~0 0 d S )Nzignored error: z - )Ú	Exceptionr/   r0   Ú	__class__r¬   )r9   r4   r   r   r   rJ   ‡  s    
rJ   c                      sD   e Zd Zddddœ‡ fdd„Zddœ‡ fdd	„Z‡ fd
d„Z‡  ZS )rk   r   r   )ÚdistributionrT   rU   c                   s   t ƒ  |¡ || _|| _d S rd   )Úsuperr[   Ú_project_cfgÚ_setuptools_cfg)rZ   rµ   rT   rU   ©r´   r   r   r[   ”  s    z"_EnsurePackagesDiscovered.__init__r   r\   c                   sŒ   | j | j }}| di ¡}| |jp&i ¡ ||_|j ¡  |jjdu rV| j	 
d¡|j_|jdu rl| 
d¡|_|jdu r‚| 
d¡|_tƒ  ¡ S )z«When entering the context, the values of ``packages``, ``py_modules`` and
        ``package_dir`` that are missing in ``dist`` are copied from ``setuptools_cfg``.
        rt   Nr-   ú
py-modulesrr   )rW   r¸   rI   rp   rl   Úset_defaultsZ_ignore_ext_modulesÚmetadatar-   r·   r)   Ú
py_modulesrr   r¶   Ú	__enter__)rZ   r6   Úcfgrl   r¹   r   r   r¾   ›  s    


z#_EnsurePackagesDiscovered.__enter__c                   s4   | j  d| jj¡ | j  d| jj¡ tƒ  |||¡S )zŸWhen exiting the context, if values of ``packages``, ``py_modules`` and
        ``package_dir`` are missing in ``setuptools_cfg``, copy from ``dist``.
        rr   rº   )r¸   rI   rW   rr   r½   r¶   Ú__exit__)rZ   Úexc_typeÚ	exc_valueÚ	tracebackr¹   r   r   rÀ   ±  s    z"_EnsurePackagesDiscovered.__exit__)r¬   r­   r®   r[   r¾   rÀ   Ú__classcell__r   r   r¹   r   rk   “  s   rk   c                   @  s   e Zd ZdZdS )rG   z``{subject}` in `pyproject.toml` is still *experimental* and likely to change in future releases.N©r¬   r­   r®   Z_SUMMARYr   r   r   r   rG   »  s   ÿrG   c                   @  s   e Zd ZdZdS )rE   zNIgnoring [tools.setuptools] in pyproject.toml, did you mean [tool.setuptools]?NrÅ   r   r   r   r   rE   Â  s   ÿrE   )F)TFN)NFN)/Ú__doc__Ú
__future__r   ÚloggingrA   Ú
contextlibr   Ú	functoolsr   Útypingr   r   r   Ú_pathr	   Úerrorsr
   r   Úwarningsr   r(   r   rg   Z_apply_pyprojecttomlr   r   r   r8   r]   r   Ztyping_extensionsr   Ú	getLoggerr¬   r/   r   r+   r:   r7   rL   rP   r«   rJ   ZEnsurePackagesDiscoveredrk   rG   rE   r   r   r   r   Ú<module>   sH   
 ý   üH   ü Y(