U
    aÊ¹j=  ã                   @  s  U 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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mZmZmZmZ d
dlmZ d
dlmZ d
dlmZ d
dlmZ erêddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z' ei ƒZ(de)d< ee*ee*e*f f Z+de)d< edeeedf gdf Z,de)d< edƒZ-e .e/¡Z0dddddœdd„Z1ddddœd d!„Z2dddd"œd#d$„Z3ddd%œd&d'„Z4d(d(d)œd*d+„Z5dd(d,d-œd.d/„Z6d0d1d2d3œZ7d(d4d5œd6d7„Z8ddd8d9œd:d;„Z9ddd8d9œd<d=„Z:dd>d8d(d?œd@dA„Z;ddd8dBœdCdD„Z<dd(d8dBœdEdF„Z=ddGd8dBœdHdI„Z>ddd8dBœdJdK„Z?dd>dLdMœdNdO„Z@ddddPœdQdR„ZAddSœdTdU„ZBddddVœdWdX„ZCe(fddYdZœd[d\„ZDd]d^d_œd`da„ZEd(d(dbœdcdd„ZFdedfdgœdhdi„ZGddjdkœdldm„ZHddndkœdodp„ZIddndkœdqdr„ZJdsdt„ ZKdudv„ ZLe9e:ee;dwdx�ee;dydx�e<e>e?e=dzœZMd{e)d|< d}d~iZNdd€iZOd�d‚dƒd„d…hZPd†e@iZQeKd‡ƒeKdˆƒeKd‰ƒeKdŠƒeLd‹dŒƒeKd�ƒeLdŽd�ƒeLd�d‘ƒeKd’ƒeKd“ƒeKd”ƒeHeIeJeKd•ƒeKd–ƒd—œZRi g g g g i i i i g i d˜œZSde)d™< G dšd›„ d›eƒZTdS )œak  Translation layer between pyproject config and setuptools distribution and
metadata objects.

The distribution and metadata objects are modeled after (an old version of)
core metadata, therefore configs in the format specified for ``pyproject.toml``
need to be processed before being applied.

**PRIVATE MODULE**: API reserved for setuptools internal usage only.
é    )ÚannotationsN)ÚAddress)ÚpartialÚreduce)Úcleandoc)Úchain)ÚMappingProxyType)ÚTYPE_CHECKINGÚAnyÚCallableÚDictÚMappingÚTypeVarÚUnioné   )ÚStrPath)ÚRemovedConfigError©Ú	Extension)ÚSetuptoolsWarning)Ú	TypeAlias©Úmetadata©ÚDistribution)Ú_OptionsListr   ÚEMPTYr   Ú_ProjectReadmeValuer   Ú_CorrespondenceÚ_TÚdictr   )ÚdistÚconfigÚfilenameÚreturnc              	   C  sh   |s| S t j |¡pd}t| ||ƒ t| ||ƒ t  ¡ }t  |¡ z|  ¡  |  ¡  W 5 t  |¡ X | S )z=Apply configuration dict read with :func:`read_configuration`Ú.)	ÚosÚpathÚdirnameÚ_apply_project_tableÚ_apply_tool_tableÚgetcwdÚchdirZ_finalize_requiresZ_finalize_license_files)r!   r"   r#   Úroot_dirZcurrent_directory© r.   úe/var/www/html/bwave/python/venv/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.pyÚapply,   s    
r0   )r!   r"   r-   c                 C  sv   |  di ¡ ¡ }|sd S t| |ƒ t|ƒ | ¡ D ]>\}}t|ƒ}t  ||¡}t|ƒrd|| ||ƒ q2t| ||ƒ q2d S )NÚproject)	ÚgetÚcopyÚ_handle_missing_dynamicÚ_unify_entry_pointsÚitemsÚjson_compatible_keyÚPYPROJECT_CORRESPONDENCEÚcallableÚ_set_config)r!   r"   r-   Úproject_tableÚfieldÚvalueÚnorm_keyZcorrespr.   r.   r/   r)   B   s    
r)   )r!   r"   r#   c           	      C  s”   |  di ¡  di ¡}|sd S | ¡ D ]^\}}t|ƒ}|tkrjtt| ƒ}d|› d�}td t|ƒ|g¡ƒ‚t  ||¡}t| ||ƒ q$t	|| |ƒ d S )NÚtoolÚ
setuptoolsz,
            The parameter `tool.setuptools.zZ` was long deprecated
            and has been removed from `pyproject.toml`.
            Ú
)
r2   r6   r7   ÚTOOL_TABLE_REMOVALSr   r   ÚjoinÚTOOL_TABLE_RENAMESr:   Ú_copy_command_options)	r!   r"   r#   Ú
tool_tabler<   r=   r>   Z
suggestionÚmsgr.   r.   r/   r*   S   s    ÿr*   )r!   r;   c                 C  s^   t | dg ¡ƒ}t ¡ D ]@\}}||ks||ks|| ƒ}|rtj||d� t |¡||< qdS )zJBe temporarily forgiving with ``dynamic`` fields not listed in ``dynamic``Údynamic©r<   r=   N)Úsetr2   Ú_PREVIOUSLY_DEFINEDr6   Ú_MissingDynamicÚemitÚ_RESET_PREVIOUSLY_DEFINED)r!   r;   rH   r<   Úgetterr=   r.   r.   r/   r4   i   s    r4   Ústr)Úkeyr$   c                 C  s   |   ¡  dd¡S )z1As defined in :pep:`566#json-compatible-metadata`ú-Ú_)ÚlowerÚreplace)rQ   r.   r.   r/   r7   t   s    r7   r
   )r!   r<   r=   c                 C  sh   t  |t¡| |ƒ}t| jd|› �d ƒ}|r4||ƒ n0t| j|ƒsH|tkrXt| j||ƒ nt| ||ƒ d S )NÚset_)Ú_PREPROCESSr2   Ú_noopÚgetattrr   ÚhasattrÚSETUPTOOLS_PATCHESÚsetattr)r!   r<   r=   ÚvalÚsetterr.   r.   r/   r:   y   s    
