o
    Ëý°jqZ  ã                   @   s  d dl Z d dlZd dlZd dl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
 d dlmZ d dlZd dlmZmZ d dlmZmZ d dlmZ G d	d
„ d
ƒZejdd„ ƒZddd„Zdd„ Zdd„ Zddd„ZG dd„ dƒZG dd„ deƒZG dd„ deƒZdS )é    N)Údefaultdict)Úpartial©Úwraps)Úiglob)ÚDistutilsOptionErrorÚDistutilsFileError)ÚVersionÚInvalidVersion)ÚSpecifierSetc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚStaticModulez0
    Attempt to load the module by the name
    c                 C   s`   t j |¡}t|jƒ�}| ¡ }W d   ƒ n1 sw   Y  t |¡}t| ƒ 	t
ƒ ¡ | `d S ©N)Ú	importlibÚutilÚ	find_specÚopenÚoriginÚreadÚastÚparseÚvarsÚupdateÚlocalsÚself)r   ÚnameÚspecÚstrmÚsrcÚmodule© r   ú„/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/setuptools/config.pyÚ__init__   s   
ÿ
zStaticModule.__init__c              
      sN   zt ‡ fdd„| jjD ƒƒW S  ty& } ztdjdi tƒ ¤Žƒ|‚d }~ww )Nc                 3   sJ   � | ] }t |tjƒr"|jD ]}t |tjƒr!|jˆ krt |j¡V  qqd S r   )Ú
isinstancer   ÚAssignÚtargetsÚNameÚidÚliteral_evalÚvalue)Ú.0Ú	statementÚtarget©Úattrr   r    Ú	<genexpr>#   s   € 
ýü
û

üûz+StaticModule.__getattr__.<locals>.<genexpr>z#{self.name} has no attribute {attr}r   )Únextr   ÚbodyÚ	ExceptionÚAttributeErrorÚformatr   )r   r-   Úer   r,   r    Ú__getattr__!   s   
þÿþ€ÿzStaticModule.__getattr__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   r5   r   r   r   r    r      s    r   c              	   c   s8   � zt j d| ¡ dV  W t j | ¡ dS t j | ¡ w )zH
    Add path to front of sys.path for the duration of the context.
    r   N)ÚsysÚpathÚinsertÚremove)r;   r   r   r    Ú
patch_path0   s
   €r>   Fc           	   	   C   s¶   ddl m}m} tj | ¡} tj | ¡std|  ƒ‚t ¡ }t 	tj 
| ¡¡ z-|ƒ }|r1| ¡ ng }| |vr<| | ¡ |j||d� t||j|d�}W t 	|¡ t|ƒS t 	|¡ w )a,  Read given configuration file and returns options from it as a dict.

    :param str|unicode filepath: Path to configuration file
        to get options from.

    :param bool find_others: Whether to search for other configuration files
        which could be on in various places.

    :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.

    :rtype: dict
    r   )ÚDistributionÚ_Distributionz%Configuration file %s does not exist.)Ú	filenames)Úignore_option_errors)Úsetuptools.distr?   r@   Úosr;   ÚabspathÚisfiler   ÚgetcwdÚchdirÚdirnameÚfind_config_filesÚappendÚparse_config_filesÚparse_configurationÚcommand_optionsÚconfiguration_to_dict)	ÚfilepathÚfind_othersrB   r?   r@   Úcurrent_directoryÚdistrA   Úhandlersr   r   r    Úread_configuration<   s$   
ÿ
þrU   c                 C   s2   dj di tƒ ¤Ž}t t| |¡}t| ||ƒ}|ƒ S )z 
    Given a target object and option key, get that option from
    the target object, either through a get_{key} method or
    from an attribute directly.
    z	get_{key}Nr   )r3   r   Ú	functoolsr   Úgetattr)Ú
