ó
X¾÷Xc           @   sÏ   d  d l  m Z d  d l  m 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
 e j Z d „  Z d „  Z e j d d	 k r° e Z e f Z n e Z e e f Z d
 „  Z	 d S(   iÿÿÿÿ(   t   core(   t   errorsN(   t   dist(   t   utilc           C   s   t  j t j ƒ t _ d  S(   N(   R   t   _get_unpatchedR    t   Distribution(    (    (    s%   /tmp/pip-build-h1VYrz/pbr/pbr/core.pyt   _monkeypatch_distribution=   s    c           C   s   t  t _ d  S(   N(   t   _saved_core_distributionR    R   (    (    (    s%   /tmp/pip-build-h1VYrz/pbr/pbr/core.pyt!   _restore_distribution_monkeypatchA   s    i    i   c   	         s  zt  ƒ  | s d St | t ƒ r8 t j j | ƒ } n t j j d ƒ } t j j | ƒ sr t j d | ƒ ‚ n  y t	 j
 | |  j ƒ } WnP t k
 rÝ t j ƒ  d } t j d ƒ t j d | | j j | f ƒ ‚ n X| ržx· | j ƒ  D]¦ \ } } t |  j d | ƒ r0t |  j d | ƒ | ƒ qñ t |  j | ƒ rXt |  j | | ƒ qñ t |  | ƒ rzt |  | | ƒ qñ d t | ƒ } t j | ƒ qñ Wn  t j j |  ƒ t |  j j t  t! f ƒ råt" |  j j ƒ |  j _ n  d	 d
 g ‰  t	 j# ‡  f d †  ƒ |  _$ Wd t% ƒ  Xd S(   s=  Implements the actual pbr setup() keyword.

    When used, this should be the only keyword in your setup() aside from
    `setup_requires`.

    If given as a string, the value of pbr is assumed to be the relative path
    to the setup.cfg file to use.  Otherwise, if it evaluates to true, it
    simply assumes that pbr should be used, and the default 'setup.cfg' is
    used.

    This works by reading the setup.cfg file, parsing out the supported
    metadata and command options, and using them to rebuild the
    `DistributionMetadata` object and set the newly added command options.

    The reason for doing things this way is that a custom `Distribution` class
    will not play nicely with setup_requires; however, this implementation may
    not work well with distributions that do use a `Distribution` subclass.
    Ns	   setup.cfgs%   The setup.cfg file %s does not exist.i   s   Error parsings   Error parsing %s: %s: %st   set_s   Unknown distribution option: %ss
   pre_hook.*s   post_hook.*c              s   t  j ˆ  ƒ S(   N(   R   t
   IgnoreDict(    (   t   ignore(    s%   /tmp/pip-build-h1VYrz/pbr/pbr/core.pyt   <lambda>™   s    (&   R   t
   isinstancet   string_typet   ost   patht   abspatht   existsR   t   DistutilsFileErrorR   t   cfg_to_argst   script_argst	   Exceptiont   syst   exc_infot   loggingt	   exceptiont   DistutilsSetupErrort	   __class__t   __name__t   itemst   hasattrt   metadatat   getattrt   setattrt   reprt   warningst   warnR    R   t   finalize_optionst   versiont   integer_typest   floatt   strt   DefaultGetDictt   command_optionsR   (	   R   t   attrt   valueR   t   attrst   et   keyt   valt   msg(    (   R   s%   /tmp/pip-build-h1VYrz/pbr/pbr/core.pyt   pbrM   sD     (   t	   distutilsR    R   R   R   R   R$   t
   setuptoolsR   R4   R   R   R   R   R   t   version_infoR*   R   t   intR(   t
   basestringt   long(    (    (    s%   /tmp/pip-build-h1VYrz/pbr/pbr/core.pyt   <module>.   s    			