r:   ztext/markdownz
text/x-rstz
text/plain)z.mdz.rstz.txtz
str | None)Úfiler$   c                 C  sh   t j |  ¡ ¡\}}|sd S |tkr,t| S d dd„ t ¡ D ƒ¡}d|› d�}td| › d|› �ƒ‚d S )Nú, c                 s  s"   | ]\}}|› d |› d�V  qdS )z (ú)Nr.   ©Ú.0ÚkÚvr.   r.   r/   Ú	<genexpr>“   s     z&_guess_content_type.<locals>.<genexpr>z3only the following file extensions are recognized: r%   zUndefined content type for )r&   r'   ÚsplitextrT   Ú_CONTENT_TYPESrC   r6   Ú
ValueError)r_   rS   ÚextÚvalidrG   r.   r.   r/   Ú_guess_content_type‹   s    rl   zStrPath | None)r!   r]   r-   c                 C  sŒ   ddl m} t|tƒr0|}| ||¡}t|ƒ}n,| d¡p<d}| d¡pR| ||¡}|d }t| d|ƒ |rxt| d|ƒ |rˆ| j 	|¡ d S )	Nr   ©Úexpandr_   r.   Útextzcontent-typeÚlong_descriptionÚlong_description_content_type)
Úsetuptools.configrn   Ú
isinstancerP   Ú
read_filesrl   r2   r:   Ú_referenced_filesÚadd)r!   r]   r-   rn   r_   ro   Úctyper.   r.   r/   Ú_long_description˜   s    

rx   c                 C  sT   ddl m} d|kr@t| d| |d g|¡ƒ | j |d ¡ nt| d|d ƒ d S )Nr   rm   r_   Úlicensero   )rr   rn   r:   rt   ru   rv   )r!   r]   r-   rn   r.   r.   r/   Ú_license°   s
    rz   z
