o
    Ee9                     @   sh  U 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	 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mZmZmZmZ d
dlmZ d
dlmZ ereddl m!Z! ddl"m#Z# ei Z$ee%d< eej&e'f Z(ee)e'f Z*edee(gdf Z+ee'e+f Z,e-e.Z/ddde)de(ddfddZ0ddde)de(fddZ1ddde)de(fddZ2ddde)fddZ3de'de'fd d!Z4ddd"e'd#efd$d%Z5d&d'd(d)Z6d*e'dee' fd+d,Z7ddd-e*de(fd.d/Z8ddd-e)de(fd0d1Z9ddd-ee) d2e(d3e'fd4d5Z:ddd-e)fd6d7Z;ddd-e)fd8d9Z<ddd-e=fd:d;Z>ddd-e)fd<d=Z?de)fd>d?Z@d@e)ddde(fdAdBZAe$fdCedee'ee' f fdDdEZBdFdGdeee'ef  fdHdIZCdJe'de'fdKdLZDdMeee'ee' e'f  dee' fdNdOZEdddee'e=f fdPdQZFdddee= fdRdSZGdddee= fdTdUZHdVdW ZIdXdY ZJe8e9ee:dZd[ee:d\d[e;e>e?e<d]ZKee'e,f e%d^< d_d`iZLdadbiZMh dcZNi dJeIdddeeIdfdgeIdhdieIdjdkeJdldmdneIdodpeJdqdrdseJdtdudveIdwdxeIdydzeId{d|eFd`eGd}eHd~eIddeIdZOi g g g g i i i i g g dZPe)e%d< G dd deZQd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.
    N)Mapping)Address)partialreduce)cleandoc)chain)MappingProxyType)TYPE_CHECKINGAnyCallableDictListOptionalSetTupleTypeUnioncast   )RemovedConfigError)SetuptoolsWarningmetadataDistributionEMPTYr   distconfigfilenamereturnc              	   C   sp   |s| S t j|pd}t| || t| || t  }t | z|   |   W t | | S t | w )z=Apply configuration dict read with :func:`read_configuration`.)	ospathdirname_apply_project_table_apply_tool_tablegetcwdchdir_finalize_requires_finalize_license_files)r   r   r   root_dircurrent_directory r,   g/var/www/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.pyapply0   s   


r.   r*   c                 C   sv   | di  }|sd S t| | t| | D ]\}}t|}t ||}t|r2|| || qt| || qd 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_keycorrespr,   r,   r-   r$   F   s   
r$   c           	      C   s   | di  di }|sd S | D ]/\}}t|}|tv r5t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`.
            
)
r0   r4   r5   TOOL_TABLE_REMOVALSr   r   joinTOOL_TABLE_RENAMESr8   _copy_command_options)	r   r   r   
tool_tabler:   r;   r<   
suggestionmsgr,   r,   r-   r%   W   s   r%   r9   c                 C   s^   t |dg }t D ] \}}||v s,||v s,|| }|r,tj||d t|||< qdS )zJBe temporarily forgiving with ``dynamic`` fields not listed in ``dynamic``dynamicr:   r;   N)setr0   _PREVIOUSLY_DEFINEDr4   _MissingDynamicemit_RESET_PREVIOUSLY_DEFINED)r   r9   rH   r:   getterr;   r,   r,   r-   r2   m   s   r2   keyc                 C   s   |   ddS )z1As defined in :pep:`566#json-compatible-metadata`-_)lowerreplace)rP   r,   r,   r-   r5   x      r5   r:   r;   c                 C   sZ   t | jd| d }|r|| d S t| j|s|tv r%t| j|| d S t| || d S )Nset_)getattrr   hasattrSETUPTOOLS_PATCHESsetattr)r   r:   r;   setterr,   r,   r-   r8   }   s   r8   ztext/markdownz
text/x-rstz
text/plain)z.mdz.rstz.txtfilec                 C   sd   t j|  \}}|sd S |tv rt| S ddd t D }d| d}td|  d| )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"   splitextrS   _CONTENT_TYPESrB   r4   
ValueError)r\   rR   extvalidrG   r,   r,   r-   _guess_content_type   s   ri   valc                 C   s   ddl m} t|tr|}|||}t|}n|dpg }|dp)|||}|d }t| d| |r<t| d| |rI| j	t
t| d S d S )Nr   expandr\   textzcontent-typelong_descriptionlong_description_content_type)setuptools.configrl   
isinstancestr
read_filesri   r0   r8   _referenced_filesaddr   )r   rj   r*   rl   r\   rm   ctyper,   r,   r-   _long_description   s   

