ó
=”Q]c           @  s‹  d  Z  d d l m Z m Z m 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 m Z m Z m Z m 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 d d l  m! Z! d e f d „  ƒ  YZ" d e
 f d „  ƒ  YZ# e# j$ j% e& d ƒ d e& d ƒ f e& d ƒ d d f g ƒ e# j( j% e& d ƒ g ƒ d S(   u   
bdist_conda

iÿÿÿÿ(   t   print_functiont   divisiont   unicode_literalsN(   t   defaultdict(   t   install(   t   DistutilsOptionErrort   DistutilsGetoptError(   t   Distribution(   t   StringIOt   string_typest   configparsert   PY3t	   text_type(   t   spec_from_line(   t   MetaData(   t   api(   t   pypi(   t   handle_anaconda_upload(   t   Configt   CondaDistributionc           B  sX   e  Z d  Z i d d 6d d 6e d 6e d 6e d 6d d 6d d 6d d	 6Z d d
 „ Z RS(   uQ	  
    Distribution subclass that supports bdist_conda options

    This class is required if you want to pass any bdist_conda specific
    options to setup().  To use, set distclass=CondaDistribution in setup().

    **NOTE**: If you use setuptools, you must import setuptools before
    importing distutils.commands.bdist_conda.

    Options that can be passed to setup() (must include
    distclass=CondaDistribution):

    - conda_buildnum: The build number. Defaults to 0. Can be overridden on
      the command line with the --buildnum flag.

    - conda_buildstr: The build string. Default is generated automatically
      from the Python version, NumPy version if relevant, and the build
      number, like py34_0.

    - conda_import_tests: Whether to automatically run import tests. The
      default is True, which runs import tests for the all the modules in
      "packages". Also allowed are False, which runs no tests, or a list of
      module names to be tested on import.

    - conda_command_tests: Command line tests to run. Default is True, which
      runs ``command --help`` for each ``command`` in the console_scripts and
      gui_scripts entry_points. Also allowed are False, which doesn't run any
      command tests, or a list of command tests to run.

    - conda_binary_relocation: Whether binary files should be made relocatable
      (using install_name_tool on OS X or patchelf on Linux). The default is
      True. See the "making packages relocatable" section in the conda build
      documentation for more information on this.

    - conda_preserve_egg_dir: Whether to preserve the egg directory as
      installed by setuptools.  The default is True if the package depends on
      setuptools or has a setuptools entry_points other than console_scripts
      and gui_scripts.

    - conda_features: List of features for the package. See the features
      section of the conda build documentation for more information about
      features in conda.

    - conda_track_features: List of features that this package should track
      (enable when installed).  See the features section of the conda build
      documentation for more information about features in conda.

    Command line options:

    --buildnum: Set the build number. Defaults to the conda_buildnum passed to
      setup(), or 0. Overrides any conda_buildnum passed to setup().

    i    u   conda_buildnumu   conda_buildstru   conda_import_testsu   conda_command_testsu   conda_binary_relocationu   conda_preserve_egg_diru   conda_featuresu   conda_track_featuresc         C  s¬   i  } | rE x6 |  j  D]( } | | k r | j | ƒ | | <q q Wn  t s^ t j |  | ƒ n t ƒ  j | ƒ x7 |  j  D], } t |  j | | j | |  j  | ƒ ƒ qx Wd  S(   N(	   t   conda_attrst   popR   R   t   __init__t   supert   setattrt   metadatat   get(   t   selft   attrst   given_attrst   attr(    (    s.   lib/python2.7/distutils/command/bdist_conda.pyR   d   s    N(   t   __name__t
   __module__t   __doc__t   Nonet   TrueR   R   (    (    (    s.   lib/python2.7/distutils/command/bdist_conda.pyR      s   5
t   bdist_condac           B  sX   e  Z d  Z e d d	 e e e j ƒ  d ƒ ƒ d e ƒ Z d „  Z	 d „  Z
 d „  Z RS(
   u   create a conda packaget   build_idu   bdist_condau   _iè  t   build_is_hostc         C  s9   t  s t j |  ƒ n t ƒ  j ƒ  d  |  _ t |  _ d  S(   N(   R   R   t   initialize_optionsR   R"   t   buildnumt   Falset   anaconda_upload(   R   (    (    s.   lib/python2.7/distutils/command/bdist_conda.pyR'   |   s
    	c         C  sg   |  j  j d ƒ } |  j r* t d ƒ ‚ n  d |  j j f | d <t sV t j |  ƒ n t	 ƒ  j ƒ  d  S(   Nu   installu   --prefix is not allowedu   bdist_condau   prefix(
   t   distributiont   get_option_dictt   prefixR   t   configt   host_prefixR   R   t   finalize_optionsR   (   R   t   opt_dict(    (    s.   lib/python2.7/distutils/command/bdist_conda.pyR0   …   s    	c           sF  ˆ  j  j } x: t j D]/ } t | | ƒ s t | | t j | ƒ q q Wˆ  j d  k	 rg ˆ  j | _ n  t	 t
 ƒ } | j j ƒ  | d d <| j | d d <| j | d d <| j | d d <| j | d d <| j | d d <| j | d d	 <| j | d d
 <g  | j pg  t ˆ  j  d g  ƒ p(g  D] } t | ƒ ^ q*d g | d d <| d d <t ˆ  j  d ƒ r¥g  ˆ  j  j pg  D] } t | ƒ ^ q‚| d d <n  | j | d d <| j | d d <| j | d d <t ˆ  j  d g  ƒ } | r8t | t ƒ ród j d „  | j ƒ  Dƒ ƒ } t j ƒ  } i  } y | j  t! | ƒ ƒ Wn1 t" k
 r}} t# d t$ | ƒ d | ƒ ‚ qóXxr | j% ƒ  D]a }	 |	 d/ k râg  | j& |	 ƒ D]" }
 d |
 | j' |	 |
 ƒ f ^ q­} | | |	 <q‹d  | |	 <q‹Wn  t | t
 ƒ st# d | ƒ ‚ q8| j' d g  ƒ } | j' d g  ƒ } | j' d g  ƒ } | rŸ| rŸ| rŸt( | ƒ d  k rŸ| d d j) d! ƒ | d d j) d! ƒ n  | | | } | rÖˆ  j* j+ d" k rÖt, | d d# <n  t( | | ƒ d$ k r8| | d d <| j- t, k r5t. t/ t0 t1 j2 | ƒ ƒ ƒ | d d% <q5q8n  d! | d d k r]t, | d d <n  | j3 r¶| j3 t, k r¢ˆ  j  j4 p„g  ˆ  j  j5 p“g  | d d& <q¶| j3 | d d& <n  | j- rõt | j- t6 ƒ rõt. t/ t0 | j- ƒ ƒ | d d% <n  t
 | ƒ } t, ˆ  j* _7 t8 j9 | d' ˆ  j* ƒ} | j: ƒ  t; | j* _< d( j t$ t= j> j? ƒ t$ t= j> j@ ƒ f ƒ | j* jA d <tB jC | d) t, d* t, ƒ| j* ˆ  _* tD s­tE jF ˆ  ƒ n tG ƒ  jF ƒ  tB jC | d+ t, d* t, ƒd$ } tB jH | d' | j* ƒ| j* jI ƒ  ˆ  jJ r.d, d0 ‡  f d- †  ƒ  Y} tK | | ƒ n d. | } tL | ƒ d  S(1   Nu   packageu   nameu   versionu   buildu   numberu   stringu   binary_relocationu   preserve_egg_diru   featuresu   track_featuresu   install_requiresu   pythonu   requirementsu   runu   tests_requireu   testu   requiresu   aboutu   homeu   licenseu   summaryu   entry_pointsu   
c         s  s   |  ] } | j  ƒ  Vq d  S(   N(   t   strip(   t   .0t   x(    (    s.   lib/python2.7/distutils/command/bdist_conda.pys	   <genexpr>Ê   s    u$   ERROR: entry-points not understood: u   
The string wasu   console_scriptsu   gui_scriptsu   %s=%su.   ERROR: Could not add entry points. They were:
u   scriptsi   u
   setuptoolsu   osxu
   osx_is_appi    u   commandsu   importsR.   u   .t
   build_onlyt   notestt   postt   argsc             s   e  Z ˆ  j Z RS(    (   R   R    R*   (    (   R   (    s.   lib/python2.7/distutils/command/bdist_conda.pyR8     s   u[   # If you want to upload this package to anaconda.org later, type:
#
# $ anaconda upload %s
(   u   console_scriptsu   gui_scripts(    (M   R+   R   R   R   t   hasattrR   R(   R"   t   conda_buildnumR   t   dictt   namet   lowert   versiont   conda_buildstrt   conda_binary_relocationt   conda_preserve_egg_dirt   conda_featurest   conda_track_featurest   requirest   getattrR   t   tests_requiret   urlt   licenset   descriptiont
   isinstanceR	   t   joint
   splitlinesR
   t   ConfigParsert   readfpR   t	   ExceptionR   t   strt   sectionst   optionsR   t   lent   appendR.   t   platformR#   t   conda_command_testst   listt   mapt   unicodeR   t   make_entry_testst   conda_import_testst   packagest
   py_modulest   boolt   keep_old_workR   t   fromdictt   check_fieldsR)   t   set_build_idt   syst   version_infot   majort   minort   variantR   t   buildR   R   t   runR   t   testt   cleanR*   R   t   print(   R   R   R   t   dt   it   entry_pointst   newstrt   ct   errt   sectiont   optiont   valuet   rst   cst   gst
   entry_listt   mt   outputR8   t   no_upload_message(    (   R   s.   lib/python2.7/distutils/command/bdist_conda.pyRi      s¸    	835'	&			
#
"	
u   bdist_conda_(   R   R    RI   R   RP   t   intt   timeR#   R.   R'   R0   Ri   (    (    (    s.   lib/python2.7/distutils/command/bdist_conda.pyR$   w   s   &				u	   buildnum=u±   The build number of
    the conda package. Defaults to 0, or the conda_buildnum specified in the
    setup() function. The command line flag overrides the option to
    setup().u   anaconda-uploadu+   Upload the finished package to anaconda.org()   R!   t
   __future__R    R   R   Rc   R~   t   collectionsR   t   distutils.command.installR   t   distutils.errorsR   R   t   distutils.distR   t   conda_build.conda_interfaceR   R	   R
   R   R   RY   R   t   conda_build.metadataR   t   conda_buildR   t   conda_build.skeletonsR   t   conda_build.buildR   t   conda_build.configR   R   R$   t   user_optionst   extendRP   R"   t   boolean_options(    (    (    s.   lib/python2.7/distutils/command/bdist_conda.pyt   <module>   s*   (Z±		