³ò
Ÿ›\Kc           @   sª   d  Z  d Z d d k Z d d k Z d d k Z d d k l Z d d k l Z d d k	 l
 Z
 l Z d d k Td d k l Z d d	 k l 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.s9   $Id: bdist_wininst.py 38697 2005-03-23 18:54:36Z loewis $iÿÿÿÿN(   t   Command(   t   get_platform(   t   create_treet   remove_tree(   t   *(   t   get_python_version(   t   logt   bdist_wininstc           B   s£   e  Z d  Z d' d d d d f d d& d d	 f d( d) d* d+ d, d- d. d/ g Z d d
 d d g Z d „  Z d  „  Z d! „  Z d" „  Z	 d& d# „ Z
 d$ „  Z d% „  Z RS(0   s-   create an executable installer for MS Windowss
   bdist-dir=s1   temporary directory for creating the distributions	   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 distributionc         C   sg   d  |  _ d |  _ d |  _ d |  _ d  |  _ d  |  _ d  |  _ d  |  _ d |  _	 d  |  _
 d  |  _ d  S(   Ni    (   t   Nonet	   bdist_dirt	   keep_tempt   no_target_compilet   no_target_optimizet   target_versiont   dist_dirt   bitmapt   titlet
   skip_buildt   install_scriptt   pre_install_script(   t   self(    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyt   initialize_options7   s    										c         C   s  |  i  d  j o. |  i d ƒ i } t i i | d ƒ |  _  n |  i p d |  _ n |  i oT |  i	 i
 ƒ  oD t ƒ  } |  i o$ |  i | j o t d | f ‚ n | |  _ n |  i d d ƒ |  i oL xI |  i	 i D]' } |  i t i i | ƒ j o PqÛ qÛ Wt d |  i ‚ n d  S(   Nt   bdistt   wininstt    sM   target version can only be %s, or the '--skip_build' option must be specifiedR   s(   install_script '%s' not found in scripts(   s   dist_dirs   dist_dir(   R   R   t   get_finalized_commandt
   bdist_baset   ost   patht   joinR   R   t   distributiont   has_ext_modulesR   t   DistutilsOptionErrort   set_undefined_optionsR   t   scriptst   basename(   R   R    t   short_versiont   script(    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyt   finalize_optionsG   s*    
	
 	c      	   C   sÊ  t  i d j o0 |  i i ƒ  p |  i i ƒ  o t d ƒ ‚ n |  i p |  i d ƒ n |  i d d d ƒ} |  i	 | _
 |  i | _ d | _ |  i d ƒ } d | _ d | _ |  i i ƒ  o} |  i } | p( |  i p
 t d	 ‚ t  i d d
 !} n d t ƒ  | f } |  i d ƒ } t i i | i d | ƒ | _ n xL d D]D } t i | ƒ } | d j o | d } n t | d | | ƒ qFWt i d |  i	 ƒ | i ƒ  t  i i d t i i |  i	 d ƒ ƒ | i ƒ  t  i d =d d k  l! } | ƒ  }	 |  i i" ƒ  }
 |  i# |	 d d |  i	 ƒ} |  i$ | |
 |  i% ƒ |  i i ƒ  o t& ƒ  } n d } |  i i' i( d | |  i) |
 ƒ f ƒ t i* d | ƒ t i+ | ƒ |  i, p t- |  i	 d |  i. ƒ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(   R3   R4   R5   s   scriptss   data(/   t   syst   platformR$   R%   t   has_c_librariest   DistutilsPlatformErrorR   t   run_commandt   reinitialize_commandR   t   roott   warn_dirt   compilet   optimizeR   t   AssertionErrort   versionR   R   R!   R"   R#   t
   build_baset	   build_libt   stringt   uppert   setattrR   t   infot   ensure_finalizedt   insertt   runt   tempfileR9   t   get_fullnamet   make_archivet
   create_exeR   R   t
   dist_filest   appendt   get_installer_filenamet   debugt   removeR   R   R=   (   R   R/   R1   R   t   plat_specifierR.   t   keyt   valueR9   t   archive_basenamet   fullnamet   arcnamet	   pyversion(    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyRR   b   sf    
				 
%

	
c         C   sß  g  } |  i  i } | i d ƒ | i p d d } d „  } xƒ d d d d d	 d
 d d g D]c } t | | d ƒ } | oD | d t i | ƒ | | ƒ f } | i d | | | ƒ f ƒ q[ q[ W| i d ƒ |  i o | i d |  i ƒ n | i d | | ƒ ƒ | i d |  i ƒ | i d |  i	 ƒ |  i
 o | i d |  i
 ƒ n |  i p |  i  i ƒ  } | i d | | ƒ ƒ d d  k } d d  k }	 d | i | i ƒ  ƒ |	 i f }
 | i d |
 ƒ t i | d ƒ S(   Ns
   [metadata]R   s   
c         S   s   t  i |  d d ƒ S(   Ns   
s   \n(   RL   t   replace(   t   s(    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyt   escapeÂ   s    t   authort   author_emailt   descriptiont
   maintainert   maintainer_emailt   namet   urlRI   s   
    %s: %ss   %s=%ss   
[Setup]s   install_script=%ss   info=%ss   target_compile=%ds   target_optimize=%ds   target_version=%ss   title=%siÿÿÿÿs   Built %s with distutils-%ss   build_info=%s(   R$   t   metadataRX   t   long_descriptiont   getattrRL   t
   capitalizeR   R   R   R   R   RT   t   timet	   distutilst   ctimet   __version__R#   (   R   t   linesRm   RO   Re   Rk   R6   R   Rq   Rr   t
   build_info(    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyt   get_inidata´   s:    	 %

c      	   C   s•  d d  k  } |  i |  i ƒ |  i ƒ  } |  i | ƒ } |  i d | ƒ | o% t | d ƒ i ƒ  } t | ƒ } n d } t | d ƒ }	 |	 i	 |  i
 ƒ  ƒ | o |	 i	 | ƒ n y t Wn t j
 o n% Xt | t ƒ o | i d ƒ } n | d } |  i o* t |  i d ƒ i ƒ  }
 | |
 d	 } n | d } |	 i	 | ƒ | i d
 d t | ƒ | ƒ } |	 i	 | ƒ |	 i	 t | d ƒ i ƒ  ƒ d  S(   Niÿÿÿÿs   creating %st   rbi    t   wbt   mbcst    t   rs   
 s   <iiii{V4(   t   structt   mkpathR   Rw   RY   t   announcet   opent   readt   lent   writet   get_exe_bytest   unicodet	   NameErrort
   isinstancet   encodeR   t   pack(   R   Ra   R`   R   R}   t   cfgdatat   installer_namet
   bitmapdatat	   bitmaplent   filet   script_datat   header(    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyRV   ã   s>    


			c         C   sS   |  i  o) t i i |  i d | |  i  f ƒ } n t i i |  i d | ƒ } | S(   Ns   %s.win32-py%s.exes   %s.win32.exe(   R   R!   R"   R#   R   (   R   R`   R‹   (    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyRY     s    
c         C   s»   d d k  l } t ƒ  } |  i oQ |  i | j oA |  i | j o | ƒ  } q} |  i d j  o
 d } q} d } n
 | ƒ  } t i i t ƒ } t i i | d | ƒ } t	 | d ƒ i
 ƒ  S(   Niÿÿÿÿ(   t   get_build_versions   2.4t   6s   7.1s   wininst-%s.exeRx   (   t   distutils.msvccompilerR‘   R   R   R!   R"   t   dirnamet   __file__R#   R€   R   (   R   R‘   t   cur_versiont   bvt	   directoryt   filename(    (    s5   /usr/lib/python2.5/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(   t   __name__t
   __module__Rh   R   t   user_optionst   boolean_optionsR   R,   RR   Rw   RV   RY   R„   (    (    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pyR      sD            						R	/7	(   t   __doc__t   __revision__R>   R!   RL   t   distutils.coreR    t   distutils.utilR   t   distutils.dir_utilR   R   t   distutils.errorst   distutils.sysconfigR   Rr   R   R   (    (    (    s5   /usr/lib/python2.5/distutils/command/bdist_wininst.pys   <module>   s   $