rw   c                 C   sV   ddl m} d|v r!t| d||d g| | j|d  d S t| d|d  d S )Nr   rk   r\   licenserm   )rp   rl   r8   rs   rt   ru   )r   rj   r*   rl   r,   r,   r-   _license   s
   ry   	_root_dirkindc                 C   s   g }g }|D ]+}d|vr| |d  qd|vr | |d  qt|d |d d}| t| q|r=t| |d| |rMt| | dd| d S d S )Nnameemail)display_name	addr_specr]   _email)appendr   rr   r8   rB   )r   rj   rz   r{   r:   email_fieldpersonaddrr,   r,   r-   _people   s   r   c                 C   s   t | d| d S )Nproject_urls)r8   )r   rj   rz   r,   r,   r-   _project_urls   s   r   c                 C   s    ddl m} t| d|| d S )Nr   )SpecifierSetpython_requires)&setuptools.extern.packaging.specifiersr   r8   )r   rj   rz   r   r,   r,   r-   _python_requires   s   r   c                 C   s$   t | dg rd}t| || _d S )Ninstall_requireszA`install_requires` overwritten in `pyproject.toml` (dependencies))rW   r   rM   r   )r   rj   rz   rG   r,   r,   r-   _dependencies   s   

r   c                 C   s"   t | dd pi }i ||| _d S )Nextras_require)rW   r   )r   rj   rz   existingr,   r,   r-   _optional_dependencies   s   r   c                 C   s|   | }| d| di }ddd}t| D ]\}}t|}||v r,| |||| < q|r<dd | D |d< d S 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,   r_   r,   r,   r-   
<listcomp>       z2_unify_entry_points.<locals>.<dictcomp>.<listcomp>r4   )r`   r|   groupr,   r,   r-   
<dictcomp>   s    z'_unify_entry_points.<locals>.<dictcomp>)poplistr4   r5   )r9   r/   r   renamingrP   r;   r<   r,   r,   r-   r3      s   
r3   	pyprojectc              	   C   s   |  di }| di  di }t|}|j}|  di  di  D ]<\}}t|}| |t }	||i  | D ]"\}
}t|
}
t||f|| |
< |
|	vr^t	d| d|
 d q<q#d S )Nr>   r?   cmdclass	distutilszCommand option r    z is not defined)
r0   _valid_command_optionscommand_optionsr4   r5   rJ   
setdefaultrr   _loggerwarning)r   r   r   rE   r   valid_optionscmd_optscmdr   rh   rP   r;   r,   r,   r-   rD      s     rD   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 ]\}}|	|t
 }	|	tt|dg B }	|	||< q.|S )Nr   r   r   r   globalzdistutils.commands)r   c                 s   s    | ]}t |V  qd S N)_load_epr`   epr,   r,   r-   rc         z)_valid_command_options.<locals>.<genexpr>c                 s   s    | ]}|r|V  qd S r   r,   r   r,   r,   r-   rc     r   user_options)
