ó
8Þ	Pc           @   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
 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   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=sT   basename of installation script to be run afterinstallation 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_options@   s    												c         C   sF  |  j  d  k ro |  j rB |  j rB |  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 rBxF |  j j D]% } |  j t j	 j | ƒ k rPqqWt d |  j ‚ n  d  S(
   Nt   bdistt   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(   s   dist_dirs   dist_dir(   s	   plat_names	   plat_name(   R   R   R   R   t   distributiont   get_command_objt   get_finalized_commandt
   bdist_baset   ost   patht   joinR   t   has_ext_modulesR    R   t   set_undefined_optionsR   t   scriptst   basename(   R   R   R%   t   short_versiont   script(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyt   finalize_optionsR   s2    				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 ƒ  r?|  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 rt| d } n  t | d | | ƒ qF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 ƒ  rV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(   s   purelibs   platlibR8   s   scriptss   data(/   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   R@   (   R   R2   R4   R   t   plat_specifierR1   t   keyt   valueR<   t   archive_basenamet   fullnamet   arcnamet	   pyversion(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyRT   v   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(   RN   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   urlRK   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   metadataRZ   t   long_descriptiont   getattrRN   t
   capitalizeR   R   R   R   R   R   RV   t   timet	   distutilst   ctimet   __version__R(   (   R   t   linesRo   RQ   Rg   Rm   R9   R   Rs   Rt   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   mbcst    t   rs   
 s   <iiii{V4(   t   structt   mkpathR   Ry   R[   t   announcet   opent   readt   lent   writet   get_exe_bytest   unicodet	   NameErrort
   isinstancet   encodeR   t   pack(   R   Rc   Rb   R   R   t   cfgdatat   installer_namet
   bitmapdatat	   bitmaplent   filet   script_datat   header(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyRX   ú   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   Rb   R   (    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyR[   1  s    	c   	      C   sF  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 ƒ } Wn1 t k
 r%} t t | ƒ d t j d  ‚ n Xz | j ƒ  SWd  | j ƒ  Xd  S(   Niÿÿÿÿ(   t   get_build_versions   2.4g      @gffffff@R0   i   t   winR!   s   wininst-%.1f%s.exeRz   s)   , please install the python%s-dev package(   t   distutils.msvccompilerR“   R    R   R&   R'   t   dirnamet   __file__R   R(   R‚   t   IOErrort   DistutilsFileErrort   strRA   RK   Rƒ   t   close(	   R   R“   t   cur_versiont   bvt	   directoryt   sfixt   filenamet   ft   msg(    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyR†   ?  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=NsT   basename of installation script to be run afterinstallation 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__Rj   R   R   t   user_optionst   boolean_optionsR   R/   RT   Ry   RX   R[   R†   (    (    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyR      sN    
         					$	S	17	(   t   __doc__t   __revision__RA   R&   RN   t	   sysconfigR    t   distutils.coreR   t   distutils.dir_utilR   t   distutils.errorsR   R   Rt   R   t   distutils.utilR   R   (    (    (    s5   /usr/lib/python2.7/distutils/command/bdist_wininst.pyt   <module>   s   