o
    *‘siJ  ã                   @   s¾  d 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mZmZ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 e	rNddlmZ eeejf 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'de"de"ded de$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 )2z„
Load setuptools configuration from ``pyproject.toml`` files.

**PRIVATE MODULE**: API reserved for setuptools internal usage only.
é    N)Úcontextmanager)Úpartial)ÚTYPE_CHECKINGÚCallableÚDictÚOptionalÚMappingÚUnion)Ú	FileErrorÚOptionErroré   )Úexpand)Úapply)Ú_PREVIOUSLY_DEFINEDÚ_WouldIgnoreField©ÚDistributionÚfilepathÚreturnc                 C   sD   ddl m} t| dƒ�}| |¡W  d   ƒ S 1 sw   Y  d S )Nr   )ÚtomliÚrb)Zsetuptools.externr   ÚopenÚload)r   r   Úfile© r   ú„C:\Users\PC\students\dividedattentionclub\pushnotificationexperiment\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yB } zt 	d|j
› �¡ t |j¡ td|j› �ƒ}|d ‚d }~ww )Nr   )Ú_validate_pyprojectztrove-classifierÚ_disable_downloadzconfiguration error: zinvalid pyproject.toml config: )Ú r   ZFORMAT_FUNCTIONSÚgetÚhasattrr   ÚvalidateZValidationErrorÚ_loggerÚerrorÚsummaryÚdebugÚdetailsÚ
ValueErrorÚname)r   r   Ú	validatorZtrove_classifierÚexr%   r   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_configuration2   s   r1   Tc              
   C   sd  t j | ¡} t j | ¡std| ›d�ƒ‚t| ƒpi }| di ¡}| di ¡}| di ¡}|r2|s4|s4i S |r>d}t |t	¡ | 
¡ }	|rSt|dƒdurS| d	|j¡ n| d	d
¡ ||d< ||d< z|d|idœ}
t|
| ƒ W n1 ty  } z%t||	|ƒr…i W  Y d}~S |r•t d|jj› d|› �¡ n‚ W Y d}~nd}~ww |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 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.ÚprojectÚtoolÚ
setuptoolszDSupport for `[tool.setuptools]` in `pyproject.toml` is still *beta*.Úinclude_package_dataNzinclude-package-dataT)r2   r3   úignored error: ú - )ÚosÚpathÚabspathÚisfiler
   r   r!   ÚwarningsÚwarnÚ_BetaConfigurationÚcopyÚgetattrÚ
setdefaultr5   r#   Ú	ExceptionÚ_skip_bad_configr$   r'   Ú	__class__Ú__name__ÚdirnameÚexpand_configuration)r   r   r0   r-   ÚasdictZproject_tableZ
tool_tableZsetuptools_tableÚmsgZorig_setuptools_tableZsubsetr,   Úroot_dirr   r   r   r.   >   sD   þ€ùr.   Úproject_cfgÚsetuptools_cfgc                 C   sn   |du s|j jdu r|j jdu r|jdu rdS |rdS t|  ¡ ƒ}h d£}||kr5tjt 	¡ tdd� dS dS )z8Be temporarily forgiving with invalid ``pyproject.toml``NF>   r*   ÚversionZpython_requireszrequires-pythoné   )Ú
stacklevelT)
Úmetadatar*   rM   Zinstall_requiresÚsetÚkeysr<   r=   Ú_InvalidFileÚmessage)rK   rL   r-   Zgiven_configZpopular_subsetr   r   r   rC   �   s   
rC   rJ   r0   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   rJ   r0   r-   r   r   r   rG   «   s   rG   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 )7rU   NFr   rJ   r0   r-   r   c                 C   sh   || _ |pt ¡ | _| di ¡| _| j dg ¡| _| di ¡ di ¡| _| j di ¡| _|| _	|| _
d S )Nr2   Údynamicr3   r4   )r   r8   ÚgetcwdrJ   r!   rK   rV   rL   Údynamic_cfgr0   Ú_dist)Úselfr   rJ   r0   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   r*   )Zsrc_rootr*   )Úsetuptools.distr   rJ   rK   r!   rY   )rZ   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)Ú_ignore_errorsr0   )rZ   r_   r`   ra   r   r   r   Ú_process_fieldÙ   s
   "ÿÿz_ConfigExpander._process_fieldúpackage-datac                 C   s   | j  |i ¡}t |¡S rb   )rL   r!   Ú_expandZcanonic_package_data)rZ   r`   Úpackage_datar   r   r   Ú_canonic_package_dataÞ   s   