_importlibr   setuptools.distr   _normalise_cmd_optionsglobal_optionsr   r   r4   r0   rJ   rW   )
r   r   r   r   unloaded_entry_pointsloaded_entry_pointsr   r   	cmd_classoptsr,   r,   r-   r   	  s   
r   r   zmetadata.EntryPointc              
   C   s`   z| j |  fW S  ty/ } z|jj d| j  }t| d|  W Y d }~d S d }~ww )Nz" while trying to load entry-point z: )r|   load	Exception	__class____name__r   r   )r   exrG   r,   r,   r-   r     s   r   r|   c                 C   s   t | dS )Nz_=)r5   strip)r|   r,   r,   r-   _normalise_cmd_option_key$     r   descc                 C   s   dd | D S )Nc                 S   s   h | ]}t |d  qS )r   )r   )r`   fancy_optionr,   r,   r-   	<setcomp>)  s    z)_normalise_cmd_options.<locals>.<setcomp>r,   )r   r,   r,   r-   r   (  r   r   c                    s*   d t | dd p	i } fdd| D S )N)r   r   r   c                    s   i | ]\}}| vr||qS r,   r,   r_   ignorer,   r-   r   /  r   z-_get_previous_entrypoints.<locals>.<dictcomp>)rW   r4   r   r;   r,   r   r-   _get_previous_entrypoints,  s   r   c                 C      t | dd pi }|dS )Nr   r   rW   r0   r   r,   r,   r-   _get_previous_scripts2     
r   c                 C   r   )Nr   r   r   r   r,   r,   r-   _get_previous_gui_scripts7  r   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   )rW   )accxr,   r,   r-   <lambda>H  s    z_attrgetter.<locals>.<lambda>r    )r   r   split)attrr,   r,   r-   _attrgetter<  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   r`   iobjr,   r-   rc   Y      z5_some_attrgetter.<locals>._acessor.<locals>.<genexpr>c                 s   s    | ]	}|d ur|V  qd S r   r,   r   r,   r,   r-   rc   Z  r   )next)r   valuesr   r   r-   _acessorX  s   z"_some_attrgetter.<locals>._acessorr,   )r4   r   r,   r   r-   _some_attrgetterK  s   r   author)r{   
maintainer)readmerx   authorsmaintainersurlsdependenciesoptional_dependenciesrequires_pythonr6   script_filesr   namespace_packagesz
        Please migrate to implicit native namespaces instead.
        See https://packaging.python.org/en/latest/guides/packaging-namespace-packages/.
        >   license_filer   license_filesprovides_extrasro   zmetadata.nameversionzmetadata.versiondescriptionzmetadata.descriptionr   zmetadata.long_descriptionzrequires-pythonr   zmetadata.python_requiresrx   zmetadata.licenser   zmetadata.authorzmetadata.author_emailr   zmetadata.maintainerzmetadata.maintainer_emailkeywordszmetadata.keywordsclassifierszmetadata.classifiersr   zmetadata.project_urlsr   gui-scriptsr   r   optional-dependenciesr   )rx   r   r   r   r   r   r   r   r   r   r   rN   c                   @   s.   e Zd ZdZdZedededef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/declaring-project-metadata/

    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.
    r:   r;   r   c                 C   s   | j j||dS )NrI   )_DETAILSformat)clsr:   r;   r,   r,   r-   details  rU   z_MissingDynamic.detailsN)	r   
__module____qualname___SUMMARYr   classmethodrr   r
   r   r,   r,   r,   r-   rL     s
    rL   )R__doc__loggingr!   collections.abcr   email.headerregistryr   	functoolsr   r   inspectr   	itertoolsr   typesr   typingr	   r
   r   r   r   r   r   r   r   r   r   errorsr   warningsr   setuptools._importlibr   r   r   r   __annotations__PathLikerr   _Pathdict
_DictOrStr
_CorrespFn_Correspondence	getLoggerr   r   r.   r$   r%   r2   r5   r8   re   ri   rw   ry   r   r   r   r   r   r   r3   rD   r   r   r   r   r   r   r   r   r   r6   rC   rA   rY   rK   rN   rL   r,   r,   r,   r-   <module>   s    	4

"
(




	