target_objÚkeyÚgetter_nameÚby_attributeÚgetterr   r   r    Ú_get_optioni   s   r]   c                 C   s<   t tƒ}| D ]}|jD ]}t|j|ƒ}|||j |< qq|S )z»Returns configuration data gathered by given handlers as a dict.

    :param list[ConfigHandler] handlers: Handlers list,
        usually from parse_configuration()

    :rtype: dict
    )r   ÚdictÚset_optionsr]   rX   Úsection_prefix)rT   Úconfig_dictÚhandlerÚoptionr(   r   r   r    rO   u   s   
þrO   c                 C   s6   t | ||ƒ}| ¡  t| j||| jƒ}| ¡  ||fS )aÒ  Performs additional parsing of configuration options
    for a distribution.

    Returns a list of used option handlers.

    :param Distribution distribution:
    :param dict command_options:
    :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.
    :rtype: list
    )ÚConfigOptionsHandlerr   ÚConfigMetadataHandlerÚmetadataÚpackage_dir)ÚdistributionrN   rB   ÚoptionsÚmetar   r   r    rM   ‡   s   ürM   c                   @   sÞ   e Zd ZdZdZ	 i Z	 d'dd„Zedd„ ƒZdd	„ Z	e
d(dd„ƒZe
d(dd„ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZedd„ ƒZedd„ ƒZe
d)dd„ƒZe
dd„ ƒZe
d)dd „ƒZd!d"„ Zd#d$„ Zd%d&„ ZdS )*ÚConfigHandlerz1Handles metadata supplied in configuration files.NFc                 C   s^   i }| j }| ¡ D ]\}}| |¡sq	| |d¡ d¡}|||< q	|| _|| _|| _g | _d S )NÚ Ú.)	r`   ÚitemsÚ
startswithÚreplaceÚstriprB   rX   Úsectionsr_   )r   rX   ri   rB   rr   r`   Úsection_nameÚsection_optionsr   r   r    r!   ³   s   


zConfigHandler.__init__c                 C   s   t d| jj ƒ‚)ú.Metadata item name to parser function mapping.z!%s must provide .parsers property)ÚNotImplementedErrorÚ	__class__r6   )r   r   r   r    ÚparsersÃ   s   
ÿzConfigHandler.parsersc           	      C   sÄ   t ƒ }| j}| j ||¡}t|||ƒ}||u rt|ƒ‚|rd S d}| j |¡}|r?z||ƒ}W n ty>   d}| js<‚ Y nw |rCd S t|d| d ƒ}|d u rVt	|||ƒ n||ƒ | j
 |¡ d S )NFTzset_%s)ÚtuplerX   ÚaliasesÚgetrW   ÚKeyErrorrx   r1   rB   Úsetattrr_   rK   )	r   Úoption_namer(   ÚunknownrX   Úcurrent_valueÚskip_optionÚparserÚsetterr   r   r    Ú__setitem__Ê   s4   ÿþzConfigHandler.__setitem__ú,c                 C   s8   t |tƒr|S d|v r| ¡ }n| |¡}dd„ |D ƒS )z×Represents value as a list.

        Value is split either by separator (defaults to comma) or by lines.

        :param value:
        :param separator: List items separator character.
        :rtype: list
        Ú
c                 S   s   g | ]
}|  ¡ r|  ¡ ‘qS r   )rq   )r)   Úchunkr   r   r    Ú
<listcomp>  s    z-ConfigHandler._parse_list.<locals>.<listcomp>)r"   ÚlistÚ
splitlinesÚsplit)Úclsr(   Ú	separatorr   r   r    Ú_parse_listð   s   



zConfigHandler._parse_listc              	      sj   d}| j ˆ |d�}g }|D ]%‰ t‡ fdd„|D ƒƒr-| tdd„ ttj ˆ ¡ƒD ƒƒ¡ q| ˆ ¡ q|S )a  Equivalent to _parse_list() but expands any glob patterns using glob().

        However, unlike with glob() calls, the results remain relative paths.

        :param value:
        :param separator: List items separator character.
        :rtype: list
        )Ú*ú?ú[ú]Ú{Ú}©r�   c                 3   s   � | ]}|ˆ v V  qd S r   r   )r)   Úchar©r(   r   r    r.     s   € z1ConfigHandler._parse_list_glob.<locals>.<genexpr>c                 s   s"   � | ]}t j |t  ¡ ¡V  qd S r   )rD   r;   ÚrelpathrG   ©r)   r;   r   r   r    r.     s
   € ÿ
ÿ)	rŽ   ÚanyÚextendÚsortedr   rD   r;   rE   rK   )rŒ   r(   r�   Úglob_charactersÚvaluesÚexpanded_valuesr   r—   r    Ú_parse_list_glob  s   
þzConfigHandler._parse_list_globc                 C   sP   d}i }|   |¡D ]}| |¡\}}}||krtd| ƒ‚| ¡ || ¡ < q	|S )zPRepresents value as a dict.

        :param value:
        :rtype: dict
        ú=z(Unable to parse option value to dict: %s)rŽ   Ú	partitionr   rq   )rŒ   r(   r�   ÚresultÚlinerY   ÚsepÚvalr   r   r    Ú_parse_dict   s   ÿzConfigHandler._parse_dictc                 C   s   |  ¡ }|dv S )zQRepresents value as boolean.

        :param value:
        :rtype: bool
        )Ú1ÚtrueÚyes)Úlower)rŒ   r(   r   r   r    Ú_parse_bool3  s   zConfigHandler._parse_boolc                    ó   ‡ fdd„}|S )zßReturns a parser function to make sure field inputs
        are not files.

        Parses a value after getting the key so error messages are
        more informative.

        :param key:
        :rtype: callable
        c                    s    d}|   |¡rtd ˆ ¡ƒ‚| S )Núfile:zCOnly strings are accepted for the {0} field, files are not accepted)ro   Ú
ValueErrorr3   )r(   Úexclude_directive©rY   r   r    r‚   I  s   
þz3ConfigHandler._exclude_files_parser.<locals>.parserr   )rŒ   rY   r‚   r   r±   r    Ú_exclude_files_parser=  s   	z#ConfigHandler._exclude_files_parserc                    s\   d}t |tƒs	|S | |¡s|S |t|ƒd… }dd„ | d¡D ƒ}d ‡ fdd„|D ƒ¡S )aO  Represents value as a string, allowing including text
        from nearest files using `file:` directive.

        Directive is sandboxed and won't reach anything outside
        directory with setup.py.

        Examples:
            file: README.rst, CHANGELOG.md, src/file.txt

        :param str value:
        :rtype: str
        r®   Nc                 s   s    � | ]}t j | ¡ ¡V  qd S r   )rD   r;   rE   rq   r™   r   r   r    r.   k  s   € z,ConfigHandler._parse_file.<locals>.<genexpr>r…   r†   c                 3   s4   � | ]}ˆ   |¡s	 	 tj |¡rˆ  |¡V  qdS )TN)Ú_assert_localrD   r;   rF   Ú
_read_filer™   ©rŒ   r   r    r.   l  s   € ýý
ý
ÿ)r"   Ústrro   Úlenr‹   Újoin)rŒ   r(   Úinclude_directiver   Ú	filepathsr   rµ   r    Ú_parse_fileT  s   

þzConfigHandler._parse_filec                 C   s   |   t ¡ ¡std|  ƒ‚d S )Nz#`file:` directive can not access %s)ro   rD   rG   r   )rP   r   r   r    r³   r  s   ÿzConfigHandler._assert_localc                 C   s:   t j| dd��}| ¡ W  d   ƒ S 1 sw   Y  d S )Nzutf-8)Úencoding)Úior   r   )rP   Úfr   r   r    r´   w  s   $ÿzConfigHandler._read_filec              	   C   s0  d}|  |¡s	|S | |d¡ ¡  d¡}| ¡ }d |¡}|p d}t ¡ }|ra|d |v rR||d  }| dd¡}	t	|	ƒdkrOtj
 t ¡ |	d ¡}|	d }n|}nd|v ratj
 t ¡ |d ¡}t|ƒ�& ztt|ƒ|ƒW W  d  ƒ S  tyƒ   t |¡}
Y nw W d  ƒ n1 sŽw   Y  t|
|ƒS )	z·Represents value as a module attribute.

        Examples:
            attr: package.attr
            attr: package.module.attr

        :param str value:
        :rtype: str
        zattr:rl   rm   r!   r   ú/é   N)ro   rp   rq   r‹   Úpopr¸   rD   rG   Úrsplitr·   r;   r>   rW   r   r1   r   Úimport_module)rŒ   r(   rg   Úattr_directiveÚ
attrs_pathÚ	attr_nameÚmodule_nameÚparent_pathÚcustom_pathÚpartsr   r   r   r    Ú_parse_attr|  s8   



ýþú
zConfigHandler._parse_attrc                    r­   )z¹Returns parser function to represents value as a list.

        Parses a value applying given methods one after another.

        :param parse_methods:
        :rtype: callable
        c                    s   | }ˆ D ]}||ƒ}q|S r   r   )r(   ÚparsedÚmethod©Úparse_methodsr   r    r   ´  s   
z1ConfigHandler._get_parser_compound.<locals>.parser   )rŒ   rÏ   r   r   rÎ   r    Ú_get_parser_compoundª  s   
z"ConfigHandler._get_parser_compoundc                 C   s6   i }|pdd„ }|  ¡ D ]\}\}}||ƒ||< q|S )zÊParses section options into a dictionary.

        Optionally applies a given parser to values.

        :param dict section_options:
        :param callable values_parser:
        :rtype: dict
        c                 S   s   | S r   r   )r¦   r   r   r    Ú<lambda>É  s    z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)rn   )rŒ   rt   Úvalues_parserr(   rY   Ú_r¦   r   r   r    Ú_parse_section_to_dict¾  s
   
z$ConfigHandler._parse_section_to_dictc              	   C   s8   |  ¡ D ]\}\}}z|| |< W q ty   Y qw dS )zQParses configuration file section.

        :param dict section_options:
        N)rn   r|   )r   rt   r   rÓ   r(   r   r   r    Úparse_sectionÎ  s   ÿüzConfigHandler.parse_sectionc                 C   sb   | j  ¡ D ])\}}d}|rd| }t| d|  dd¡dƒ}|du r*td| j|f ƒ‚||ƒ qdS )zTParses configuration file items from one
        or more related sections.

        rl   z_%szparse_section%srm   Ú__Nz0Unsupported distribution option section: [%s.%s])rr   rn   rW   rp   r   r`   )r   rs   rt   Úmethod_postfixÚsection_parser_methodr   r   r    r   Ú  s"   üÿÿ
