ó
Ð²Ebc           @@ sZ  d  d l  m Z m 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 m Z m Z d  d l m Z m Z d  d	 l m Z d  d
 l m Z m Z e Z e e d „ Z d „  Z d „  Z e d „ Z d f  d „  ƒ  YZ  d e  f d „  ƒ  YZ! d e  f d „  ƒ  YZ" d S(   i    (   t   absolute_importt   unicode_literalsN(   t   defaultdict(   t   partial(   t   wraps(   t   import_module(   t   DistutilsOptionErrort   DistutilsFileError(   t   LegacyVersiont   parse(   t   SpecifierSet(   t   string_typest   PY3c   	      C@ sù   d d l  m } m } t j j |  ƒ }  t j j |  ƒ sM t d |  ƒ ‚ n  t j ƒ  } t j	 t j j
 |  ƒ ƒ zl | ƒ  } | r | j ƒ  n g  } |  | k r² | j |  ƒ n  | j | d | ƒt | | j d | ƒ} Wd t j	 | ƒ Xt | ƒ S(   u,  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
    i    (   t   Distributiont   _Distributionu%   Configuration file %s does not exist.t	   filenamest   ignore_option_errorsN(   t   setuptools.distR   R   t   ost   patht   abspatht   isfileR   t   getcwdt   chdirt   dirnamet   find_config_filest   appendt   parse_config_filest   parse_configurationt   command_optionst   configuration_to_dict(	   t   filepatht   find_othersR   R   R   t   current_directoryt   distR   t   handlers(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   read_configuration   s$    	c         C@ s@   d j  t ƒ    } t j t |  | ƒ } t |  | | ƒ } | ƒ  S(   u    
    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.
    u	   get_{key}(   t   formatt   localst	   functoolsR   t   getattr(   t
   target_objt   keyt   getter_namet   by_attributet   getter(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _get_optionE   s    c         C@ sX   t  t ƒ } xE |  D]= } x4 | j D]) } t | j | ƒ } | | | j | <q# Wq W| S(   u»   Returns configuration data gathered by given handlers as a dict.

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

    :rtype: dict
    (   R   t   dictt   set_optionsR.   R)   t   section_prefix(   R#   t   config_dictt   handlert   optiont   value(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR   Q   s    c         C@ sK   t  |  | | ƒ } | j ƒ  t |  j | | |  j ƒ } | j ƒ  | | f S(   uÒ  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
    (   t   ConfigOptionsHandlerR	   t   ConfigMetadataHandlert   metadatat   package_dir(   t   distributionR   R   t   optionst   meta(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR   c   s    

t   ConfigHandlerc           B@ sø   e  Z d  Z d Z i  Z e d „ Z e d „  ƒ Z	 d „  Z
 e d d „ ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z e d „  ƒ Z e d d „ ƒ Z e d „  ƒ Z e d d „ ƒ Z d „  Z d „  Z d „  Z RS(   u1   Handles metadata supplied in configuration files.c         C@ sŽ   i  } |  j  } xT | j ƒ  D]F \ } } | j | ƒ s= q n  | j | d ƒ j d ƒ } | | | <q W| |  _ | |  _ | |  _ g  |  _ d  S(   Nu    u   .(	   R1   t   itemst
   startswitht   replacet   stripR   R)   t   sectionsR0   (   t   selfR)   R;   R   RB   R1   t   section_namet   section_options(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   __init__Ž   s    				c         C@ s   t  d |  j j ƒ ‚ d S(   u.   Metadata item name to parser function mapping.u!   %s must provide .parsers propertyN(   t   NotImplementedErrort	   __class__t   __name__(   RC   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   parsersž   s    c   	      C@ s  t  ƒ  } |  j } |  j j | | ƒ } t | | | ƒ } | | k rT t | ƒ ‚ n  | r^ d  St } |  j j | ƒ } | r¸ y | | ƒ } Wq¸ t k
 r´ t	 } |  j
 sµ ‚  qµ q¸ Xn  | rÂ d  St | d | d  ƒ } | d  k r÷ t | | | ƒ n
 | | ƒ |  j j | ƒ d  S(   Nu   set_%s(   t   tupleR)   t   aliasest   getR(   t   KeyErrort   FalseRJ   t	   Exceptiont   TrueR   t   Nonet   setattrR0   R   (	   RC   t   option_nameR5   t   unknownR)   t   current_valuet   skip_optiont   parsert   setter(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   __setitem__¤   s0    			
u   ,c         C@ sf   t  | t ƒ r | Sd | k r. | j ƒ  } n | j | ƒ } g  | D] } | j ƒ  rD | j ƒ  ^ qD S(   u×   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
        u   
(   t
   isinstancet   listt
   splitlinest   splitRA   (   t   clsR5   t	   separatort   chunk(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _parse_listÊ   s    
c         C@ sw   d } i  } xd |  j  | ƒ D]S } | j | ƒ \ } } } | | k rY t d | ƒ ‚ n  | j ƒ  | | j ƒ  <q W| S(   uP   Represents value as a dict.

        :param value:
        :rtype: dict
        u   =u(   Unable to parse option value to dict: %s(   Rb   t	   partitionR   RA   (   R_   R5   R`   t   resultt   lineR*   t   sept   val(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _parse_dictÞ   s    c         C@ s   | j  ƒ  } | d k S(   uQ   Represents value as boolean.

        :param value:
        :rtype: bool
        u   1u   trueu   yes(   u   1u   trueu   yes(   t   lower(   R_   R5   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _parse_boolð   s    c         @ s   ‡  f d †  } | S(   uß   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         @ s1   d } |  j  | ƒ r- t d j ˆ  ƒ ƒ ‚ n  |  S(   Nu   file:uC   Only strings are accepted for the {0} field, files are not accepted(   R?   t
   ValueErrorR%   (   R5   t   exclude_directive(   R*   (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyRX     s    (    (   R_   R*   RX   (    (   R*   s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _exclude_files_parserú   s    c         @ sr   d } t  | t ƒ s | S| j | ƒ s, | S| t | ƒ } d „  | j d ƒ Dƒ } d j ‡  f d †  | Dƒ ƒ S(   uO  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
        u   file:c         s@ s'   |  ] } t  j j | j ƒ  ƒ Vq d  S(   N(   R   R   R   RA   (   t   .0R   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pys	   <genexpr>%  s    u   ,u   
c         3@ sE   |  ]; } ˆ  j  | ƒ s t r t j j | ƒ r ˆ  j | ƒ Vq d  S(   N(   t   _assert_localRQ   R   R   R   t
   _read_file(   Rn   R   (   R_   (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pys	   <genexpr>'  s   (   R[   R   R?   t   lenR^   t   join(   R_   R5   t   include_directivet   spect	   filepaths(    (   R_   s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _parse_file  s    c         C@ s,   |  j  t j ƒ  ƒ s( t d |  ƒ ‚ n  d  S(   Nu#   `file:` directive can not access %s(   R?   R   R   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyRo   -  s    c         C@ s,   t  j |  d d ƒ } | j ƒ  SWd  QXd  S(   Nt   encodingu   utf-8(   t   iot   opent   read(   R   t   f(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyRp   3  s    c         C@ se  d } | j  | ƒ s | S| j | d ƒ j ƒ  j d ƒ } | j ƒ  } d j | ƒ } | p^ d } t j ƒ  } | r| d | k rê | | d } | j d d ƒ }	 t	 |	 ƒ d k rá t j
 j t j ƒ  |	 d ƒ } |	 d } q| } qd | k rt j
 j t j ƒ  | d ƒ } qn  t j
 j d | ƒ z t | ƒ }
 t |
 | ƒ } Wd t j
 d t _
 X| S(	   u·   Represents value as a module attribute.

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

        :param str value:
        :rtype: str
        u   attr:u    u   .u   __init__i    u   /i   N(   R?   R@   RA   R^   t   popRr   R   R   t   rsplitRq   R   t   syst   insertR   R(   (   R_   R5   R9   t   attr_directivet
   attrs_patht	   attr_namet   module_namet   parent_patht   custom_patht   partst   module(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _parse_attr8  s0    !	%c         @ s   ‡  f d †  } | S(   u¹   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'   |  } x ˆ  D] } | | ƒ } q W| S(   N(    (   R5   t   parsedt   method(   t   parse_methods(    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR	   n  s    (    (   R_   R‹   R	   (    (   R‹   s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _get_parser_compounde  s    	c         C@ sL   i  } | p d „  } x0 | j  ƒ  D]" \ } \ } } | | ƒ | | <q" W| S(   uÊ   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(   N(    (   Rg   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   <lambda>ƒ  t    (   R>   (   R_   RE   t   values_parserR5   R*   t   _Rg   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _parse_section_to_dictx  s
    
c         C@ sI   xB | j  ƒ  D]4 \ } \ } } y | |  | <Wq t k
 r@ q Xq Wd S(   uQ   Parses configuration file section.

        :param dict section_options:
        N(   R>   RN   (   RC   RE   t   nameR   R5   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   parse_sectionˆ  s
    c         C@ s‘   xŠ |  j  j ƒ  D]y \ } } d } | r5 d | } n  t |  d | j d d ƒ d ƒ } | d k r t d |  j | f ƒ ‚ n  | | ƒ q Wd S(   uT   Parses configuration file items from one
        or more related sections.

        u    u   _%su   parse_section%su   .u   __u0   Unsupported distribution option section: [%s.%s]N(   RB   R>   R(   R@   RR   R   R1   (   RC   RD   RE   t   method_postfixt   section_parser_method(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR	   ”  s    	c         @ s%   t  ˆ  ƒ ‡  ‡ ‡ f d †  ƒ } | S(   ué    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  j ˆ ˆ ƒ ˆ  |  | Ž  S(   N(   t   warningst   warn(   t   argst   kwargs(   t   funct   msgt   warning_class(    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   config_handler³  s    (   R   (   RC   Rš   R›   Rœ   R   (    (   Rš   R›   Rœ   s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _deprecated_config_handler¬  s    !N(   RI   t
   __module__t   __doc__RR   R1   RL   RO   RF   t   propertyRJ   RZ   t   classmethodRb   Rh   Rj   Rm   Rv   t   staticmethodRo   Rp   Rˆ   RŒ   R‘   R“   R	   Rž   (    (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR=   ~   s,   	&
,		R7   c           B@ s]   e  Z d  Z i d d 6d d 6d d 6d d 6Z e Z e d d	 „ Z e d
 „  ƒ Z	 d „  Z
 RS(   u   metadatau   urlu	   home_pageu   descriptionu   summaryu   classifiersu
   classifieru	   platformsu   platformc         C@ s)   t  t |  ƒ j | | | ƒ | |  _ d  S(   N(   t   superR7   RF   R9   (   RC   R)   R;   R   R9   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyRF   Ì  s    c         C@ s    |  j  } |  j } |  j } |  j } i | d 6| d 6| d 6|  j | d t ƒ d 6| d 6|  j | | ƒ d 6| d ƒ d 6| d	 6| d
 6| d 6|  j d 6| d 6S(   u.   Metadata item name to parser function mapping.u	   platformsu   keywordsu   providesu[   The requires parameter is deprecated, please use install_requires for runtime dependencies.u   requiresu	   obsoletesu   classifiersu   licenseu   license_filesu   descriptionu   long_descriptionu   versionu   project_urls(   Rb   Rv   Rh   Rm   Rž   t   DeprecationWarningRŒ   t   _parse_version(   RC   t
   parse_listt
   parse_filet
   parse_dictt   exclude_files_parser(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyRJ   Ò  s(    				

c         C@ sØ   |  j  | ƒ } | | k ra | j ƒ  } t t | ƒ t ƒ r] d } t | j t ƒ    ƒ ‚ n  | S|  j | |  j	 ƒ } t
 | ƒ rŽ | ƒ  } n  t | t ƒ sÔ t | d ƒ rÇ d j t t | ƒ ƒ } qÔ d | } n  | S(   uS   Parses `version` option value.

        :param value:
        :rtype: str

        uC   Version loaded from {value} does not comply with PEP 440: {version}u   __iter__u   .u   %s(   Rv   RA   R[   R	   R   R   R%   R&   Rˆ   R9   t   callableR   t   hasattrRr   t   mapt   str(   RC   R5   t   versiont   tmpl(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR¦   í  s    N(   RI   RŸ   R1   RL   RO   t   strict_modeRR   RF   R¡   RJ   R¦   (    (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR7   »  s   
R6   c           B@ se   e  Z d  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z RS(
   u   optionsc         C@ s¸   |  j  } t |  j  d d ƒ} |  j } |  j } i | d 6| d 6| d 6| d 6| d 6| d 6| d	 6| d
 6| d 6| d 6| d 6| d 6| d 6| d 6|  j d 6|  j d 6| d 6t d 6S(   u.   Metadata item name to parser function mapping.R`   u   ;u   zip_safeu   use_2to3u   include_package_datau   package_diru   use_2to3_fixersu   use_2to3_exclude_fixersu   convert_2to3_doctestsu   scriptsu   eager_resourcesu   dependency_linksu   namespace_packagesu   install_requiresu   setup_requiresu   tests_requireu   packagesu   entry_pointsu
   py_modulesu   python_requires(   Rb   R   Rj   Rh   t   _parse_packagesRv   R
   (   RC   R§   t   parse_list_semicolont
   parse_boolR©   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyRJ     s.    			

c         C@ s®   d d g } | j  ƒ  } | | k r1 |  j | ƒ S| | d k } | r] t r] t d ƒ ‚ n  |  j |  j j d i  ƒ ƒ } | r” d d l m } n d d l m	 } | |   S(	   uT   Parses `packages` option value.

        :param value:
        :rtype: list
        u   find:u   find_namespace:i   u8   find_namespace: directive is unsupported on Python < 3.3u   packages.findi    (   t   find_namespace_packages(   t   find_packages(
   RA   Rb   R   R   t   parse_section_packages__findRB   RM   t
   setuptoolsRµ   R¶   (   RC   R5   t   find_directivest   trimmed_valuet   findnst   find_kwargsR¶   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR²   2  s    c         C@ s—   |  j  | |  j ƒ } d d d g } t g  | j ƒ  D]* \ } } | | k r4 | r4 | | f ^ q4 ƒ } | j d ƒ } | d k	 r“ | d | d <n  | S(   uœ   Parses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        u   whereu   includeu   excludei    N(   R‘   Rb   R/   R>   RM   RR   (   RC   RE   t   section_datat
   valid_keyst   kt   vR¼   t   where(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR·   N  s    @c         C@ s#   |  j  | |  j ƒ } | |  d <d S(   u`   Parses `entry_points` configuration file section.

        :param dict section_options:
        u   entry_pointsN(   R‘   Rb   (   RC   RE   R‰   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   parse_section_entry_pointsc  s    c         C@ sB   |  j  | |  j ƒ } | j d ƒ } | r> | | d <| d =n  | S(   Nu   *u    (   R‘   Rb   RM   (   RC   RE   R‰   t   root(    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   _parse_package_datak  s    

c         C@ s   |  j  | ƒ |  d <d S(   u`   Parses `package_data` configuration file section.

        :param dict section_options:
        u   package_dataN(   RÄ   (   RC   RE   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   parse_section_package_datau  s    c         C@ s   |  j  | ƒ |  d <d S(   uh   Parses `exclude_package_data` configuration file section.

        :param dict section_options:
        u   exclude_package_dataN(   RÄ   (   RC   RE   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt"   parse_section_exclude_package_data|  s    c         C@ s/   t  |  j d d ƒ} |  j | | ƒ |  d <d S(   ub   Parses `extras_require` configuration file section.

        :param dict section_options:
        R`   u   ;u   extras_requireN(   R   Rb   R‘   (   RC   RE   R§   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   parse_section_extras_require„  s    c         C@ sH   |  j  | |  j ƒ } g  | j ƒ  D] \ } } | | f ^ q" |  d <d S(   u^   Parses `data_files` configuration file section.

        :param dict section_options:
        u
   data_filesN(   R‘   Rb   R>   (   RC   RE   R‰   R¿   RÀ   (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   parse_section_data_files  s    (   RI   RŸ   R1   R¡   RJ   R²   R·   RÂ   RÄ   RÅ   RÆ   RÇ   RÈ   (    (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyR6     s   				
				(#   t
   __future__R    R   Rx   R   R~   R–   R'   t   collectionsR   R   R   t	   importlibR   t   distutils.errorsR   R   t#   setuptools.extern.packaging.versionR   R	   t&   setuptools.extern.packaging.specifiersR
   t   setuptools.extern.sixR   R   t   typet   __metaclass__RO   R$   R.   R   R   R=   R7   R6   (    (    (    s5   /tmp/pip-build-UPPWic/setuptools/setuptools/config.pyt   <module>   s,   .		ÿ >V