z%_ConfigExpander._canonic_package_datac                 C   s|   |   ¡  |  ¡  |  d¡ |  ¡ }t|| jƒ�}|j}|  ¡  |  |¡ |  ||¡ W d   ƒ | j	S 1 s6w   Y  | j	S )Nzexclude-package-data)
Ú_expand_packagesrh   r^   Ú_EnsurePackagesDiscoveredrL   Úpackage_dirÚ_expand_data_filesÚ_expand_cmdclassÚ_expand_all_dynamicr   )rZ   r-   Zensure_discoveredrk   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ÚfindrJ   úpackage-dirZfill_package_dirr   )rL   r!   Ú
isinstanceÚlistÚtupleÚdictrJ   rA   rc   r0   rf   Zfind_packages)rZ   ro   rp   r   r   r   ri   ò   s   


"ÿýz _ConfigExpander._expand_packagesc                 C   s$   t tj| jd�}|  | jd|¡ d S )N)rJ   z
data-files)r   rf   Zcanonic_data_filesrJ   rd   rL   )rZ   Z
data_filesr   r   r   rl   þ   s   z"_ConfigExpander._expand_data_filesrk   c                 C   s*   | j }ttj||d�}|  | jd|¡ d S )N)rk   rJ   Úcmdclass)rJ   r   rf   rv   rd   rL   )rZ   rk   rJ   rv   r   r   r   rm     s   z _ConfigExpander._expand_cmdclassc              	      s‚   d‰‡ ‡‡‡fdd„ˆj D ƒ}|jˆ ˆ ˆ¡pi ˆ ˆ ˆ¡ˆ ˆ ¡ˆ ˆ ¡ˆ ˆ ¡ˆ ˆ ¡d� dd„ | ¡ D ƒ}ˆj	 |¡ d S )N)rM   Úreadmeúentry-pointsÚscriptsúgui-scriptsÚclassifiersÚdependenciesúoptional-dependenciesc                    s$   i | ]}|ˆvr|ˆ  ˆ |ˆ¡“qS r   )Ú_obtain©Ú.0r`   ©r-   rk   rZ   Zspecialr   r   Ú
<dictcomp>  s
    þz7_ConfigExpander._expand_all_dynamic.<locals>.<dictcomp>)rM   rw   r{   r|   Zoptional_dependenciesc                 S   s   i | ]\}}|d ur||“qS rb   r   )r€   ÚkÚvr   r   r   r‚   "  s    )
rV   ÚupdateÚ_obtain_entry_pointsÚ_obtain_versionÚ_obtain_readmeÚ_obtain_classifiersÚ_obtain_dependenciesÚ_obtain_optional_dependenciesÚitemsrK   )rZ   r-   rk   Zobtained_dynamicZupdatesr   r�   r   rn     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   r0   r   )rZ   r-   r`   ÚpreviousrI   r   r   r   Ú_ensure_previously_set%  s   
ÿúz&_ConfigExpander._ensure_previously_setÚ	specifierc                 C   sˆ   t | jƒ�5 | j}d|v rt |d |¡W  d   ƒ S d|v r0t |d ||¡W  d   ƒ S td|› d|›�ƒ‚1 s=w   Y  d S )Nr   Úattrz	invalid `z`: )rc   r0   rJ   rf   Z
read_filesZ	read_attrr)   )rZ   r�   Ú	directiverk   rJ   r   r   r   Ú_expand_directive/  s   ýûúz!_ConfigExpander._expand_directivec                 C   s4   || j v r|  d|› �| j | |¡S |  ||¡ d S )Nztool.setuptools.dynamic.)rX   r’   rŽ   )rZ   r-   r`   rk   r   r   r   r~   ;  s   
ýz_ConfigExpander._obtainc                 C   s,   d| j v rd| jv rt |  |d|¡¡S d S )NrM   )rV   rX   rf   rM   r~   )rZ   r-   rk   r   r   r   r‡   E  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 )Nrw   úcontent-typez
text/x-rst)Útextr“   )rV   rX   r~   r!   rŽ   )rZ   r-   rX   r   r   r   rˆ   K  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)rx   ry   rz   c                 3   s   � | ]}|ˆ j v V  qd S rb   )rV   r   ©rZ   r   r   Ú	<genexpr>]  s   € z7_ConfigExpander._obtain_entry_points.<locals>.<genexpr>rx   r`   Úgroupc                    sD   |ˆv r ˆ  |¡}| ˆjvrt | |¡}t |t¡ |ˆ | < d S d S rb   )ÚpoprV   r   rT   r<   r=   )r`   r—   ÚvaluerI   ©ÚexpandedÚgroupsrZ   r   r   Ú_set_scriptsg  s   