ízConfigHandler.parsec                    s   t ˆ ƒ‡ ‡‡fdd„ƒ}|S )zèthis function will wrap around parameters that are deprecated

        :param msg: deprecation message
        :param warning_class: class of warning exception to be raised
        :param func: function to be wrapped around
        c                     s   t  ˆˆ¡ ˆ | i |¤ŽS r   )ÚwarningsÚwarn)ÚargsÚkwargs©ÚfuncÚmsgÚwarning_classr   r    Úconfig_handlerü  s   z@ConfigHandler._deprecated_config_handler.<locals>.config_handlerr   )r   rÞ   rß   rà   rá   r   rÝ   r    Ú_deprecated_config_handlerô  s   z(ConfigHandler._deprecated_config_handler©F)r…   r   )r6   r7   r8   r9   r`   rz   r!   Úpropertyrx   r„   ÚclassmethodrŽ   r    r§   r¬   r²   r»   Ústaticmethodr³   r´   rË   rÐ   rÔ   rÕ   r   râ   r   r   r   r    rk   £   sF    

&

	



-
rk   c                       sL   e Zd ZdZdddddœZdZ	 	d‡ fd	d
„	Zedd„ ƒZdd„ Z	‡  Z
S )re   rf   ÚurlÚdescriptionÚclassifiersÚ	platforms)Ú	home_pageÚsummaryÚ
classifierÚplatformFNc                    s   t t| ƒ |||¡ || _d S r   )Úsuperre   r!   rg   )r   rX   ri   rB   rg   ©rw   r   r    r!     s   
ÿ
zConfigMetadataHandler.__init__c                 C   s^   | j }| j}| j}| j}||||  |dt¡||  ||¡|dƒ|  |dƒdt¡|||| j|dœS )ru   z[The requires parameter is deprecated, please use install_requires for runtime dependencies.ÚlicenseÚlicense_filezDThe license_file parameter is deprecated, use license_files instead.)rê   ÚkeywordsÚprovidesÚrequiresÚ	obsoletesré   rñ   rò   Úlicense_filesrè   Úlong_descriptionÚversionÚproject_urls)rŽ   r»   r§   r²   râ   ÚDeprecationWarningrÐ   Ú_parse_version)r   Ú
parse_listÚ
parse_fileÚ
parse_dictÚexclude_files_parserr   r   r    rx     s4   ü
üézConfigMetadataHandler.parsersc                 C   s¢   |   |¡}||kr)| ¡ }zt|ƒ W |S  ty(   d}t|jdi tƒ ¤Žƒ‚w |  || j¡}t	|ƒr7|ƒ }t
|tƒsOt|dƒrKd tt|ƒ¡}|S d| }|S )zSParses `version` option value.

        :param value:
        :rtype: str

        zCVersion loaded from {value} does not comply with PEP 440: {version}Ú__iter__rm   z%sNr   )r»   rq   r	   r
   r   r3   r   rË   rg   Úcallabler"   r¶   Úhasattrr¸   Úmap)r   r(   rù   Útmplr   r   r    rü   ?  s(   

ùÿû	

þz$ConfigMetadataHandler._parse_version)FN)r6   r7   r8   r`   rz   Ústrict_moder!   rä   rx   rü   Ú__classcell__r   r   rð   r    re     s    üÿ
!re   c                   @   sd   e Zd ZdZedd„ ƒZdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )rd   ri   c                 C   sN   | j }t| j dd�}| j}| j}| j}||||||||||| j| j|t|dœS )ru   ú;r•   )Úzip_safeÚinclude_package_datarg   ÚscriptsÚeager_resourcesÚdependency_linksÚnamespace_packagesÚinstall_requiresÚsetup_requiresÚtests_requireÚpackagesÚentry_pointsÚ
py_modulesÚpython_requiresÚcmdclass)rŽ   r   r¬   r§   Ú_parse_cmdclassÚ_parse_packagesr»   r   )r   rý   Úparse_list_semicolonÚ
parse_boolrÿ   Úparse_cmdclassr   r   r    rx   i  s*   ñzConfigOptionsHandler.parsersc                    s$   dd„ ‰ ‡ fdd„|   |¡ ¡ D ƒS )Nc                 S   s8   |   d¡}| |d d … }| d |… }t|ƒ}t||ƒS )Nrm   rÀ   )ÚrfindÚ
__import__rW   )Úqualified_class_nameÚidxÚ
class_nameÚpkg_namer   r   r   r    Úresolve_class…  s
   

