mò
fAÙBc           @   s€   d  Z  d Z d Z d k Z d k Z e e e i d „ Z e e e i d „ Z e d „ Z e	 d j o e e i
 d ƒ n d S(	   s
  Bootstrap setuptools installation

If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::

    from ez_setup import use_setuptools
    use_setuptools()

If you want to require a specific version of setuptools, set a download
mirror, or use an alternate download directory, you can do so by supplying
the appropriate options to ``use_setuptools()``.

This file can also be run as a script to install or upgrade setuptools.
s   0.5a13s3   http://www.python.org/packages/source/s/setuptools/Nc         C   sá   y; d k  } | i d j o t i d IJt i d ƒ n WnJ t j
 o> t |  | | ƒ } t i i d | ƒ d k  } | | _ n Xd k } y | i d |  ƒ Wn4 | i j
 o% t i d |  IJt i d ƒ n Xd S(   s  Automatically find/download setuptools and make it available on sys.path

    `version` should be a valid setuptools version number that is available
    as an egg for download under the `download_base` URL (which should end with
    a '/').  `to_dir` is the directory where setuptools will be downloaded, if
    it is not already available.

    If an older version of setuptools is installed, this will print a message
    to ``sys.stderr`` and raise SystemExit in an attempt to abort the calling
    script.
    Ns   0.0.1s   You have an obsolete version of setuptools installed.  Please
remove it from your system entirely before rerunning this script.i   i    s   setuptools>=s   The required version of setuptools (>=%s) is not available, and
can't be installed while this script is running. Please install
 a more recent version first.(   t
   setuptoolst   __version__t   syst   stderrt   exitt   ImportErrort   download_setuptoolst   versiont   download_baset   to_dirt   eggt   patht   insertt   bootstrap_install_fromt   pkg_resourcest   requiret   VersionConflict(   R   R   R	   R   R    R
   (    (    tt   /home/tanner/projects/real-time/debian/turbogears/PyProtocols/python-pyprotocols-1.0a0dev_r2082/ez_setup/__init__.pyt   use_setuptools*   s      		c         C   s  d k  } d k }
 d |  t i d  f } | | d } t i i	 | | ƒ }	 d } } t i i |	 ƒ pŠ zX d k l } | i d | ƒ | i | ƒ } | i ƒ  } t |	 d ƒ } | i | ƒ Wd | o | i ƒ  n | o | i ƒ  n Xn t i i |	 ƒ S(   s/  Download setuptools from a specified location and return its filename

    `version` should be a valid setuptools version number that is available
    as an egg for download under the `download_base` URL (which should end
    with a '/'). `to_dir` is the directory where the egg will be downloaded.
    Ns   setuptools-%s-py%s.eggi   s   .zip(   s   logs   Downloading %st   wb(   t   urllib2t   shutilR   R   t   egg_nameR   t   urlt   osR   t   joinR	   t   savetot   Nonet   srct   dstt   existst	   distutilst   logt   warnt   urlopent   readt   datat   opent   writet   closet   realpath(   R   R   R	   R   R    R   R$   R   R   R   R   R   (    (    R   R   S   s(     
   c   
      C   s“  y d k  } Wn• t j
 o‰ d k } d k } | i d d ƒ }	 zM t | d |	 ƒ} t	 i
 i d | ƒ d k l } | t |  ƒ | g ƒ Wd | i |	 ƒ Xn  X| i d j o t | ƒ n d | } d k } y | i | ƒ Wnq | i j
 ob y d k l } Wn  t j
 o d k l } n X| t |  ƒ t ƒ  g ƒ t	 i d ƒ n6 X|  o d k l } | |  ƒ n d	 G| Gd
 GHd GHd S(   s-   Install or upgrade setuptools and EasyInstallNt   prefixs   easy_install-R	   i    (   s   mains   0.0.1s   setuptools>=s   Setuptools versions   or greater has been installed.s:   (Run "ez_setup.py -U setuptools" to reinstall or upgrade.)(   R    R   t   tempfileR   t   mkdtempt   tmpdirR   R   R
   R   R   R   t   setuptools.command.easy_installt   maint   listt   argvt   rmtreeR   R   t   reqR   R   R   t   easy_installR   (
   R0   R   R.   R2   R   R*   R    R   R
   R,   (    (    R   R.   |   s>      
	t   __main__i   (   t   __doc__t   DEFAULT_VERSIONt   DEFAULT_URLR   R   t   curdirR   R   R.   t   __name__R0   (   R6   R   R7   R   R.   R   R   (    (    R   t   ?   s   ))&