ùz:_ConfigExpander._obtain_entry_points.<locals>._set_scriptsry   Úconsole_scriptsrz   Úgui_scripts)Úanyr~   rf   Zentry_pointsÚstr)rZ   r-   rk   Úfieldsr”   r�   r   rš   r   r†   Y  s   



z$_ConfigExpander._obtain_entry_pointsc                 C   s(   d| j v r|  |di ¡}|r| ¡ S d S )Nr{   )rV   r~   Ú
splitlines©rZ   r-   r™   r   r   r   r‰   v  ó
   
z#_ConfigExpander._obtain_classifiersc                 C   s(   d| j v r|  |di ¡}|rt|ƒS d S )Nr|   )rV   r~   Ú_parse_requirements_listr¤   r   r   r   rŠ   }  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‚   Š  s    ûýÿzA_ConfigExpander._obtain_optional_dependencies.<locals>.<dictcomp>)rV   rX   rr   ru   rŒ   rŽ   )rZ   r-   Zoptional_dependencies_mapr   r•   r   r‹   „  s   



úz-_ConfigExpander._obtain_optional_dependencies©NFN)r   r   )re   )r-   r   )rE   Ú
__module__Ú__qualname__ru   r   Ú_PathÚboolr[   r^   r¡   r   rd   rh   r   ri   rl   r   rm   rn   rŽ   r’   r~   r‡   r   rˆ   r†   r‰   rŠ   r‹   r   r   r   r   rU   Â   sP    ûþýü
û


ÿ

ÿ
ÿ
ÿ
þ

rU   c                 C   s   dd„ |   ¡ D ƒS )Nc                 S   s&   g | ]}|  ¡ r|  ¡  d ¡s|‘qS )ú#)ÚstripÚ
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 )Nr6   r7   )rB   r$   r'   rD   rE   )r0   r,   r   r   r   rc   ž  s   €(€ÿrc   c                       s>   e Zd Zdddef‡ fdd„Z‡ fdd„Z‡ fdd	„Z‡  ZS )
rj   Údistributionr   rL   c                    s   t ƒ  |¡ || _d S rb   )Úsuperr[   Ú_setuptools_cfg)rZ   r±   rL   ©rD   r   r   r[   «  s   
z"_EnsurePackagesDiscovered.__init__c                    sp   | j | j}}| di ¡}| |jpi ¡ ||_|j ¡  |jdu r(| d¡|_|j	du r3| 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``.
        rq   Nú
py-modulesro   )rY   r³   rA   r…   rk   Úset_defaultsZ_ignore_ext_modulesÚ
py_modulesr!   ro   r²   Ú	__enter__)rZ   r-   Úcfgrk   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``.
        ro   rµ   )r³   rA   rY   ro   r·   r²   Ú__exit__)rZ   Úexc_typeÚ	exc_valueÚ	tracebackr´   r   r   rº   Ã  s   z"_EnsurePackagesDiscovered.__exit__)rE   r¨   r©   ru   r[   r¸   rº   Ú__classcell__r   r   r´   r   rj   ª  s    rj   c                   @   s   e Zd ZdZdS )r>   zJExplicitly inform users that some `pyproject.toml` configuration is *beta*N)rE   r¨   r©   Ú__doc__r   r   r   r   r>   Í  s    r>   c                   @   s   e Zd ZdZedd„ ƒZdS )rS   aú  The given `pyproject.toml` file is invalid and would be ignored.
    !!


    ############################
    # Invalid `pyproject.toml` #
    ############################

    Any configurations in `pyproject.toml` will be ignored.
    Please note that future releases of setuptools will halt the build process
    if an invalid file is given.

    To prevent setuptools from considering `pyproject.toml` please
    DO NOT include the `[project]` or `[tool.setuptools]` tables in your file.
    

!!
    c                 C   s   ddl m} || jƒS )Nr   )Úcleandoc)ÚinspectrÀ   r¿   )ÚclsrÀ   r   r   r   rT   á  s   
z_InvalidFile.messageN)rE   r¨   r©   r¿   ÚclassmethodrT   r   r   r   r   rS   Ñ  s    rS   )F)TFNr§   )2r¿   Úloggingr8   r<   Ú
contextlibr   Ú	functoolsr   Útypingr   r   r   r   r   r	   Zsetuptools.errorsr
   r   r    r   rf   Z_apply_pyprojecttomlr   r/   r   r   r\   r   r¡   ÚPathLikerª   Ú	getLoggerrE   r$   ru   r   r«   r#   r1   r.   rC   rG   rU   r¦   rc   ZEnsurePackagesDiscoveredrj   ÚUserWarningr>   rS   r   r   r   r   Ú<module>   s€     
ýÿþ
üüÿ
üOÿÿÿ
þ üÿþýü
û U#