z;ConfigOptionsHandler._parse_cmdclass.<locals>.resolve_classc                    s   i | ]	\}}|ˆ |ƒ“qS r   r   ©r)   ÚkÚv©r"  r   r    Ú
<dictcomp>Ž  s    z8ConfigOptionsHandler._parse_cmdclass.<locals>.<dictcomp>)r§   rn   )r   r(   r   r&  r    r  „  s   	z$ConfigOptionsHandler._parse_cmdclassc                 C   sn   ddg}|  ¡ }||vr|  |¡S ||d k}|  | j di ¡¡}|r*ddlm} nddlm} |d	i |¤ŽS )
zTParses `packages` option value.

        :param value:
        :rtype: list
        zfind:zfind_namespace:rÀ   zpackages.findr   )Úfind_namespace_packages)Úfind_packagesNr   )rq   rŽ   Úparse_section_packages__findrr   r{   Ú
setuptoolsr(  r)  )r   r(   Úfind_directivesÚtrimmed_valueÚfindnsÚfind_kwargsr)  r   r   r    r  �  s   
ÿz$ConfigOptionsHandler._parse_packagesc                    sR   |   || j¡}g d¢‰ t‡ fdd„| ¡ D ƒƒ}| d¡}|dur'|d |d< |S )zœParses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        )ÚwhereÚincludeÚexcludec                    s$   g | ]\}}|ˆ v r|r||f‘qS r   r   r#  ©Ú
valid_keysr   r    rˆ   ¶  s   $ zEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>r0  Nr   )rÔ   rŽ   r^   rn   r{   )r   rt   Úsection_datar/  r0  r   r3  r    r*  ª  s   ÿ
z1ConfigOptionsHandler.parse_section_packages__findc                 C   s   |   || j¡}|| d< dS )z`Parses `entry_points` configuration file section.

        :param dict section_options:
        r  N)rÔ   rŽ   ©r   rt   rÌ   r   r   r    Úparse_section_entry_points¿  s   z/ConfigOptionsHandler.parse_section_entry_pointsc                 C   s.   |   || j¡}| d¡}|r||d< |d= |S )Nr�   rl   )rÔ   rŽ   r{   )r   rt   rÌ   Úrootr   r   r    Ú_parse_package_dataÇ  s   
z(ConfigOptionsHandler._parse_package_datac                 C   ó   |   |¡| d< dS )z`Parses `package_data` configuration file section.

        :param dict section_options:
        Úpackage_dataN©r9  ©r   rt   r   r   r    Úparse_section_package_dataÑ  ó   z/ConfigOptionsHandler.parse_section_package_datac                 C   r:  )zhParses `exclude_package_data` configuration file section.

        :param dict section_options:
        Úexclude_package_dataNr<  r=  r   r   r    Ú"parse_section_exclude_package_dataØ  r?  z7ConfigOptionsHandler.parse_section_exclude_package_datac                 C   s"   t | jdd�}|  ||¡| d< dS )zbParses `extras_require` configuration file section.

        :param dict section_options:
        r  r•   Úextras_requireN)r   rŽ   rÔ   )r   rt   rý   r   r   r    Úparse_section_extras_requireß  s   ÿz1ConfigOptionsHandler.parse_section_extras_requirec                 C   s(   |   || j¡}dd„ | ¡ D ƒ| d< dS )z^Parses `data_files` configuration file section.

        :param dict section_options:
        c                 S   s   g | ]\}}||f‘qS r   r   r#  r   r   r    rˆ   ï  s    zAConfigOptionsHandler.parse_section_data_files.<locals>.<listcomp>Ú
data_filesN)rÔ   r    rn   r6  r   r   r    Úparse_section_data_filesé  s   z-ConfigOptionsHandler.parse_section_data_filesN)r6   r7   r8   r`   rä   rx   r  r  r*  r7  r9  r>  rA  rC  rE  r   r   r   r    rd   e  s    


rd   )FFrã   ) r   r½   rD   r:   rÙ   rV   r   Úcollectionsr   r   r   Úglobr   Ú
contextlibÚdistutils.errorsr   r   Ú#setuptools.extern.packaging.versionr	   r
   Ú&setuptools.extern.packaging.specifiersr   r   Úcontextmanagerr>   rU   r]   rO   rM   rk   re   rd   r   r   r   r    Ú<module>   s6    

-
  ca