
.Wc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z y d d l	 Z	 Wn  e
 k
 r d d l j	 Z	 n Xd d l Z e j Z e j 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  d	 d l! m" Z" d	 d l# m$ Z$ m% Z% d	 d l& m' Z' d	 d l( m Z m& Z& d   Z) d   Z* d e f d     YZ+ d S(   sI   
Create a wheel (.whl) distribution.

A wheel is a built archive format.
iN(   t   rmtree(   t	   Generator(   t   get_platform(   t   Command(   t   get_python_version(   t   logi   (   t   get_abbr_implt   get_impl_vert   get_abi_tag(   t   nativet   open_for_csv(   t   archive_wheelfile(   t   read_pkg_infot   write_pkg_info(   t   pkginfo_to_dict(   t
   pep425tagst   metadatac         C   s   t  |   j d d  S(   Nt   -t   _(   t	   safe_namet   replace(   t   name(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt
   safer_name+   s    c         C   s   t  |   j d d  S(   NR   R   (   t   safe_versionR   (   t   version(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   safer_version.   s    t   bdist_wheelc           B   s  e  Z d  Z d- d d d e   f d d d	 d
 f d. d0 d1 d2 d3 d4 d d/ d e   d f g
 Z d d d d g Z d   Z d   Z	 e
 d    Z d    Z d!   Z d"   Z d# e j d$ d%  Z d&   Z d'   Z d(   Z d)   Z d*   Z d+   Z d,   Z RS(5   s   create a wheel distributions
   bdist-dir=t   bs1   temporary directory for creating the distributions
   plat-name=t   ps;   platform name to embed in generated filenames (default: %s)s	   keep-tempt   ks/   keep the pseudo-installation tree around after s!   creating the distribution archives	   dist-dir=t   ds-   directory to put final built distributions ins
   skip-builds2   skip rebuilding everything (for testing/debugging)t   relatives6   build the archive using relative paths(default: false)s   owner=t   us@   Owner name used when creating a tar file [default: current user]s   group=t   gsA   Group name used when creating a tar file [default: current group]t	   universals'   make a universal wheel (default: false)s   python-tag=s7   Python implementation compatibility tag (default: py%s)i    c         C   s   d  |  _ d  |  _ d  |  _ d  |  _ d |  _ t |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ t |  _ d  |  _ d  |  _ t |  _ d t   d |  _ t |  _ d  S(   Nt   zipt   pyi    (   t   Nonet	   bdist_dirt   data_dirt	   plat_namet   plat_tagt   formatt   Falset	   keep_tempt   dist_dirt   distinfo_dirt   egginfo_dirt   root_is_puret
   skip_buildR   t   ownert   groupR"   R   t
   python_tagt   plat_name_supplied(   t   self(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   initialize_optionsT   s"    															c         C   s   |  j  d  k r< |  j d  j } t j j | d  |  _  n  |  j d |  _ |  j	 d  k	 |  _
 d } |  j d t | |   |  j j   p |  j j   |  _ |  j j d  } d | k r | d d j   } | j   d k r t |  _ q n  d  S(   Nt   bdistt   wheels   .dataR-   R(   R1   R"   i   t   1t   truet   yes(   s   dist_dirs	   plat_names
   skip_build(   R:   s   trues   yes(   R&   R%   t   get_finalized_commandt
   bdist_baset   ost   patht   joint   wheel_dist_nameR'   R(   R5   t   set_undefined_optionsR#   t   distributiont   has_ext_modulest   has_c_librariesR0   t   get_option_dictt   stript   lowert   TrueR"   (   R6   R>   t   need_optionsR9   t   val(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   finalize_optionsg   s    	c         C   s1   d j  t |  j j    t |  j j    f  S(   s4   Return distribution full name with - replaced with _R   (   RA   R   RD   t   get_nameR   t   get_version(   R6   (    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyRB      s    c         C   s  |  j  r |  j } n$ |  j r' d } n |  j p6 t   } | j d d  j d d  } |  j r |  j rr d } n	 |  j } | d | f } nq t   } t   } t	 t
    j   } | | | | f } t j d |  j  r | n d   } | | d k s t  | S(	   Nt   anyR   R   t   .s   py2.py3t   nonet   supplied_platformi    (   R5   R(   R0   R   R   R"   R4   R   R   t   strR   RI   R   t   get_supportedR%   t   AssertionError(   R6   R(   t   implt   tagt	   impl_namet   impl_vert   abi_tagt   supported_tags(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   get_tag   s&    										c         C   s2   |  j    \ } } } d |  j | | | f } | S(   s%   Return archive name without extensions   %s-%s-%s-%s(   R]   RB   (   R6   t   impl_tagR[   R)   t   archive_basename(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   get_archive_basename   s    
c   
      C   s  |  j  d  } d | _ |  j s1 |  j d  n  |  j  d d t } |  j | _ t | _ |  j | _ t | _	 |  j  d  } t | _
 x4 d D], } t | d | t j j |  j |   q Wd } t j d k rt j j t j j |  j d   } | |  _ |  _ n  t | |  j r d n d |  t j d |  j  |  j d  |  j   } t j j |  j |  } |  j s|  j } n$ t j j |  j |  j | j   } |  j d d  t j j |  j d |  j  |  _ |  j |  j  |  j  |  j! |  j  |  j" |  j |  j  t j j# |  j  s=t j$ |  j  n  t% | |  }	 d t j& k r{t' j( t j& d d |	 g  n  t) |  j* d g   j+ d t,   |	 f  |  j- s|  j. rt j d |  j  qt/ |  j  n  d  S(   Nt   build_scriptst   pythont   buildt   installt   reinit_subcommandst   install_scriptst   headerst   scriptst   datat   purelibt   platlibt   install_t    t   nts   ..t   install_purelibt   install_platlibs   installing to %st   install_egg_infot   targetR/   s   %s.dist-infot
   WHEEL_TOOLt   signt
   dist_filesR   s   removing %s(   s   headerss   scriptss   datas   purelibs   platlib(   s   targets   egginfo_dir(0   t   reinitialize_commandt
   executableR1   t   run_commandRJ   R&   t   rootR+   t   compilet   warn_dirt   no_ept   setattrR?   R@   RA   R'   R   t   normpatht   install_libbaset   install_libR0   t   loggert   infoR`   R-   R   t   _ensure_relativet   install_baseRC   RB   R.   t   egg2distR/   t   write_wheelfilet   write_recordt   existst   makedirsR   t   environt
   subprocesst   callt   getattrRD   t   appendR   R,   t   dry_runR    (
   R6   Ra   Rd   Rf   t   keyt   basedir_observedR_   t   pseudoinstall_roott   archive_roott
   wheel_name(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   run   sf    						$		

 		s   bdist_wheel (t   )c         C   s  d d l  m } |   } d | d <| | d <t |  j  j   | d <|  j   \ } } } xg | j d  D]V } xM | j d  D]< }	 x3 | j d  D]" }
 d j | |	 |
 f  | d	 <q Wq Wqk Wt j	 j | d
  } t
 j d |  t | d    } t | d d j |  Wd  QXd  S(   Ni(   t   Messages   1.0s   Wheel-VersionR   s   Root-Is-PurelibRQ   R   t   Tagt   WHEELs   creating %st   wt   maxheaderleni    (   t   email.messageR   RT   R0   RI   R]   t   splitRA   R?   R@   R   R   t   openR   t   flatten(   R6   t   wheelfile_baset	   generatorR   t   msgR^   R[   R)   RW   t   abit   platt   wheelfile_patht   f(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyR     s    	

(c         C   sC   t  j j |  \ } } | d d !t  j k r? | | d } n  | S(   Ni    i   (   R?   R@   t
   splitdrivet   sep(   R6   R@   t   drive(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyR     s    c         C   s   t  j | |  S(   N(   R   t   pkginfo_to_metadata(   R6   t   egg_info_patht   pkginfo_path(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   _pkginfo_to_metadata  s    c         C   s.   |  j  j d  } d | k r" d S| d d S(   sF   Return license filename from a license-file key in setup.cfg, or None.R   t   license_filei   N(   RD   RG   R%   (   R6   R   (    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyR     s    c         c   s   |  j  j d  } xt d d	 f D]f \ } } | | k r= q n  | | } x; | d j   D]) } | j   } | sv qX n  | | f VqX Wq Wd S(
   s5  Generate requirements from setup.cfg as
        ('Requires-Dist', 'requirement; qualifier') tuples. From a metadata
        section in setup.cfg:

        [metadata]
        provides-extra = extra1
            extra2
        requires-dist = requirement; qualifier
            another; qualifier2
            unqualified

        Yields

        ('Provides-Extra', 'extra1'),
        ('Provides-Extra', 'extra2'),
        ('Requires-Dist', 'requirement; qualifier'),
        ('Requires-Dist', 'another; qualifier2'),
        ('Requires-Dist', 'unqualified')
        R   t   provides_extras   Provides-Extrat   requires_dists   Requires-Disti   N(   R   s   Provides-Extra(   R   s   Requires-Dist(   RD   RG   t
   splitlinesRH   (   R6   R   R   t   titlet   fieldt   line(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   setupcfg_requirements%  s    
c         C   s   t  |  j    } | s d St |  } d | k s@ d | k r^ t j d  | d =| d =n  x | D] \ } } | | | <qe Wt | |  d S(   s@   Add additional requirements from setup.cfg to file metadata_pathNs   Provides-Extras   Requires-Dists5   setup.cfg requirements overwrite values from setup.py(   t   listR   R   t   warningst   warnR   (   R6   t   metadata_patht
   additionalt   pkg_infoR   t   v(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   add_requirementsG  s     
c         C   s  d   } | |  t  j j |  s d d l } t  j j t  j j |  d  } | j |  } d | f } | r t  j j | d  } | d | f 7} n  t |   n  t  j j |  r | }	 |  j	 | |  }
 t  j
 |  n t  j j | d  }	 |  j	 | |	  }
 t j | | d	 d
   t  j j | d  } t | d   } | j   j   } Wd QX| sy| |  n  t t  j j | d  |
  t  j j | d  } |  j |  t  j j | d  } t | d |  j } d | k r^d } | j d  } t  j j | |  } t | d   } | j | j d   Wd QX| | d d d d <n  |  j   } | rd } t j | t  j j |  j |   | | d d d d <n  t | d   } t j | | d t Wd QX| |  d S(   s:   Convert an .egg-info directory into a .dist-info directoryc         S   sm   t  j j |   rG t  j j |   rG t  j j |   rG t j |   n" t  j j |   ri t  j |   n  d S(   s-   Appropriately delete directory, file or link.N(   R?   R@   R   t   islinkt   isdirt   shutilR    t   unlink(   R   (    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   adiosV  s    7iNs
   *.egg-infos)   Egg metadata expected at %s but not foundi    s-    (%s found - possible misnamed archive file?)s   PKG-INFOt   ignorec         S   s
   t  d  S(   Ns   PKG-INFOs   requires.txts   SOURCES.txts   not-zip-safe(   s   PKG-INFOs   requires.txts   SOURCES.txts   not-zip-safe(   t   set(   t   xt   y(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   <lambda>z  s     s   dependency_links.txtt   rt   METADATAs   metadata.jsonRD   t   descriptions   DESCRIPTION.rstt   wbs   utf-8t
   extensionss   python.detailst   document_namess   LICENSE.txtt   licenseR   t	   sort_keys(   R?   R@   R   t   globRA   t   dirnamet   basenamet
   ValueErrort   isfileR   t   mkdirR   t   copytreeR   t   readRH   R   R   R   RD   t   popt   writet   encodeR   t   copyR.   t   jsont   dumpRJ   (   R6   t   egginfo_patht   distinfo_pathR   R   t   patt   possiblet   errt   altR   R   t   dependency_links_patht   dependency_links_filet   dependency_linksR   t   metadata_json_patht   pymetat   description_filenamet   description_textt   description_patht   description_fileR   t   license_filenamet   metadata_json(    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyR   T  s\    	
!
		"c      
      s_  d d l  m } t j j | d  } t j j |       f d   }  f d   } t | d   } t j |  } x |   D] }	 t j j |	    }
 | |
  r d } d } n[ t	 |	 d   } | j
   } Wd  QXt j |  j   } d	 t | |   } t |  } t j j |	    j t j j d
  } | j | | | f  q WWd  QXd  S(   Ni(   t   urlsafe_b64encodet   RECORDc          3   s\   xU t  j    D]D \ }  } } | j   x( t |  D] } t  j j |  |  Vq6 Wq Wd  S(   N(   R?   t   walkt   sortt   sortedR@   RA   (   t   dirt   dirst   filesR   (   R&   (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyR     s    
c            s
   |    k S(   s!   Wheel hashes every possible file.(    (   R@   (   t   record_relpath(    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   skip  s    s   w+Rm   t   rbs   sha256=t   /(   t
   wheel.utilR   R?   R@   RA   t   relpathR
   t   csvt   writerR   R   t   hashlibt   sha256t   digestR	   t   lenR   R   t   writerow(   R6   R&   R.   R   t   record_pathR   R   t   record_fileR   R@   R   t   hasht   sizeR   Ri   R  (    (   R&   R   s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyR     s(    		(   s
   bdist-dir=R   s1   temporary directory for creating the distribution(   s	   dist-dir=R   s-   directory to put final built distributions inN(   s
   skip-buildNs2   skip rebuilding everything (for testing/debugging)(   s   relativeNs6   build the archive using relative paths(default: false)(   s   owner=R    s@   Owner name used when creating a tar file [default: current user](   s   group=R!   sA   Group name used when creating a tar file [default: current group](   s	   universalNs'   make a universal wheel (default: false)(   t   __name__t
   __module__R   R   R%   R   t   user_optionst   boolean_optionsR7   RM   t   propertyRB   R]   R`   R   R9   t   __version__R   R   R   R   R   R   R   R   (    (    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyR   1   sN    
      					S				"		R(,   t   __doc__R   R   R?   R   R   R   R   R9   t	   sysconfigt   ImportErrort   distutils.sysconfigt   pkg_resourcesR   R   R    t   email.generatorR   t   distutils.utilR   t   distutils.coreR   R   t	   distutilsR   R   R   R   R   R   t   utilR	   R
   t   archiveR   t   pkginfoR   R   R   R   Rm   R   R   R   (    (    (    s0   /tmp/pip-build-Q3rTTP/wheel/wheel/bdist_wheel.pyt   <module>   s<   				