ó
è¾bc           @   sÀ   d  Z  d 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 m Z d d l m Z d d	 l m Z d d
 l m Z d e f d „  ƒ  YZ d S(   sz   distutils.command.bdist_wininst

Implements the Distutils 'bdist_wininst' command: create a windows installer
exe-program.s   $Id$iÿÿÿÿN(   t   get_python_version(   t   Command(   t   remove_tree(   t   DistutilsOptionErrort   DistutilsPlatformError(   t   DistutilsFileError(   t   log(   t   get_platformt   bdist_wininstc           B   s¹   e  Z d  Z d, d d d e ƒ  f d d d d	 f d
 d+ d d f d- d. d/ d0 d1 d2 d3 d4 d5 g Z d d d d g Z d$ „  Z d% „  Z d& „  Z	 d' „  Z
 d+ d( „ Z d) „  Z d* „  Z RS(6   s-   create an executable installer for MS Windowss
   bdist-dir=s1   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   target-version=s!   require a specific python versions    on the target systems   no-target-compilet   cs/   do not compile .py to .pyc on the target systems   no-target-optimizet   os;   do not compile .py to .pyo (optimized) on the target systems	   dist-dir=t   ds-   directory to put final built distributions ins   bitmap=t   bs>   bitmap to use for the installer instead of python-powered logos   title=t   ts?   title to display on the installer background instead of defaults
   skip-builds2   skip rebuilding everything (for testing/debugging)s   install-script=sU   basename of installation script to be run after installation or before deinstallations   pre-install-script=s{   Fully qualified filename of a script to be run before any files are installed.  This script need not be in the distributions   user-access-control=sŠ   specify Vista's UAC handling - 'none'/default=no handling, 'auto'=use UAC if target Python installed for all users, 'force'=always use UACc         C   sy   d  |  _ d  |  _ d |  _ d |  _ d |  _ d  |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ d  S(   Ni    (   t   Nonet	   bdist_dirt	   plat_namet	   keep_tempt   no_target_compilet   no_target_optimizet   target_versiont   dist_dirt   bitmapt   titlet
   skip_buildt   install_scriptt   pre_install_scriptt   user_access_control(   t   self(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyt   initialize_optionsA   s    												c         C   sV  |  j  d d	 ƒ |  j d  k r |  j rR |  j rR |  j j d ƒ } |  j | _ n  |  j d ƒ j } t	 j
 j | d ƒ |  _ n  |  j s” d |  _ n  |  j rí |  j j ƒ  rí t ƒ  } |  j rá |  j | k rá t d | f ‚ n  | |  _ n  |  j  d d
 d ƒ |  j rRxF |  j j D]% } |  j t	 j
 j | ƒ k rPqqWt d |  j ‚ n  d  S(   Nt   bdistR   t   wininstt    sM   target version can only be %s, or the '--skip-build' option must be specifiedR   R   s(   install_script '%s' not found in scripts(   R   R   (   R   R   (   R   R   (   t   set_undefined_optionsR   R   R   R   t   distributiont   get_command_objt   get_finalized_commandt
   bdist_baset   ost   patht   joinR   t   has_ext_modulesR    R   R   t   scriptst   basename(   R   R    R'   t   short_versiont   script(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyt   finalize_optionsS   s4    				c         C   sÇ  t  j d k r< |  j j ƒ  s- |  j j ƒ  r< t d ƒ ‚ n  |  j sU |  j d ƒ n  |  j d d d ƒ} |  j	 | _
 |  j | _ d | _ |  j | _ |  j d ƒ } d | _ d | _ |  j j ƒ  rB|  j } | sþ |  j së t d	 ƒ ‚ t  j d d
 !} n  d |  j | f } |  j d ƒ } t j j | j d | ƒ | _ n  xJ d D]B } t j | ƒ } | d k rw| d } n  t | d | | ƒ qIWt j d |  j	 ƒ | j ƒ  t  j j d t j j |  j	 d ƒ ƒ | j ƒ  t  j d =d d l  m! } | ƒ  }	 |  j j" ƒ  }
 |  j# |	 d d |  j	 ƒ} |  j$ | |
 |  j% ƒ |  j j ƒ  rYt& ƒ  } n d } |  j j' j( d | |  j) |
 ƒ f ƒ t j* d | ƒ t j+ | ƒ |  j, sÃt- |  j	 d |  j. ƒn  d  S(   Nt   win32s^   distribution contains extensions and/or C libraries; must be compiled on a Windows 32 platformt   buildt   installt   reinit_subcommandsi   i    t   install_libs    Should have already checked thisi   s   .%s-%st   libt   purelibt   platlibt   headersR,   t   datas   /Include/$dist_namet   install_s   installing to %st   PURELIBiÿÿÿÿ(   t   mktempt   zipt   root_dirt   anyR   s   removing temporary file '%s't   dry_run(   R7   R8   R9   R,   R:   (/   t   syst   platformR$   R+   t   has_c_librariesR   R   t   run_commandt   reinitialize_commandR   t   roott   warn_dirR   t   compilet   optimizeR   t   AssertionErrort   versionR&   R(   R)   R*   t
   build_baset	   build_libt   stringt   uppert   setattrR   t   infot   ensure_finalizedt   insertt   runt   tempfileR=   t   get_fullnamet   make_archivet
   create_exeR   R    t
   dist_filest   appendt   get_installer_filenamet   debugt   removeR   R   RA   (   R   R3   R5   R   t   plat_specifierR2   t   keyt   valueR=   t   archive_basenamet   fullnamet   arcnamet	   pyversion(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyRU   {   sf    					
%

		c         C   s÷  g  } |  j  j } | j d ƒ | j p+ d d } d „  } x d d d d d	 d
 d d g D]a } t | | d ƒ } | rZ | d t j | ƒ | | ƒ f } | j d | | | ƒ f ƒ qZ qZ W| j d ƒ |  j rì | j d |  j ƒ n  | j d | | ƒ ƒ | j d |  j ƒ | j d |  j	 ƒ |  j
 rM| j d |  j
 ƒ n  |  j rm| j d |  j ƒ n  |  j p‚|  j  j ƒ  } | j d | | ƒ ƒ d d  l } d d  l }	 d | j | j ƒ  ƒ |	 j f }
 | j d |
 ƒ t j | d ƒ S(   Ns
   [metadata]R"   s   
c         S   s   t  j |  d d ƒ S(   Ns   
s   \n(   RO   t   replace(   t   s(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyt   escapeÜ   s    t   authort   author_emailt   descriptiont
   maintainert   maintainer_emailt   namet   urlRL   s   
    %s: %ss   %s=%ss   
[Setup]s   install_script=%ss   info=%ss   target_compile=%ds   target_optimize=%ds   target_version=%ss   user_access_control=%ss   title=%siÿÿÿÿs   Built %s with distutils-%ss   build_info=%s(   R$   t   metadataR[   t   long_descriptiont   getattrRO   t
   capitalizeR   R   R   R   R   R   RW   t   timet	   distutilst   ctimet   __version__R*   (   R   t   linesRp   RR   Rh   Rn   R:   R   Rt   Ru   t
   build_info(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyt   get_inidataÎ   s<    	$			c         C   s‹  d d  l  } |  j |  j ƒ |  j ƒ  } |  j | ƒ } |  j d | ƒ | rr t | d ƒ j ƒ  } t | ƒ } n d } t | d ƒ }	 |	 j	 |  j
 ƒ  ƒ | r° |	 j	 | ƒ n  y t Wn t k
 rË n" Xt | t ƒ rí | j d ƒ } n  | d } |  j r)t |  j d ƒ j ƒ  }
 | |
 d	 } n
 | d } |	 j	 | ƒ | j d
 d t | ƒ | ƒ } |	 j	 | ƒ |	 j	 t | d ƒ j ƒ  ƒ d  S(   Niÿÿÿÿs   creating %st   rbi    t   wbt   mbcss    t   rs   
 s   <iiii{V4(   t   structt   mkpathR   Rz   R\   t   announcet   opent   readt   lent   writet   get_exe_bytest   unicodet	   NameErrort
   isinstancet   encodeR   t   pack(   R   Rd   Rc   R   R   t   cfgdatat   installer_namet
   bitmapdatat	   bitmaplent   filet   script_datat   header(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyRY   ÿ   s>    
	
			c         C   s`   |  j  r7 t j j |  j d | |  j |  j  f ƒ } n% t j j |  j d | |  j f ƒ } | S(   Ns   %s.%s-py%s.exes	   %s.%s.exe(   R   R(   R)   R*   R   R   (   R   Rc   R   (    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyR\   6  s    	c   	      C   s?  d d l  m } t ƒ  } |  j rm |  j | k rm |  j | k rL | ƒ  } qv |  j d k  rd d } qv d } n	 | ƒ  } t j j t ƒ } |  j d k rº |  j d  d k rº |  j d } n d	 } t j j	 | d
 | | f ƒ } y t
 | d ƒ } Wn* t k
 r} t t | ƒ d | ‚ n Xz | j ƒ  SWd  | j ƒ  Xd  S(   Niÿÿÿÿ(   t   get_build_versions   2.4g      @gffffff@R1   i   t   winR"   s   wininst-%.1f%s.exeR{   s)   , %s not included in the Debian packages.(   t   distutils.msvccompilerR“   R    R   R(   R)   t   dirnamet   __file__R   R*   R‚   t   IOErrorR   t   strRƒ   t   close(	   R   R“   t   cur_versiont   bvt	   directoryt   sfixt   filenamet   ft   msg(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyR†   D  s*    					"N(   s
   bdist-dir=Ns1   temporary directory for creating the distribution(   s   no-target-compileR   s/   do not compile .py to .pyc on the target system(   s   no-target-optimizeR   s;   do not compile .py to .pyo (optimized) on the target system(   s	   dist-dir=R   s-   directory to put final built distributions in(   s   bitmap=R   s>   bitmap to use for the installer instead of python-powered logo(   s   title=R   s?   title to display on the installer background instead of default(   s
   skip-buildNs2   skip rebuilding everything (for testing/debugging)(   s   install-script=NsU   basename of installation script to be run after installation or before deinstallation(   s   pre-install-script=Ns{   Fully qualified filename of a script to be run before any files are installed.  This script need not be in the distribution(   s   user-access-control=NsŠ   specify Vista's UAC handling - 'none'/default=no handling, 'auto'=use UAC if target Python installed for all users, 'force'=always use UAC(   t   __name__t
   __module__Rk   R   R   t   user_optionst   boolean_optionsR   R0   RU   Rz   RY   R\   R†   (    (    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyR      sN    
         					(	S	17	(   t   __doc__t   __revision__RB   R(   RO   t	   sysconfigR    t   distutils.coreR   t   distutils.dir_utilR   t   distutils.errorsR   R   R   Ru   R   t   distutils.utilR   R   (    (    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyt   <module>   s   