o
    OBi%E  ã                   @   s®  d 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
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ede$fdd„Z%de$dede&fdd„Z'	d/dddeddfdd„Z(			d0deded fdd„Z)			d1de$dee d e&ded de$f
d!d"„Z*G d#d$„ d$ƒZ+d%d&„ Z,ed e&fd'd(„ƒZ-G d)d*„ d*ej.ƒZ/G d+d,„ d,eƒZ0G d-d.„ d.eƒZ1dS )2ac  
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``.
é    N)Úcontextmanager)Úpartial)ÚTYPE_CHECKINGÚCallableÚDictÚMappingÚOptionalÚSeté   )ÚStrPath)Ú	FileErrorÚInvalidConfigError)ÚSetuptoolsWarningé   )Úexpand)Ú_PREVIOUSLY_DEFINEDÚ_MissingDynamic)Úapply©ÚDistribution)ÚSelfÚfilepathÚreturnc                 C   sD   ddl m} t| dƒ�}| |¡W  d   ƒ S 1 sw   Y  d S )Nr
   )ÚtomllibÚrb)Úcompat.py310r   ÚopenÚload)r   r   Úfile© r   ún/var/www/html/Moveonwheels/move_on_wheels/venv/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.pyÚ	load_file    s   $ÿr!   Úconfigc              
   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#   ÚFORMAT_FUNCTIONSÚgetÚhasattrr$   ÚvalidateÚValidationErrorÚsummaryÚnameÚstripÚ_loggerÚdebugÚdetailsÚ
ValueError)r"   r   Ú	validatorÚtrove_classifierÚexr/   Úerrorr   r   r    r-   '   s   

€ør-   FÚdistr   c                 C   s   t |d|| ƒ}t| ||ƒS )zeApply the configuration from a ``pyproject.toml`` file into an existing
    distribution object.
    T)Úread_configurationÚ_apply)r:   r   Úignore_option_errorsr"   r   r   r    Úapply_configuration<   s   r>   Tc           
      C   s6  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	� |r\t
|d
dƒdur\| d|j¡ n| dd¡ ||d< ||d< t|ƒ� |d|idœ}t|| ƒ W d  ƒ n1 s…w   Y  |r™t 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Ú
setuptoolsÚtoolsÚ	distutilsz[tool.distutils])ÚsubjectÚinclude_package_dataNzinclude-package-dataT)r&   r?   )ÚosÚpathÚabspathÚisfiler   r!   r+   Ú_ToolsTypoInMetadataÚemitÚ_ExperimentalConfigurationÚgetattrÚ
setdefaultrD   Ú_ignore_errorsr-   ÚdirnameÚexpand_configuration)
r   r   r=   r:   ÚasdictÚproject_tableÚ
tool_tableÚsetuptools_tableÚsubsetÚroot_dirr   r   r    r;   H   s4   
ýr;   rV   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"   rV   r=   r:   r   r   r    rP   Ž   s   rP   c                
   @   sr  e Zd Z			d3dedee deded fdd	„Zd4dd„Zdede	de
fdd„Zd5dd„Zdd„ Zdd„ Zdd„ Zdee	e	f fdd„Zdddee	e	f fdd„Zddde	fd d!„Zd"e	dee	e	f fd#d$„Zddde	dee	e	f fd%d&„Zdddee	e	f fd'd(„Zddd
eee	e	f  fd)d*„Zdddee	e	f d
eee	ef  fd+d,„Zd6d-d.„Zd6d/d0„Zd6d1d2„ZdS )7rW   NFr"   rV   r=   r:   r   c                 C   sp   || _ |pt ¡ | _| di ¡| _| j dg ¡| _| di ¡ di ¡| _| j di ¡| _|| _	|| _
tƒ | _d S )Nr&   Údynamicr?   r@   )r"   rE   ÚgetcwdrV   r+   Úproject_cfgrX   Úsetuptools_cfgÚdynamic_cfgr=   Ú_distÚsetÚ_referenced_files)Úselfr"   rV   r=   r:   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   r0   )Úsrc_rootr0   )Úsetuptools.distr   rV   rZ   r+   r]   )r`   r   Úattrsr   r   r    Ú_ensure_dist·   s   z_ConfigExpander._ensure_distÚ	containerÚfieldÚfnc                 C   sL   ||v r$t | jƒ� ||| ƒ||< W d   ƒ d S 1 sw   Y  d S d S ©N)rN   r=   )r`   rf   rg   rh   r   r   r    Ú_process_field½   s
   "ÿÿz_ConfigExpander._process_fieldúpackage-datac                 C   s   | j  |i ¡}t |¡S ri   )r[   r+   Ú_expandÚcanonic_package_data)r`   rg   Ú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   re   Ú_EnsurePackagesDiscoveredrZ   r[   Úpackage_dirÚ_expand_data_filesÚ_expand_cmdclassÚ_expand_all_dynamicr_   Úupdater"   )r`   r:   ÚctxÚ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ÚfindrV   úpackage-dirÚfill_package_dirr   )r[   r+   Ú
isinstanceÚlistÚtupleÚdictrV   rM   rN   r=   rl   Úfind_packages)r`   ry   rz   r   r   r    rp   ×   s   