list[dict])r!   r]   Ú	_root_dirÚkindc                 C  sš   g }g }|D ]V}d|kr(|  |d ¡ qd|kr@|  |d ¡ qt|d |d d�}|  t|ƒ¡ q|rzt| |d |¡ƒ |r–t| |› d�d |¡ƒ d S )NÚnameÚemail)Údisplay_nameZ	addr_specr`   Z_email)Úappendr   rP   r:   rC   )r!   r]   r{   r|   r<   Zemail_fieldZpersonÚaddrr.   r.   r/   Ú_peopleº   s    r‚   ©r!   r]   r{   c                 C  s   t | d|ƒ d S )NÚproject_urls)r:   rƒ   r.   r.   r/   Ú_project_urlsÌ   s    r…   c                 C  s    ddl m} t| d||ƒƒ d S )Nr   )ÚSpecifierSetÚpython_requires)Zpackaging.specifiersr†   r:   )r!   r]   r{   r†   r.   r.   r/   Ú_python_requiresÐ   s    rˆ   Úlistc                 C  s$   t | dg ƒrd}t |¡ || _d S )NÚinstall_requireszA`install_requires` overwritten in `pyproject.toml` (dependencies))rY   r   rM   rŠ   ©r!   r]   r{   rG   r.   r.   r/   Ú_dependenciesÖ   s    
rŒ   c                 C  s$   t | dd ƒrd}t |¡ || _d S )NÚextras_requirezH`extras_require` overwritten in `pyproject.toml` (optional-dependencies))rY   r   rM   r�   r‹   r.   r.   r/   Ú_optional_dependenciesÝ   s    
rŽ   zlist[Extension])r!   r]   r$   c                 C  s.   | j pg }dd„ |D ƒ}dd„ |D ƒ}||•S )Nc                 s  s    | ]}d d„ |  ¡ D ƒV  qdS )c                 S  s   i | ]\}}|  d d¡|“qS )rR   rS   )rU   rb   r.   r.   r/   Ú
<dictcomp>æ   s     
 z*_ext_modules.<locals>.<genexpr>.<dictcomp>N©r6   )rc   Úxr.   r.   r/   rf   æ   s     z_ext_modules.<locals>.<genexpr>c                 S  s   g | ]}t f |Ž‘qS r.   r   )rc   Úkwr.   r.   r/   Ú
<listcomp>ç   s     z _ext_modules.<locals>.<listcomp>)Úext_modules)r!   r]   ÚexistingÚargsÚnewr.   r.   r/   Ú_ext_modulesä   s    
r˜   )Ú_distr]   r$   c                 C  s   |S ©Nr.   )r™   r]   r.   r.   r/   rX   ë   s    rX   )r;   c                 C  sx   | }|  d|  di ¡¡}dddœ}t| ¡ ƒD ]*\}}t|ƒ}||kr.|  |¡||| < q.|rtdd„ | ¡ D ƒ|d< d S )Núentry-pointsÚentry_pointsÚconsole_scriptsÚgui_scripts)Úscriptsrž   c                 S  s(   i | ] \}}|r|d d„ |  ¡ D ƒ“qS )c                 S  s   g | ]\}}|› d |› �‘qS )z = r.   rb   r.   r.   r/   r“   û   s     z2_unify_entry_points.<locals>.<dictcomp>.<listcomp>r�   )rc   r}   Úgroupr.   r.   r/   r�   ú   s   þ z'_unify_entry_points.<locals>.<dictcomp>)Úpopr‰   r6   r7   )r;   r1   rœ   ZrenamingrQ   r=   r>   r.   r.   r/   r5   ï   s    
þr5   )Ú	pyprojectr!   r#   c              	   C  sÄ   |   di ¡}|  di ¡  di ¡}t|ƒ}|j}|   di ¡  di ¡ ¡ D ]x\}}t|ƒ}|  |tƒ ¡}	| |i ¡ | ¡ D ]D\}
}t|
ƒ}
t|ƒ|f|| |
< |
|	krxt 	d|› d|
› d�¡ qxqFd S )Nr?   r@   ÚcmdclassÚ	distutilszCommand option r%   z is not defined)
r2   Ú_valid_command_optionsÚcommand_optionsr6   r7   rJ   Ú
setdefaultrP   Ú_loggerÚwarning)r¢   r!   r#   rF   r£   Úvalid_optionsÚcmd_optsÚcmdr"   rk   rQ   r=   r.   r.   r/   rE     s     rE   zdict[str, set[str]])r£   r$   c           
      C  s”   ddl m} ddlm} dt|jƒi}|jdd�}dd	„ |D ƒ}d
d	„ |D ƒ}t||  ¡ ƒD ]2\}}| 	|t
ƒ ¡}	|	tt|dg ƒƒB }	|	||< q\|S )Nr   r   r   r   Úglobalzdistutils.commands)r    c                 s  s   | ]}t |ƒV  qd S rš   )Ú_load_ep©rc   Úepr.   r.   r/   rf     s     z)_valid_command_options.<locals>.<genexpr>c                 s  s   | ]}|r|V  qd S rš   r.   r¯   r.   r.   r/   rf     s      Úuser_options)Úsetuptools.distr   Z
_importlibr   Ú_normalise_cmd_optionsÚglobal_optionsrœ   r   r6   r2   rJ   rY   )
r£   r   r   rª   Zunloaded_entry_pointsZloaded_entry_pointsrœ   r¬   Ú	cmd_classÚoptsr.   r.   r/   r¥     s    
r¥   zmetadata.EntryPointztuple[str, type] | None)r°   r$   c              
   C  sv   | j  d¡rd S z| j|  ¡ fW S  tk
rp } z2|jj› d| j› �}t |› d|› �¡ W Y ¢d S d }~X Y nX d S )Nzwheel.bdist_wheelz" while trying to load entry-point z: )	r=   Ú
startswithr}   ÚloadÚ	ExceptionÚ	__class__Ú__name__r¨   r©   )r°   ÚexrG   r.   r.   r/   r®   (  s    r®   )r}   r$   c                 C  s   t | ƒ d¡S )Nz_=)r7   Ústrip)r}   r.   r.   r/   Ú_normalise_cmd_option_key7  s    r¾   r   zset[str])Údescr$   c                 C  s   dd„ | D ƒS )Nc                 S  s   h | ]}t |d  ƒ’qS )r   )r¾   )rc   Zfancy_optionr.   r.   r/   Ú	<setcomp><  s     z)_normalise_cmd_options.<locals>.<setcomp>r.   )r¿   r.   r.   r/   r³   ;  s    r³   zdict[str, list])r!   r$   c                   s*   d‰ t | dd ƒpi }‡ fdd„| ¡ D ƒS )N)r�   rž   rœ   c                   s   i | ]\}}|ˆ kr||“qS r.   r.   rb   ©Úignorer.   r/   r�   B  s       z-_get_previous_entrypoints.<locals>.<dictcomp>)rY   r6   ©r!   r=   r.   rÁ   r/   Ú_get_previous_entrypoints?  s    rÄ   zlist | Nonec                 C  s   t | dd ƒpi }| d¡S )Nrœ   r�   ©rY   r2   rÃ   r.   r.   r/   Ú_get_previous_scriptsE  s    rÆ   c                 C  s   t | dd ƒpi }| d¡S )Nrœ   rž   rÅ   rÃ   r.   r.   r/   Ú_get_previous_gui_scriptsJ  s    rÇ   c                 C  s   t tdd„ |  d¡ƒS )a8  
    Similar to ``operator.attrgetter`` but returns None if ``attr`` is not found
    >>> from types import SimpleNamespace
    >>> obj = SimpleNamespace(a=42, b=SimpleNamespace(c=13))
    >>> _attrgetter("a")(obj)
    42
    >>> _attrgetter("b.c")(obj)
    13
    >>> _attrgetter("d")(obj) is None
    True
    c                 S  s   t | |d ƒS rš   )rY   )Úaccr‘   r.   r.   r/   Ú<lambda>[  ó    z_attrgetter.<locals>.<lambda>r%   )r   r   Úsplit)Úattrr.   r.   r/   Ú_attrgetterO  s    rÍ   c                    s   ‡ fdd„}|S )aL  
    Return the first "truth-y" attribute or None
    >>> from types import SimpleNamespace
    >>> obj = SimpleNamespace(a=42, b=SimpleNamespace(c=13))
    >>> _some_attrgetter("d", "a", "b.c")(obj)
    42
    >>> _some_attrgetter("d", "e", "b.c", "a")(obj)
    13
    >>> _some_attrgetter("d", "e", "f")(obj) is None
    True
    c                   s&   ‡ fdd„ˆD ƒ}t dd„ |D ƒd ƒS )Nc                 3  s   | ]}t |ƒˆ ƒV  qd S rš   )rÍ   ©rc   Úi©Úobjr.   r/   rf   l  s     z5_some_attrgetter.<locals>._acessor.<locals>.<genexpr>c                 s  s   | ]}|d k	r|V  qd S rš   r.   rÎ   r.   r.   r/   rf   m  s      )Únext)rÑ   Úvaluesr�   rÐ   r/   Ú_acessork  s    z"_some_attrgetter.<locals>._acessorr.   )r6   rÔ   r.   r�   r/   Ú_some_attrgetter^  s    rÕ   Úauthor)r|   Ú
maintainer)Úreadmery   ÚauthorsÚmaintainersÚurlsÚdependenciesZoptional_dependenciesÚrequires_pythonzdict[str, _Correspondence]r8   Zscript_filesrŸ   Únamespace_packagesz 
        Please migrate to implicit native namespaces instead.
        See https://packaging.python.org/en/latest/guides/packaging-namespace-packages/.
        rq   r„   Zprovides_extrasZlicense_fileZlicense_filesr”   zmetadata.namezmetadata.versionzmetadata.descriptionzmetadata.long_descriptionr‡   zmetadata.python_requireszmetadata.licensezmetadata.authorzmetadata.author_emailzmetadata.maintainerzmetadata.maintainer_emailzmetadata.keywordszmetadata.classifierszmetadata.project_urlsrŠ   r�   )r}   ÚversionÚdescriptionrØ   zrequires-pythonry   rÙ   rÚ   ÚkeywordsÚclassifiersrÛ   r›   rŸ   úgui-scriptsrÜ   úoptional-dependencies)ry   rÙ   rÚ   rá   râ   rÛ   r›   rŸ   rã   rÜ   rä   rN   c                   @  s*   e Zd ZdZdZeddddœdd„ƒZdS )	rL   z9`{field}` defined outside of `pyproject.toml` is ignored.a%  
    The following seems to be defined outside of `pyproject.toml`:

    `{field} = {value!r}`

    According to the spec (see the link below), however, setuptools CANNOT
    consider this value unless `{field}` is listed as `dynamic`.

    https://packaging.python.org/en/latest/specifications/pyproject-toml/#declaring-project-metadata-the-project-table

    To prevent this problem, you can list `{field}` under `dynamic` or alternatively
    remove the `[project]` table from your file and rely entirely on other means of
    configuration.
    rP   r
   )r<   r=   r$   c                 C  s   | j j||d�S )NrI   )Ú_DETAILSÚformat)Úclsr<   r=   r.   r.   r/   ÚdetailsË  s    z_MissingDynamic.detailsN)r»   Ú
__module__Ú__qualname__Z_SUMMARYrå   Úclassmethodrè   r.   r.   r.   r/   rL   ¶  s   rL   )UÚ__doc__Ú
__future__r   Úloggingr&   Zemail.headerregistryr   Ú	functoolsr   r   Úinspectr   Ú	itertoolsr   Útypesr   Útypingr	   r
   r   r   r   r   r   Ú_pathr   Úerrorsr   Ú	extensionr   Úwarningsr   Útyping_extensionsr   Zsetuptools._importlibr   r²   r   Údistutils.distr   r   Ú__annotations__rP   r   r   r   Ú	getLoggerr»   r¨   r0   r)   r*   r4   r7   r:   rh   rl   rx   rz   r‚   r…   rˆ   rŒ   rŽ   r˜   rX   r5   rE   r¥   r®   r¾   r³   rÄ   rÆ   rÇ   rÍ   rÕ   r8   rD   rB   r[   rW   rK   rN   rL   r.   r.   r.   r/   Ú<module>   sÔ   
$"
ý


ø ÿû	 ÿðó