
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    š’aW  ã                   @   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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)ÚDistutilsOptionErrorÚDistutilsFileError)ÚLegacyVersionÚparse)Ú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   sL   t j |¡}t|jƒ�}| ¡ }W 5 Q R X t |¡}t| ƒ 	t
ƒ ¡ | `d S ©N)Ú	importlibÚutilÚ	find_specÚopenÚoriginÚreadÚastr	   ÚvarsÚupdateÚlocalsÚself)r   ÚnameÚspecÚstrmÚsrcÚmodule© r   ú9/tmp/pip-install-7tp5dx2w/setuptools/setuptools/config.pyÚ__init__   s    
zStaticModule.__init__c              
      sX   zt ‡ fdd„| jjD ƒƒW S  tk
rR } ztdjf tƒ Žƒ|‚W 5 d }~X Y nX d S )Nc                 3   sH   | ]@}t |tjƒr|jD ](}t |tjƒr|jˆ krt |j¡V  qqd S r   )Ú
isinstancer   ZAssignÚtargetsÚNameÚidÚliteral_evalÚvalue)Ú.0Z	statementÚtarget©Úattrr   r   Ú	<genexpr>!   s     
üz+StaticModule.__getattr__.<locals>.<genexpr>z#{self.name} has no attribute {attr})Únextr   ÚbodyÚ	ExceptionÚAttributeErrorÚformatr   )r   r)   Úer   r(   r   Ú__getattr__   s    þ
ÿþzStaticModule.__getattr__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r1   r   r   r   r   r      s   r   c              	   c   s,   zt j d| ¡ dV  W 5 t j | ¡ X dS )zH
    Add path to front of sys.path for the duration of the context.
    r   N)ÚsysÚpathÚremoveÚinsert)r7   r   r   r   Ú
patch_path.   s    
r:   Fc           	   	   C   s®   ddl m}m} tj | ¡} tj | ¡s4td|  ƒ‚t ¡ }t 	tj 
| ¡¡ zJ|ƒ }|rb| ¡ ng }| |krx| | ¡ |j||d� t||j|d�}W 5 t 	|¡ X t|ƒS )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)Zsetuptools.distr;   r<   Úosr7   ÚabspathÚisfiler   ÚgetcwdÚchdirÚdirnameÚfind_config_filesÚappendÚparse_config_filesÚparse_configurationÚcommand_optionsÚconfiguration_to_dict)	ÚfilepathZfind_othersr>   r;   r<   Zcurrent_directoryÚdistr=   Úhandlersr   r   r   Úread_configuration:   s*    ÿ
 þ
rN   c                 C   s.   dj f 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})r/   r   Ú	functoolsr   Úgetattr)Ú
target_objÚkeyZgetter_nameZby_attributeÚgetterr   r   r   Ú_get_optioni   s    rT   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_optionsrT   rQ   Úsection_prefix)rM   Zconfig_dictÚhandlerÚoptionr%   r   r   r   rJ   u   s    
rJ   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)ÚdistributionrI   r>   ÚoptionsÚmetar   r   r   rH   ‡   s      ÿ  þrH   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„ ƒ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Ú Ú.)	rW   ÚitemsÚ
startswithÚreplaceÚstripr>   rQ   ÚsectionsrV   )r   rQ   r_   r>   rh   rW   Úsection_nameÚsection_optionsr   r   r   r   ²   s    

zConfigHandler.__init__c                 C   s   t d| jj ƒ‚dS )ú.Metadata item name to parser function mapping.z!%s must provide .parsers propertyN)ÚNotImplementedErrorÚ	__class__r2   )r   r   r   r   ÚparsersÂ   s    
ÿzConfigHandler.parsersc           	      C   sÆ   t ƒ }| j}| j ||¡}t|||ƒ}||kr6t|ƒ‚|r>d S d}| j |¡}|r€z||ƒ}W n  tk
r~   d}| jsz‚ Y nX |rˆd S t|d| d ƒ}|d kr®t	|||ƒ n||ƒ | j
 |¡ d S )NFTzset_%s)ÚtuplerQ   ÚaliasesÚgetrP   ÚKeyErrorrn   r-   r>   ÚsetattrrV   rF   )	r   Zoption_namer%   ÚunknownrQ   Zcurrent_valueZskip_optionÚparserÚsetterr   r   r   Ú__setitem__È   s0    zConfigHandler.__setitem__ú,c                 C   s8   t |tƒr|S d|k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   )rg   )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                 C   sP   d}i }|   |¡D ]8}| |¡\}}}||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   rg   )r   r%   r€   ÚresultÚlinerR   ÚsepÚvalr   r   r   Ú_parse_dict  s    ÿzConfigHandler._parse_dictc                 C   s   |  ¡ }|dkS )zQRepresents value as boolean.

        :param value:
        :rtype: bool
        )Ú1ÚtrueÚyes)Úlower)r   r%   r   r   r   Ú_parse_bool  s    zConfigHandler._parse_boolc                    s   ‡ 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)re   Ú
ValueErrorr/   )r%   Zexclude_directive©rR   r   r   ru   )  s    
ÿÿz3ConfigHandler._exclude_files_parser.<locals>.parserr   )r   rR   ru   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   )r?   r7   r@   rg   ©r&   r7   r   r   r   r*   I  s     z,ConfigHandler._parse_file.<locals>.<genexpr>rx   ry   c                 3   s.   | ]&}ˆ   |¡stj |¡rˆ  |¡V  qdS )TN)Ú_assert_localr?   r7   rA   Ú
_read_filer’   ©r   r   r   r*   J  s
   
  ý)r    Ústrre   Úlenr~   Újoin)r   r%   Zinclude_directiver   Z	filepathsr   r•   r   Ú_parse_file2  s    

þzConfigHandler._parse_filec                 C   s   |   t ¡ ¡std|  ƒ‚d S )Nz#`file:` directive can not access %s)re   r?   rB   r   )rK   r   r   r   r“   Q  s    ÿzConfigHandler._assert_localc              
   C   s.   t j| dd��}| ¡ W  5 Q R £ S Q R X d S )Nzutf-8)Úencoding)Úior   r   )rK   Úfr   r   r   r”   W  s    zConfigHandler._read_filec              
   C   s  d}|  |¡s|S | |d¡ ¡  d¡}| ¡ }d |¡}|p@d}t ¡ }|rÂ|d |kr¤||d  }| dd¡}	t	|	ƒdkržtj
 t ¡ |	d ¡}|	d }qÂ|}nd|krÂtj
 t ¡ |d ¡}t|ƒ�D ztt|ƒ|ƒW W  5 Q R £ S  tk
�r   t |¡}
Y nX W 5 Q R X t|
|ƒS )z·Represents value as a module attribute.

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

        :param str value:
        :rtype: str
        zattr:rb   rc   r   r   ú/é   )re   rf   rg   r~   Úpopr˜   r?   rB   Úrsplitr—   r7   r:   rP   r   r-   r   Úimport_module)r   r%   r]   Zattr_directiveZ
attrs_pathÚ	attr_nameÚmodule_nameÚparent_pathZcustom_pathÚpartsr   r   r   r   Ú_parse_attr\  s0    



zConfigHandler._parse_attrc                    s   ‡ fdd„}|S )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>¨  ó    z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)rd   )r   rj   Zvalues_parserr%   rR   Ú_r‡   r   r   r   Ú_parse_section_to_dict�  s
    
z$ConfigHandler._parse_section_to_dictc              	   C   s<   |  ¡ D ].\}\}}z|| |< W q tk
r4   Y qX qdS )zQParses configuration file section.

        :param dict section_options:
        N)rd   rr   )r   rj   r   r®   r%   r   r   r   Úparse_section­  s
    zConfigHandler.parse_sectionc                 C   sb   | j  ¡ D ]R\}}d}|r"d| }t| d|  dd¡dƒ}|dkrTtd| j|f ƒ‚||ƒ q
dS )zTParses configuration file items from one
        or more related sections.

        rb   z_%szparse_section%src   Ú__Nz0Unsupported distribution option section: [%s.%s])rh   rd   rP   rf   r   rW   )r   ri   rj   Zmethod_postfixZ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  ˆˆ¡ ˆ | |Ž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)rx   )N)N)r2   r3   r4   r5   rW   rp   r   Úpropertyrn   rw   Úclassmethodr�   rˆ   r�   r‘   r™   Ústaticmethodr“   r”   r¦   r«   r¯   r°   r	   r»   r   r   r   r   ra   ¢   s<   

&

	



-
ra   c                       sH   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 )r[   r\   ÚurlÚdescriptionÚclassifiersÚ	platforms)Z	home_pageÚsummaryÚ
classifierÚplatformFNc                    s   t t| ƒ |||¡ || _d S r   )Úsuperr[   r   r]   )r   rQ   r_   r>   r]   ©rm   r   r   r   ñ  s    ÿzConfigMetadataHandler.__init__c                 C   s^   | j }| j}| j}| j}||||  |dt¡||  ||¡|dƒ|  |dƒdt¡|||| j|dœS )rk   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É   Zlicense_filesrÀ   Úlong_descriptionÚversionZproject_urls)r�   r™   rˆ   r‘   r»   ÚDeprecationWarningr«   Ú_parse_version)r   Ú
parse_listZ
parse_fileÚ
parse_dictZexclude_files_parserr   r   r   rn   ÷  s4    ü
üëzConfigMetadataHandler.parsersc                 C   s�   |   |¡}||krB| ¡ }tt|ƒtƒr>d}t|jf tƒ Žƒ‚|S |  || j	¡}t
|ƒr^|ƒ }t|tƒsŒt|dƒr„d tt|ƒ¡}nd| }|S )zSParses `version` option value.

        :param value:
        :rtype: str

        zCVersion loaded from {value} does not comply with PEP 440: {version}Ú__iter__rc   z%s)r™   rg   r    r	   r   r   r/   r   r¦   r]   Úcallabler–   Úhasattrr˜   Úmap)r   r%   rÏ   Útmplr   r   r   rÑ     s     
ÿ

z$ConfigMetadataHandler._parse_version)FN)r2   r3   r4   rW   rp   Zstrict_moder   r¼   rn   rÑ   Ú__classcell__r   r   rÇ   r   r[   à  s   ü  ÿ
r[   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 )rZ   r_   c                 C   sV   | j }t| j dd�}| j}| j}| j}||||||||||||||| j| j|t|dœS )rk   ú;©r€   )Zzip_safeZuse_2to3Zinclude_package_datar]   Zuse_2to3_fixersZuse_2to3_exclude_fixersZconvert_2to3_doctestsÚscriptsZeager_resourcesZdependency_linksZnamespace_packagesZinstall_requiresZsetup_requiresZtests_requireÚpackagesÚentry_pointsÚ
py_modulesZpython_requiresÚcmdclass)r�   r   r�   rˆ   Ú_parse_cmdclassÚ_parse_packagesr™   r
   )r   rÒ   Zparse_list_semicolonZ
parse_boolrÓ   Zparse_cmdclassr   r   r   rn   ?  s2    ízConfigOptionsHandler.parsersc                    s$   dd„ ‰ ‡ fdd„|   |¡ ¡ D ƒS )Nc                 S   s8   |   d¡}| |d d … }| d |… }t|ƒ}t||ƒS )Nrc   rž   )ÚrfindÚ
__import__rP   )Z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>h  s   ÿ z8ConfigOptionsHandler._parse_cmdclass.<locals>.<dictcomp>)rˆ   rd   )r   r%   r   rì   r   rá   ^  s    	
þz$ConfigOptionsHandler._parse_cmdclassc                 C   sj   ddg}|  ¡ }||kr"|  |¡S ||d k}|  | j di ¡¡}|rTddlm} nddlm} |f |ŽS )zTParses `packages` option value.

        :param value:
        :rtype: list
        zfind:zfind_namespace:rž   zpackages.findr   )Úfind_namespace_packages)Úfind_packages)rg   r�   Úparse_section_packages__findrh   rq   Ú
setuptoolsrî   rï   )r   r%   Zfind_directivesZtrimmed_valueZfindnsÚfind_kwargsrï   r   r   r   râ   m  s    
ÿz$ConfigOptionsHandler._parse_packagesc                    sT   |   || j¡}dddg‰ t‡ fdd„| ¡ D ƒƒ}| d¡}|dk	rP|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 | ]\}}|ˆ kr|r||f‘qS r   r   ré   ©Z
valid_keysr   r   r{   “  s       zEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>Nr   )r¯   r�   rU   rd   rq   )r   rj   Zsection_datarò   ró   r   rö   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   rj   r§   r   r   r   Úparse_section_entry_points›  s    z/ConfigOptionsHandler.parse_section_entry_pointsc                 C   s.   |   || j¡}| d¡}|r*||d< |d= |S )NÚ*rb   )r¯   r�   rq   )r   rj   r§   Úrootr   r   r   Ú_parse_package_data£  s    
z(ConfigOptionsHandler._parse_package_datac                 C   s   |   |¡| d< dS )z`Parses `package_data` configuration file section.

        :param dict section_options:
        Úpackage_dataN©rû   ©r   rj   r   r   r   Úparse_section_package_data­  s    z/ConfigOptionsHandler.parse_section_package_datac                 C   s   |   |¡| d< dS )zhParses `exclude_package_data` configuration file section.

        :param dict section_options:
        Zexclude_package_dataNrý   rþ   r   r   r   Ú"parse_section_exclude_package_data´  s    ÿ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Û   Zextras_requireN)r   r�   r¯   )r   rj   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�   rd   r÷   r   r   r   Úparse_section_data_filesÅ  s    z-ConfigOptionsHandler.parse_section_data_filesN)r2   r3   r4   rW   r¼   rn   rá   râ   rð   rø   rû   rÿ   r   r  r  r   r   r   r   rZ   ;  s   

	rZ   )FF)F)r   r›   r?   r6   r²   rO   r   Úcollectionsr   r   r   Ú
contextlibÚdistutils.errorsr   r   Z#setuptools.extern.packaging.versionr   r	   Z&setuptools.extern.packaging.specifiersr
   r   Úcontextmanagerr:   rN   rT   rJ   rH   ra   r[   rZ   r   r   r   r   Ú<module>   s8   
   ÿ
/ ÿ
  @[