"ÿýz _ConfigExpander._expand_packagesc                 C   s$   t tj| jd�}|  | jd|¡ d S )N)rV   z
data-files)r   rl   Úcanonic_data_filesrV   rj   r[   )r`   Ú
data_filesr   r   r    rs   ã   s   z"_ConfigExpander._expand_data_filesrr   c                 C   s*   | j }ttj||d�}|  | jd|¡ d S )N)rr   rV   Úcmdclass)rV   r   rl   r„   rj   r[   )r`   rr   rV   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©Ú.0rg   ©r:   rr   r`   Úspecialr   r    Ú
<dictcomp>ø   s
    þz7_ConfigExpander._expand_all_dynamic.<locals>.<dictcomp>)r…   r†   rŠ   r‹   Úoptional_dependenciesc                 S   s   i | ]\}}|d ur||“qS ri   r   )r�   ÚkÚvr   r   r    r’     s    )
rX   rv   Ú_obtain_entry_pointsÚ_obtain_versionÚ_obtain_readmeÚ_obtain_classifiersÚ_obtain_dependenciesÚ_obtain_optional_dependenciesÚitemsrZ   )r`   r:   rr   Úobtained_dynamicÚ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   r=   r   )r`   r:   rg   Ú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`: )Ú setuptools.extern.more_itertoolsr£   rN   r=   rV   r_   rv   rl   Ú
read_filesÚ	read_attrr5   )r`   r¢   Ú	directiverr   r£   rV   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¡   )r`   r:   rg   rr   r   r   r    r�   #  s   
ýz_ConfigExpander._obtainc                 C   s,   d| j v rd| jv rt |  |d|¡¡S d S )Nr…   )rX   r\   rl   r…   r�   )r`   r:   rr   r   r   r    r—   -  s   z_ConfigExpander._obtain_versionc                 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ª   )rX   r\   r�   r+   r¡   )r`   r:   r\   r   r   r    r˜   3  s   
þz_ConfigExpander._obtain_readmec                    s|   d}t ‡fdd„|D ƒƒsd S ˆ |d|¡}|d u rd S t |¡‰dˆi‰ dtdtf‡ ‡‡fdd„}|d	d
ƒ |ddƒ ˆ S )N)r‡   rˆ   r‰   c                 3   s   � | ]}|ˆ j v V  qd S ri   )rX   rŽ   ©r`   r   r    Ú	<genexpr>E  s   € z7_ConfigExpander._obtain_entry_points.<locals>.<genexpr>r‡   rg   Úgroupc                    s<   |ˆv rˆ  |¡}| ˆjvrtt | |¡ƒ‚|ˆ | < d S d S ri   )ÚpoprX   r   r   r4   )rg   r®   Úvalue©ÚexpandedÚgroupsr`   r   r    Ú_set_scriptsO  s   

