ó
Ý²k^c           @` s  d  Z  d d l 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 d	 l m Z m Z m Z d d
 l m Z 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! m" Z" m# Z# d d l$ Z$ e e% ƒ Z& e d d d d g ƒ Z' e d ƒ Z( d e* d „ Z+ d „  Z, d „  Z- d „  Z. d „  Z/ d „  Z0 d „  Z1 d „  Z2 d e f d „  ƒ  YZ3 d e
 f d „  ƒ  YZ4 d  d% d! „ Z5 e% d" k re e$ j6 d# ƒ Z7 e0 e e7 d$ ƒ ƒ Z8 e1 e7 e8 ƒ n  d S(&   s<  
=====
Usage
=====

Method #1: auxlib.packaging as a run time dependency
---------------------------------------------------

Place the following lines in your package's main __init__.py

from auxlib import get_version
__version__ = get_version(__file__)



Method #2: auxlib.packaging as a build time-only dependency
----------------------------------------------------------


import auxlib

# When executing the setup.py, we need to be able to import ourselves, this
# means that we need to add the src directory to the sys.path.
here = os.path.abspath(os.path.dirname(__file__))
src_dir = os.path.join(here, "auxlib")
sys.path.insert(0, src_dir)

setup(
    version=auxlib.__version__,
    cmdclass={
        'build_py': auxlib.BuildPyCommand,
        'sdist': auxlib.SDistCommand,
        'test': auxlib.Tox,
    },
)



Place the following lines in your package's main __init__.py

from auxlib import get_version
__version__ = get_version(__file__)


Method #3: write .version file
------------------------------



Configuring `python setup.py test` for Tox
------------------------------------------

must use setuptools (distutils doesn't have a test cmd)

setup(
    version=auxlib.__version__,
    cmdclass={
        'build_py': auxlib.BuildPyCommand,
        'sdist': auxlib.SDistCommand,
        'test': auxlib.Tox,
    },
)


i    (   t   absolute_importt   divisiont   print_function(   t
   namedtuple(   t   build_py(   t   sdist(   t   convert_path(   t   fnmatchcase(   t	   getLogger(   t   getenvt   listdirt   remove(   t   abspatht   dirnamet
   expandusert   isdirt   isfilet   join(   t   compile(   t   shlex_split_unicode(   t   CalledProcessErrort   PIPEt   PopenNt   Responset   stdoutt   stderrt   rcsT   (?:[_-a-zA-Z]*)(?P<version>[a-zA-Z0-9.]+)(?:-(?P<post>\d+)-g(?P<hash>[0-9a-f]{7,}))$c         C` sÝ   | d  k r t j n	 t | ƒ } t t |  ƒ d | d t d t ƒ} | j ƒ  \ } } | j } t	 j
 d j | |  | | | ƒ ƒ | rµ | d k rµ t | |  d j | | ƒ ƒ ‚ n  t | j d ƒ | j d ƒ t | ƒ ƒ S(   Nt   cwdR   R   s0   {0} $  {1}
  stdout: {2}
  stderr: {3}
  rc: {4}i    s   stdout: {0}
stderr: {1}s   utf-8(   t   Nonet   syst   prefixR   R   R   R   t   communicatet
   returncodet   logt   debugt   formatR   R   t   decodet   int(   t   commandt   patht   raise_on_errort   pR   R   R   (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   callZ   s    !$	!c         C` sJ   t  |  d ƒ } t | ƒ rF t | d ƒ  } | j ƒ  j ƒ  SWd  QXn  d  S(   Ns   .versiont   r(   R   R   t   opent   readt   strip(   R'   t	   file_patht   fh(    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   _get_version_from_version_filei   s    c         C` s!  y t  d |  d t ƒWn' t k
 r@ } t j t | ƒ ƒ d  SXt  d |  d t ƒ} | j d k rr | j j	 ƒ  S| j d k rš d | j
 j ƒ  k rš d  S| j d k rÂ d | j
 j ƒ  k rÂ d  S| j d k rt j d	 j t d
 d  ƒ ƒ ƒ t | j | j
 ƒ ‚ n t | j | j
 ƒ ‚ d  S(   Ns   git update-index --refreshR(   s   git describe --tags --longi    i€   s   no names founds   not a git repositoryi   s   git not found on path: PATH={0}t   PATH(   R*   t   FalseR   R!   t   warnt   reprR   R   R   R.   R   t   lowert   errorR#   R	   (   R'   t   et   response(    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   _git_describe_tagsp   s     $$c         C` sW   t  j |  ƒ } | d k r d S| j ƒ  \ } } } | d k rD | Sd j | | | ƒ S(   s€   Return a PEP440-compliant version derived from the git status.
    If that fails for any reason, return the changeset hash.
    t   0s   {0}.post{1}+{2}N(   t   GIT_DESCRIBE_REGEXt   matchR   t   groupsR#   (   t   tagt   mt   versiont   post_committ   hash(    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   _get_version_from_git_tag†   s
    c         C` s   t  |  ƒ p d } t | ƒ S(   Nt    (   R:   RD   (   R'   R?   (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   _get_version_from_git_clone‘   s    c         C` s€   t  t t |  ƒ ƒ ƒ } y t | ƒ p0 t | ƒ SWnG t k
 r[ } t j t | ƒ ƒ d St
 k
 r{ } t j | ƒ d SXd S(   sì  Returns a version string for the current package, derived
    either from git or from a .version file.

    This function is expected to run in two contexts. In a development
    context, where .git/ exists, the version is pulled from git tags.
    Using the BuildPyCommand and SDistCommand classes for cmdclass in
    setup.py will write a .version file into any dist.

    In an installed context, the .version file written at dist build
    time is the source of version information.

    N(   R   R   R   R1   RF   R   R!   R4   R5   R   t	   Exceptiont	   exception(   t   dunder_fileR'   R8   (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   get_version–   s    c      	   C` s#  t  |  d ƒ } t | ƒ s0 t d j | ƒ ƒ ‚ t | d ƒ  } | j ƒ  } Wd  QXxs t t | ƒ ƒ D]_ } | | j d ƒ r– d j | ƒ | | <qg | | j d ƒ s¹ d | | k rg d  | | <qg qg Wt
 d	 j | ƒ ƒ t | ƒ t | d
 ƒ ' } | j d j  d „  | Dƒ ƒ ƒ Wd  QXd  S(   Ns   __init__.pys   File not found: {0}R+   t   __version__s   __version__ = "{0}"
s   from auxlibs   import auxlibs   auxlib.packagings   UPDATING {0}t   wRE   c         s` s!   |  ] } | d  k	 r | Vq d  S(   N(   R   (   t   .0t   l(    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pys	   <genexpr>¼   s    (   s   from auxlibs   import auxlib(   R   R   t   AssertionErrorR#   R,   t	   readlinest   ranget   lent
   startswithR   t   printR   t   write(   t
   target_dirRA   t   target_init_filet   ft
   init_linest   q(    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   write_version_into_init®   s    !
c         C` so   t  |  ƒ s! t d j |  ƒ ƒ ‚ t |  d ƒ } t d j | | ƒ ƒ t | d ƒ  } | j | ƒ Wd  QXd  S(   Ns   Directory not found: {0}s   .versions   WRITING {0} with version {1}RL   (   R   RO   R#   R   RT   R,   RU   (   RV   RA   t   target_fileRX   (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   write_version_file¿   s
    !t   BuildPyCommandc           B` s   e  Z d  „  Z RS(   c         C` sX   t  j |  ƒ t |  j |  j j j ƒ } t | |  j j j ƒ t	 | |  j j j ƒ d  S(   N(
   R   t   runR   t	   build_libt   distributiont   metadatat   nameR[   RA   R]   (   t   selfRV   (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyR_   È   s    (   t   __name__t
   __module__R_   (    (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyR^   Ç   s   t   SDistCommandc           B` s   e  Z d  „  Z RS(   c         C` s[   t  j |  | | ƒ t | |  j j j ƒ } t | |  j j j ƒ t | |  j j j ƒ d  S(   N(	   R   t   make_release_treeR   Ra   Rb   Rc   R[   RA   R]   (   Rd   t   base_dirt   filesRV   (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyRh   Ñ   s    (   Re   Rf   Rh   (    (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyRg   Ð   s   t   .c   	      C` s  g  } t  |  ƒ d f g } x¡ | r¾ | j d ƒ \ }  } x t |  ƒ D]q } t |  | ƒ } d | k rF t | ƒ rF t t | d ƒ ƒ rF | j | | ƒ | j | | | d f ƒ qF qF Wq WxF t | ƒ d d g D]. } g  | D] } t | | ƒ sã | ^ qã } qÖ W| S(   NRE   i    Rk   s   __init__.pyt   ez_setupt   distribute_setup(	   R   t   popR
   R   R   R   t   appendt   listR   (	   t   wheret   excludet   outt   stackR   Rc   t   fnt   patt   item(    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   find_packagesÙ   s    	&,t   __main__i   s   __init__.py(    (9   t   __doc__t
   __future__R    R   R   t   collectionsR   t   distutils.command.build_pyR   t   distutils.command.sdistR   t   distutils.utilR   t   fnmatchR   t   loggingR   t   osR	   R
   R   t   os.pathR   R   R   R   R   R   t   reR   t   conda._vendor.auxlib.compatR   t
   subprocessR   R   R   R   Re   R!   R   R<   R   t   TrueR*   R1   R:   RD   RF   RJ   R[   R]   R^   Rg   Rx   t   argvRV   RA   (    (    (    s=   lib/python2.7/site-packages/conda/_vendor/auxlib/packaging.pyt   <module>B   s>   .									