
^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 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 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 d l( m) Z* d 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   Command(   t   get_python_version(   t   logi   (   t   get_abbr_implt   get_impl_vert   get_abi_tagt   get_platform(   t   nativet   open_for_csv(   t   archive_wheelfile(   t   read_pkg_infot   write_pkg_info(   t   pkginfo_to_dict(   t
   pep425tagst   metadata(   t   __version__s   cp3\dc         C   s   t  |   j d d  S(   Nt   -t   _(   t	   safe_namet   replace(   t   name(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt
   safer_name.   s    c         C   s   t  |   j d d  S(   NR   R   (   t   safe_versionR   (   t   version(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   safer_version1   s    t   bdist_wheelc           B   s  e  Z d  Z d/ d d d e   f d d d	 d
 f d0 d2 d3 d4 d5 d6 d d1 d e   d f d7 g Z d d d d g Z d   Z d    Z	 e
 d!    Z d"   Z d#   Z d$   Z d% e d& d'  Z d(   Z d)   Z d*   Z d+   Z d,   Z d-   Z d.   Z RS(8   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    s   py-limited-api=s?   Python tag (cp32|cp33|cpNN) for abi3 wheel tag (default: false)c         C   s   d  |  _ d  |  _ d  |  _ d  |  _ d |  _ t |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ t |  _ d  |  _ d  |  _ t |  _ d t   d |  _ t |  _ 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   py_limited_apit   plat_name_supplied(   t   self(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   initialize_optionsZ   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 r t j t |  j  r t d t   n  |  j j d  } d | k r$| d d	 j   } | j   d k r$t |  _ q$n  d  S(   Nt   bdistt   wheels   .dataR.   R)   R2   s   py-limited-api must match '%s'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)   R7   t   set_undefined_optionsR$   t   distributiont   has_ext_modulest   has_c_librariesR1   R6   t   ret   matcht   PY_LIMITED_API_PATTERNt
   ValueErrort   get_option_dictt   stript   lowert   TrueR#   (   R8   R@   t   need_optionsR;   t   val(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   finalize_optionsn   s"    	c         C   s1   d j  t |  j j    t |  j j    f  S(   s4   Return distribution full name with - replaced with _R   (   RC   R   RF   t   get_nameR   t   get_version(   R8   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyRD      s    c         C   s  |  j  r |  j } nH |  j r' d } n6 |  j p6 t   } | d k r] t j d k r] d } n  | j d d  j d d  } |  j r |  j r d	 } n	 |  j } | d
 | f } n t	   } t
   } | | } |  j r | | j d  r |  j } d } n t t    j   } | | | f } t j d |  j  r7| n d   } |  j sv| | d k svt d | | d f   n  | | k st d |   | S(   Nt   anys   linux-x86_64t   linux_x86_64it
   linux_i686R   R   t   .s   py2.py3t   nonet   cp3t   abi3t   supplied_platformi    s   %s != %ss)   would build wheel with unsupported tag %s(   s   linux-x86_64s   linux_x86_64(   R7   R)   R1   R   t   syst   maxsizeR   R#   R5   R   R   R6   t
   startswitht   strR   RO   R   t   get_supportedR&   t   AssertionError(   R8   R)   t   implt   tagt	   impl_namet   impl_vert   abi_tagt   supported_tags(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   get_tag   s6    										
				-c         C   s2   |  j    \ } } } d |  j | | | f } | S(   s%   Return archive name without extensions   %s-%s-%s-%s(   Rj   RD   (   R8   t   impl_tagRh   R*   t   archive_basename(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   targetR0   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
   executableR2   t   run_commandRP   R'   t   rootR,   t   compilet   warn_dirt   no_ept   setattrRA   RB   RC   R(   R   t   normpatht   install_libbaset   install_libR1   t   loggert   infoRm   R.   R    t   _ensure_relativet   install_baseRE   RD   R/   t   egg2distR0   t   write_wheelfilet   write_recordt   existst   makedirsR   t   environt
   subprocesst   callt   getattrRF   t   appendR   R-   t   dry_runR    (
   R8   Rn   Rq   Rs   t   keyt   basedir_observedRl   t   pseudoinstall_roott   archive_roott
   wheel_name(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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-PurelibRY   R   t   Tagt   WHEELs   creating %st   wt   maxheaderleni    (   t   email.messageR   Ra   R1   RO   Rj   t   splitRC   RA   RB   R   R   t   openR   t   flatten(   R8   t   wheelfile_baset	   generatorR   t   msgRk   Rh   R*   Rd   t   abit   platt   wheelfile_patht   f(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyR     s    	

(c         C   sC   t  j j |  \ } } | d d !t  j k r? | | d } n  | S(   Ni    i   (   RA   RB   t
   splitdrivet   sep(   R8   RB   t   drive(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyR   (  s    c         C   s   t  j | |  S(   N(   R   t   pkginfo_to_metadata(   R8   t   egg_info_patht   pkginfo_path(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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(   RF   RM   R&   (   R8   R   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyR   2  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(   RF   RM   t
   splitlinesRN   (   R8   R   R   t   titlet   fieldt   line(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   setupcfg_requirements9  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   (   R8   t   metadata_patht
   additionalt   pkg_infoR   t   v(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   add_requirements[  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(   RA   RB   R   t   islinkt   isdirt   shutilR    t   unlink(   R   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   adiosj  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(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   <lambda>  s     s   dependency_links.txtt   rt   METADATAs   metadata.jsonRF   t   descriptions   DESCRIPTION.rstt   wbs   utf-8t
   extensionss   python.detailst   document_namess   LICENSE.txtt   licenseR   t	   sort_keys(   RA   RB   R   t   globRC   t   dirnamet   basenameRL   t   isfileR   t   mkdirR   t   copytreeR   t   readRN   R   R   R   RF   t   popt   writet   encodeR   t   copyR/   t   jsont   dumpRP   (   R8   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(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyR   h  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(   RA   t   walkt   sortt   sortedRB   RC   (   t   dirt   dirst   filesR   (   R'   (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyR     s    
c            s
   |    k S(   s!   Wheel hashes every possible file.(    (   RB   (   t   record_relpath(    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   skip  s    s   w+Rz   t   rbs   sha256=t   /(   t   utilR   RA   RB   RC   t   relpathR
   t   csvt   writerR   R   t   hashlibt   sha256t   digestR	   t   lenR   R   t   writerow(   R8   R'   R/   R   t   record_pathR   R  t   record_fileR
  RB   R  t   hasht   sizeR   Rv   R  (    (   R'   R  sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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)(   s   py-limited-api=Ns?   Python tag (cp32|cp33|cpNN) for abi3 wheel tag (default: false)(   t   __name__t
   __module__R   R   R&   R   t   user_optionst   boolean_optionsR9   RS   t   propertyRD   Rj   Rm   R   t   wheel_versionR   R   R   R   R   R   R   R   (    (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyR   4   sR    
       				'		S				"		R(/   t   __doc__R	  R  RA   R   R   R   R   R^   RI   t	   sysconfigt   ImportErrort   distutils.sysconfigt   pkg_resourcesR   R   R    t   email.generatorR   t   distutils.coreR   R   t	   distutilsR   R   R   R   R   R   R   R  R	   R
   t   archiveR   t   pkginfoR   R   R   R   Rz   R   R  RK   R   R   R   (    (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/wheel/wheel/bdist_wheel.pyt   <module>   s@   		"		