
вEbc           @   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 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 d d l 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% e j& d k  rnd d l' m( Z) n d d l' m) Z) e j* Z* e j+ Z+ d Z, d   Z- d   Z. e/ e/ d  Z0 d   Z1 d   Z2 d   Z3 d   Z4 d e f d     YZ5 d S(    sI   
Create a wheel (.whl) distribution.

A wheel is a built archive format.
iN(   t   OrderedDict(   t   Command(   t   log(   t   BytesIO(   t   iglob(   t   rmtree(   t   get_config_var(   t   ZIP_DEFLATEDt
   ZIP_STOREDi   (   t   write_pkg_info(   t   calculate_macosx_platform_tag(   t   pkginfo_to_metadata(   t   tags(   t	   WheelFile(   t   __version__i   (   t	   Generator(   t   BytesGenerators   cp3\dc           C   s   d j  t j d  S(   Ns   py{}i    (   t   formatt   syst   version_info(    (    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt
   python_tag+   s    c         C   sd   t  j j   } | j d  r< |  d k	 r< t |  |  } n  | d k r` t j d k r` d } n  | S(   s0   Return our platform name 'win32', 'linux_x86_64't   macosxt   linux_x86_64it
   linux_i686N(   t	   distutilst   utilt   get_platformt
   startswitht   NoneR
   R   t   maxsize(   t   archive_roott   result(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyR   /   s    	c         C   sK   t  |   } | d k rA | r= t j d j |   t d  n  | S| | k S(   sf   Use a fallback value for determining SOABI flags if the needed config
    var is unset or unavailable.s?   Config variable '{0}' is unset, Python ABI tag may be incorrecti   N(   R   R   t   warningst   warnR   t   RuntimeWarning(   t   vart   fallbackt   expectedR!   t   val(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   get_flag;   s    c       	   C   s  t  d  }  t j   } |  r4| d k r4t t d  r4d } d } d } t d t t d  d | d k ry d	 } n  t d
 | d k d | d k o t j d k  r t j d k  r d } n  t d t j d k d d d | d k o t j d k  rt j d k  rd } n  d | t j   | | | f } n |  rc|  j	 d  rcd |  j
 d  d } n |  r|  j	 d  rd j |  j
 d  d   } | j d d  j d d  } n- |  r|  j d d  j d d  } n d  } | S(!   sX   Return the ABI tag based on SOABI (if available) or emulate SOABI
    (CPython 2, PyPy).t   SOABIt   cpt   ppt
   maxunicodet    t   Py_DEBUGt   gettotalrefcountR!   t   dt   WITH_PYMALLOCi   i   t   mt   Py_UNICODE_SIZEi R%   i   t   us
   %s%s%s%s%ss   cpython-t   -i   s   pypy-i   t   .t   _(   R)   R*   (   i   i   (   i   i   (   i   i   (   i   i   N(   R   R   t   interpreter_namet   hasattrR   R'   R   R+   t   interpreter_versionR   t   splitt   joint   replaceR   (   t   soabit   implR/   R1   R3   t   abi(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   get_abi_tagG   sB    "			"!!c         C   s   t  |   j d d  S(   NR4   R6   (   t	   safe_nameR<   (   t   name(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt
   safer_nameo   s    c         C   s   t  |   j d d  S(   NR4   R6   (   t   safe_versionR<   (   t   version(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   safer_versions   s    c         C   s0   t  | d  GHt j | t j  |  |  d  S(   Ni   (   t   strt   ost   chmodt   statt   S_IWRITE(   t   funct   patht   excinfo(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   remove_readonlyw   s    t   bdist_wheelc           B   s  e  Z d  Z e d e f d e f g  Z d0 d d d e d1  f d	 d
 d d f d2 d3 d4 d5 d6 d7 d d1 d j	 d j
 e   f d d1 d  e   f d8 d9 g Z d	 d d d g Z d%   Z d&   Z e d'    Z d(   Z d)   Z d* e d+ d,  Z d-   Z e d.    Z d/   Z RS(:   s   create a wheel distributiont   storedt   deflateds
   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=R/   s-   directory to put final built distributions ins
   skip-builds2   skip rebuilding everything (for testing/debugging)t   relatives7   build the archive using relative paths (default: false)s   owner=R3   s@   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   compression=s6   zipfile compression (one of: {}) (default: 'deflated')s   , s   python-tag=s7   Python implementation compatibility tag (default: '%s')s   build-number=sq   Build number for this particular version. As specified in PEP-0427, this must start with a digit. [default: None]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  |  _ t |  _ d  |  _ d  |  _ t |  _ d |  _ t   |  _ d  |  _ t |  _ t |  _ d  S(   Nt   zipRR   (   R   t	   bdist_dirt   data_dirt	   plat_namet   plat_tagR   t   Falset	   keep_tempt   dist_dirt   egginfo_dirt   root_is_puret
   skip_buildRV   t   ownert   groupRX   t   compressionR   t   build_numbert   py_limited_apit   plat_name_supplied(   t   self(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   initialize_options   s&    																	c         C   s  |  j  d  k r< |  j d  j } t j j | d  |  _  n  |  j d |  _ |  j	 d  k	 |  _
 y |  j |  j |  _ Wn) t k
 r t d j |  j    n Xd } |  j d t | |   |  j j   p |  j j   |  _ |  j rt j t |  j  rt d t   n  |  j j d  } d	 | k rtt j d
  | d	 d j   } | j   d k rtt |  _  qtn  |  j! d  k	 r|  j! d  j"   rt d   n  d  S(   Nt   bdistt   wheels   .datas   Unsupported compression: {}R`   R\   Rc   s   py-limited-api must match '%s'RX   s=   The [wheel] section is deprecated. Use [bdist_wheel] instead.i   t   1t   truet   yess1   Build tag (build-number) must start with a digit.(   R`   R\   Rc   (   Rn   Ro   Rp   (#   RZ   R   t   get_finalized_commandt
   bdist_baseRH   RM   R;   t   wheel_dist_nameR[   R\   Ri   t   supported_compressionsRf   t   KeyErrort
   ValueErrorR   t   set_undefined_optionsRY   t   distributiont   has_ext_modulest   has_c_librariesRb   Rh   t   ret   matcht   PY_LIMITED_API_PATTERNt   get_option_dictt   loggerR!   t   stript   lowert   TrueRX   Rg   t   isdigit(   Rj   Rr   t   need_optionsRm   R&   (    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   finalize_options   s0    	#c         C   sS   t  |  j j    t |  j j    f } |  j rF | |  j f 7} n  d j |  S(   s4   Return distribution full name with - replaced with _R4   (   RC   Rx   t   get_nameRF   t   get_versionRg   R;   (   Rj   t
   components(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyRs      s
    	c   	      C   s  |  j  r |  j } nm |  j r' d } n[ |  j rO |  j j d  rO |  j } n t |  j  } | d k r t j d k r d } n  | j   j	 d d  j	 d	 d  } |  j r |  j
 r d
 } n	 |  j } | d | f } n t j   } t j   } | | } |  j r,| | j d  r,|  j } d } n t t    j   } | | | f } g  t j   D] } | j | j | f ^ q]} | | k st d j |    | S(   Nt   anyR   s   linux-x86_64R   iR   R4   R6   R5   s   py2.py3t   nonet   cp3t   abi3s)   would build wheel with unsupported tag {}(   s   linux-x86_64R   (   Ri   R\   Rb   R   R   RZ   R   R   R   R<   RX   R   R   R7   R9   Rh   RG   R@   t   sys_tagst   interpreterR?   t   AssertionErrorR   (	   Rj   R\   R>   t   tagt	   impl_namet   impl_vert   abi_tagt   tt   supported_tags(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   get_tag   s6    				$				
		+!c         C   s2  |  j  d  } d | _ t | _ |  j  d  } t | _ |  j sR |  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 rAd n d |  t j d |  j  |  j d  |  j   \ } } }	 d j |  j | | |	  }
 |  j s|  j } n$ t j j |  j |  j | j   } |  j d d"  d j t  |  j! j"    t# |  j! j$     } t j j |  j |  } |  j% |  j& |  |  j' |  t j j( |  j)  stt j* |  j)  n  t j j |  j) |
 d  } t+ | d |  j,   } | j- |  Wd  QXt. |  j! d g   j/ d d j t0 j1 d    | f  |  j2 s.t j d |  j  |  j3 s.t4 |  j d  t5 q.n  d  S(#   Nt   build_scriptst   pythont	   build_extt   buildt   installt   reinit_subcommandst   install_scriptst   headerst   scriptst   datat   purelibt   platlibt   install_R,   t   nts   ..t   install_purelibt   install_platlibs   installing to %ss   {}-{}-{}-{}t   install_egg_infot   targetRa   s   {}-{}.dist-infos   .whlt   wt
   dist_filesRP   s   {}.{}i   s   removing %st   onerror(   R   R   R   R   R   (   R   Ra   (6   t   reinitialize_commandt
   executableR   t   forceR^   t   inplaceRc   t   run_commandRZ   t   roott   compilet   warn_dirt   no_ept   setattrRH   RM   R;   R[   RB   t   normpatht   install_libbaset   install_libRb   R   t   infoR   R   Rs   RV   t   _ensure_relativet   install_baseRw   RC   Rx   R   RF   R   t   egg2distRa   t   write_wheelfilet   existsR`   t   makedirsR   Rf   t   write_filest   getattrt   appendR   R   R_   t   dry_runR   RO   (   Rj   R   R   R   R   t   keyt   basedir_observedt   impl_tagR   R]   t   archive_basenameR   t   distinfo_dirnamet   distinfo_dirt
   wheel_patht   wf(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   run"  sn    								$		
		s   bdist_wheel (t   )c         C   s  d d l  m } t j d k  rA t | t  rA | j d  } n  |   } d | d <| | d <t |  j  j   | d <|  j	 d  k	 r |  j	 | d	 <n  |  j   \ } } } xg | j d
  D]V } xM | j d
  D]< }	 x3 | j d
  D]" }
 d j | |	 |
 f  | d <q Wq Wq Wt j j | d  } t j d |  t   } t | d d j |  t | d  & } | j | j   j d d   Wd  QXd  S(   Ni(   t   Messagei   s   utf-8s   1.0s   Wheel-VersionR   s   Root-Is-Purelibt   BuildR5   R4   t   Tagt   WHEELs   creating %st   maxheaderleni    t   wbs   
s   (   i   (   t   email.messageR   R   R   t
   isinstanceRG   t   encodeRb   R   Rg   R   R   R:   R;   RH   RM   R   R   R   R   t   flattent   opent   writet   getvalueR<   (   Rj   t   wheelfile_baset	   generatorR   t   msgR   R   R]   R>   R?   t   platt   wheelfile_patht   buffert   f(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyR   v  s(    	

(	c         C   sC   t  j j |  \ } } | d d !t  j k r? | | d } n  | S(   Ni    i   (   RH   RM   t
   splitdrivet   sep(   Rj   RM   t   drive(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyR     s    c         C   s.  |  j  j d  } t   } t d   | j d d  d j   D  } d | k r{ t j d t  | j	 | d d  n  d | k r d | k r d } n  x | D] } xz t
 |  D]l } | j d  r t j d |  q n  | | k r t j j |  r t j d | |  | j	 |  q q Wq W| S(   Nt   metadatac         S   s   h  |  ] } |  q S(    (    (   t   .0t   option(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pys	   <setcomp>  s   	 t   license_filesR,   i   t   license_filesE   The "license_file" option is deprecated. Use "license_files" instead.s   LICEN[CS]E*s   COPYING*s   NOTICE*s   AUTHORS*t   ~s4   ignoring license file "%s" as it looks like a backups/   adding license file "%s" (matched pattern "%s")(   R,   R,   (   s   LICEN[CS]E*s   COPYING*s   NOTICE*s   AUTHORS*(   Rx   R~   t   sett   sortedt   getR:   R    R!   t   DeprecationWarningt   addR   t   endswithR   t   debugRH   RM   t   isfileR   (   Rj   R   t   filest   patternst   patternRM   (    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   license_paths  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 | }	 t	 | |  }
 t  j
 |  n t  j j | d  }	 t	 | |	  }
 t j | | d	 d
   t  j j | d  } t | d   } | j   j   } Wd QX| ss| |  n  t t  j j | d  |
  xB |  j D]7 } t  j j |  } t j | t  j j | |   qW| |  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(   RH   RM   R   t   islinkt   isdirt   shutilR   t   unlink(   RT   (    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   adios  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   d d d d h S(   Ns   PKG-INFOs   requires.txts   SOURCES.txts   not-zip-safe(    (   t   xt   y(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   <lambda>  s   	s   dependency_links.txtt   rt   METADATA(   RH   RM   R   t   globR;   t   dirnamet   basenameRv   R   R   t   mkdirR   t   copytreeR   t   readR   R	   R   t   copy(   Rj   t   egginfo_patht   distinfo_pathR   R  t   patt   possiblet   errt   altt   pkginfo_patht   pkg_infot   dependency_links_patht   dependency_links_filet   dependency_linkst   license_patht   filename(    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyR     s:    	
!
#(   s
   bdist-dir=RS   s1   temporary directory for creating the distributionN(   s	   dist-dir=R/   s-   directory to put final built distributions in(   s
   skip-buildNs2   skip rebuilding everything (for testing/debugging)(   RV   Ns7   build the archive using relative paths (default: false)(   s   owner=R3   s@   Owner name used when creating a tar file [default: current user](   s   group=RW   sA   Group name used when creating a tar file [default: current group](   RX   Ns'   make a universal wheel (default: false)(   s   build-number=Nsq   Build number for this particular version. As specified in PEP-0427, this must start with a digit. [default: None](   s   py-limited-api=Ns?   Python tag (cp32|cp33|cpNN) for abi3 wheel tag (default: false)(   t   __name__t
   __module__t   descriptionR    R   R   Rt   R   R   R   R;   R   t   user_optionst   boolean_optionsRk   R   t   propertyRs   R   R   t   wheel_versionR   R   R   R   (    (    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyRP   }   sX   	       
  			$		0	T	(   i   (6   t   __doc__R   RH   R   RJ   R   R{   R    t   collectionsR    t   distutils.coreR   R   R   t   ioR   R  R   R   t	   sysconfigR   t   zipfileR   R   t   pkg_resourcest   pkginfoR	   t   macosx_libfileR
   R   R   t   vendored.packagingR   t	   wheelfileR   R,   R   R  R   t   email.generatorR   R   RA   RD   R}   R   R   R   R'   R@   RC   RF   RO   RP   (    (    (    s0   /tmp/pip-build-UPPWic/wheel/wheel/bdist_wheel.pyt   <module>   sH   					(			