üz:_ConfigExpander._obtain_entry_points.<locals>._set_scriptsrˆ   Úconsole_scriptsr‰   Úgui_scripts)Úanyr�   rl   Úentry_pointsÚstr)r`   r:   rr   Úfieldsr«   r´   r   r±   r    r–   A  s   


z$_ConfigExpander._obtain_entry_pointsc                 C   s(   d| j v r|  |di ¡}|r| ¡ S d S )NrŠ   )rX   r�   Ú
splitlines©r`   r:   r°   r   r   r    r™   [  ó
   
z#_ConfigExpander._obtain_classifiersc                 C   s(   d| j v r|  |di ¡}|rt|ƒS d S )Nr‹   )rX   r�   Ú_parse_requirements_listr¼   r   r   r    rš   b  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©   )r�   r®   r¨   r¬   r   r    r’   o  s    ùýÿÿzA_ConfigExpander._obtain_optional_dependencies.<locals>.<dictcomp>)rX   r\   r}   r€   rœ   r¡   )r`   r:   Úoptional_dependencies_mapr   r¬   r    r›   i  s   



ø
z-_ConfigExpander._obtain_optional_dependencies©NFN)r   r   )rk   )r:   r   )Ú__name__Ú
__module__Ú__qualname__r€   r   r   Úboolra   re   r¹   r   rj   ro   r   rp   rs   r   rt   ru   r¡   r©   r�   r—   r   r˜   r–   r™   rš   r›   r   r   r   r    rW   ¥   sP    ûþýü
û


ÿ

ÿ
ÿ
ÿ
þ

rW   c                 C   s   dd„ |   ¡ D ƒS )Nc                 S   s&   g | ]}|  ¡ r|  ¡  d ¡s|‘qS )ú#)r1   Ú
startswith)r�   Ú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 - )Ú	Exceptionr2   r3   Ú	__class__rÁ   )r=   r8   r   r   r    rN   …  s   €(€ÿrN   c                       sD   e Zd Zdddedef‡ fdd„Zd‡ fd	d
„Z‡ fdd„Z‡  ZS )rq   Údistributionr   rZ   r[   c                    s   t ƒ  |¡ || _|| _d S ri   )Úsuperra   Ú_project_cfgÚ_setuptools_cfg)r`   rË   rZ   r[   ©rÊ   r   r    ra   ’  s   
z"_EnsurePackagesDiscovered.__init__r   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 )z«When entering the context, the values of ``packages``, ``py_modules`` and
        ``package_dir`` that are missing in ``dist`` are copied from ``setuptools_cfg``.
        r{   Nr0   ú
py-modulesry   )r]   rÎ   rM   rv   rr   Úset_defaultsÚ_ignore_ext_modulesÚmetadatar0   rÍ   r+   Ú
py_modulesry   rÌ   Ú	__enter__)r`   r:   Úcfgrr   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``.
        ry   rÐ   )rÎ   rM   r]   ry   rÔ   rÌ   Ú__exit__)r`   Úexc_typeÚ	exc_valueÚ	tracebackrÏ   r   r    r×   ¯  s   z"_EnsurePackagesDiscovered.__exit__)r   r   )rÁ   rÂ   rÃ   r€   ra   rÕ   r×   Ú__classcell__r   r   rÏ   r    rq   ‘  s    ÿÿÿrq   c                   @   ó   e Zd ZdZdS )rK   z``{subject}` in `pyproject.toml` is still *experimental* and likely to change in future releases.N©rÁ   rÂ   rÃ   Ú_SUMMARYr   r   r   r    rK   ¹  ó    ÿrK   c                   @   rÜ   )rI   zNIgnoring [tools.setuptools] in pyproject.toml, did you mean [tool.setuptools]?NrÝ   r   r   r   r    rI   À  rß   rI   )F)TFNrÀ   )2Ú__doc__ÚloggingrE   Ú
contextlibr   Ú	functoolsr   Útypingr   r   r   r   r   r	   Ú_pathr   Úerrorsr   r   Úwarningsr   r)   r   rl   Ú_apply_pyprojecttomlr   r   r   r<   rc   r   Útyping_extensionsr   Ú	getLoggerrÁ   r2   r€   r!   rÄ   r-   r>   r;   rP   rW   r¾   rN   ÚEnsurePackagesDiscoveredrq   rK   rI   r   r   r   r    Ú<module>   sp     
ýÿþ
üüÿ
üHüÿþýü
û Y(