
bc           @   s  d  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 Z d d
 l m Z m Z m Z d d l m Z m Z m Z m Z d e f d     YZ d e f d     YZ d S(   s#   
Implements the bdist_msi command.
iN(   t   get_python_version(   t   Command(   t   remove_tree(   t   StrictVersion(   t   DistutilsOptionError(   t   log(   t   get_platform(   t   schemat   sequencet   text(   t	   Directoryt   Featuret   Dialogt   add_datat   PyDialogc           B   sV   e  Z d  Z d   Z d   Z d d d  Z d d d  Z d d d	  Z d
   Z RS(   s   Dialog class with a fixed layout: controls at the top, then a ruler,
    then a list of buttons: back, next, cancel. Optionally a bitmap at the
    left.c         O   s=   t  j |  |  |  j d } |  j d d | |  j d  d S(   sb   Dialog(database, name, x, y, w, h, attributes, title, first,
        default, cancel, bitmap=true)i$   t
   BottomLinei    N(   R   t   __init__t   ht   linet   w(   t   selft   argst   kwt   ruler(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR      s    c      	   C   s'   |  j  d d d d d d d |  d S(	   s,   Set the title text of the dialog at the top.t   Titlei   i
   i@  i<   i  s   {\VerdanaBold10}%sN(   R	   (   R   t   title(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR   $   s    t   Backi   c      	   C   s>   | r d } n d } |  j  | d |  j d d d | | |  S(   s   Add a back button with a given title, the tab-next button,
        its name in the Control table, possibly initially disabled.

        Return the button, so that events can be associatedi   i   i   i   i8   i   (   t
   pushbuttonR   (   R   R   t   nextt   namet   activet   flags(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyt   back+   s    	t   Cancelc      	   C   s>   | r d } n d } |  j  | d |  j d d d | | |  S(   s   Add a cancel button with a given title, the tab-next button,
        its name in the Control table, possibly initially disabled.

        Return the button, so that events can be associatedi   i   i0  i   i8   i   (   R   R   (   R   R   R   R   R   R   (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyt   cancel6   s    	t   Nextc      	   C   s>   | r d } n d } |  j  | d |  j d d d | | |  S(   s   Add a Next button with a given title, the tab-next button,
        its name in the Control table, possibly initially disabled.

        Return the button, so that events can be associatedi   i   i   i   i8   i   (   R   R   (   R   R   R   R   R   R   (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR   A   s    	c      	   C   s:   |  j  | t |  j | d  |  j d d d d | |  S(   s   Add a button with a given title, the tab-next button,
        its name in the Control table, giving its x position; the
        y-position is aligned with the other buttons.

        Return the button, so that events can be associatedi   i   i8   i   i   (   R   t   intR   R   (   R   R   R   R   t   xpos(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyt   xbuttonL   s    (	   t   __name__t
   __module__t   __doc__R   R   R    R"   R   R&   (    (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR      s   			t	   bdist_msic           B   s=  e  Z d  Z d e d f d d d e   f d d d d	 f d
 e d d f d d d f d d d f d d d f d e d f d e d f d e d f g
 Z d d d d g Z d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ g Z d0 Z d1   Z	 d2   Z
 d3   Z d4   Z d5   Z d6   Z d7   Z d8   Z RS(9   s7   create a Microsoft Installer (.msi) binary distributions
   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
   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   2.0s   2.1s   2.2s   2.3s   2.4s   2.5s   2.6s   2.7s   2.8s   2.9s   3.0s   3.1s   3.2s   3.3s   3.4s   3.5s   3.6s   3.7s   3.8s   3.9t   Xc         C   sg   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
   skip_buildt   install_scriptt   pre_install_scriptt   versions(   R   (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyt   initialize_options~   s    										c         C   si  |  j  d d	  |  j d  k rL |  j d  j } t j j | d  |  _ n  t   } |  j	 rz |  j
 j   rz | |  _	 n  |  j	 r |  j	 g |  _ |  j r |  j
 j   r |  j	 | k r t d | f  q n t |  j  |  _ |  j  d d
 d  |  j r
t d  n  |  j r\xF |  j
 j D]% } |  j t j j |  k r Pq q Wt d |  j  n  d  |  _ d  S(   Nt   bdistR9   t   msisM   target version can only be %s, or the '--skip-build' option must be specifiedR8   R3   s5   the pre-install-script feature is not yet implementeds(   install_script '%s' not found in scripts(   R9   R9   (   R8   R8   (   R3   R3   (   t   set_undefined_optionsR2   R1   t   get_finalized_commandt
   bdist_baset   ost   patht   joinR    R7   t   distributiont   has_ext_modulesR<   R9   R   t   listt   all_versionsR;   R:   t   scriptst   basenamet   install_script_key(   R   RB   t   short_versiont   script(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyt   finalize_options   s8    					c         C   s  |  j  s |  j d  n  |  j d d d } |  j | _ |  j  | _  d | _ |  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  t j d |  j  | j   t j j d t j j |  j d   | j   t j d =|  j |  j  |  j j   } |  j |  } t j j |  } t j j |  rt j  |  n  |  j j! } | j" }	 |	 s| j# }	 n  |	 sd }	 n  | j$   }
 d t% |
  j } |  j j   } |  j
 r5d |  j
 | f } n
 d | } t& j' | t( | t& j)   | |	  |  _* t& j+ |  j* t,  d |
 f g } | j- p| j. } | r| j/ d | f  n  | j0 r| j/ d | j0 f  n  | rt1 |  j* d |  n  |  j2   |  j3   |  j4   |  j5   |  j* j6   t7 |  j d  rid |  j
 pJd | f } |  j j8 j/ |  n  |  j9 st: |  j d |  j; n  d  S(   Nt   buildt   installt   reinit_subcommandsi   i    t   install_libs    Should have already checked thisi   s   .%s-%st   libs   installing to %st   PURELIBt   UNKNOWNs   %d.%d.%ds   Python %s %ss	   Python %st   DistVersiont
   ARPCONTACTt   ARPURLINFOABOUTt   Propertyt
   dist_filesR*   t   anyt   dry_run(<   R9   t   run_commandt   reinitialize_commandR2   t   prefixt   warn_dirt   compilet   optimizeRF   RG   R7   t   AssertionErrort   syst   versionR3   RA   RC   RD   RE   t
   build_baset	   build_libR   t   infot   ensure_finalizedt   insertt   runt   mkpathR8   t   get_fullnamet   get_installer_filenamet   abspatht   existst   unlinkt   metadatat   authort
   maintainert   get_versionR   t   msilibt   init_databaseR   t   gen_uuidt   dbt
   add_tablesR   t   author_emailt   maintainer_emailt   appendt   urlR   t   add_find_pythont	   add_filest   add_scriptst   add_uit   Committ   hasattrR[   R4   R   R]   (   R   RQ   RS   R7   t   plat_specifierRP   t   fullnamet   installer_nameRs   Rt   Rf   t   sversiont   product_namet   propst   emailt   tup(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyRl      s~    					
%

 			
	



	c      
   C   s  |  j  } t j d  } t j j |  j  } t | | d  | d d  } t	 | d d d d d d d } | | d	 f g } x |  j
 |  j g D] } d | } d | }	 }
 d } | |  j k r d
 } d } n d | } d } t	 | |	 | | d | d | } t | | | | | |
  } | j | | | f  q W| j   i  } x| D]\ } } } | g } xg| r| j   } xNt j | j  D]:} t j j | j |  } t j j |  rd | j |  | f } | | }
 t | | | | |
 |  } | j |  q| j s.| j | j | d  n  | | k r| j |  } | | <| |  j k r|  j r|t d |   n  d | |  _ qq| | } t |  j  d | | | j | d  | j f g  qWqiW| j   qNW| j |  d  S(   Nt	   distfilest	   TARGETDIRt	   SourceDirt   Pythont
   Everythingi    i   t	   directoryt    s   Python from another locationi   s   Python %s from registrys   %s|%ss   Multiple files with name %ss   [#%s]t   DuplicateFile(   Rz   Rw   t   CABRC   RD   Rp   R2   R
   R1   R   R<   t   other_versionR~   R   t   popt   listdirt   absoluteRE   t   isdirt
   make_shortt	   componentt   start_componentt   logicalt   add_fileR:   RL   R   R   t   commit(   R   Rz   t   cabt   rootdirt   roott   ft   itemsRf   t   targetR   t   defaultt   descR   t   levelt   dirt   seent   featuret   todot   filet   afilet   shortt   newdirt   key(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR     s\    	
	
!
		
		
+c         C   s  d } x|  j  D]} d | } d | } d | } d | } d | } d | } d | }	 d	 | }
 d
 | } d | } t j r d  } n d } t |  j d | d | d | f | d | d | f g  t |  j d | | f | | f g  t |  j d | d! | d | d f |	 d" | d | d f |
 d# | d | d f g  t |  j d | | | f |	 | | d f |
 d | d f g  t |  j d | | | f |	 | | d f |
 d | d f g  t |  j d d | d d | f g  | d 7} | d k  s t  q Wd S($   ss  Adds code to the installer to compute the location of Python.

        Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the
        registry for each version of Python.

        Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined,
        else from PYTHON.MACHINE.X.Y.

        Properties PYTHONX.Y will be set to TARGETDIRX.Y\python.exei  s)   SOFTWARE\Python\PythonCore\%s\InstallPaths   python.machine.s   python.user.s   PYTHON.MACHINE.s   PYTHON.USER.t   PythonFromMachinet   PythonFromUsert	   PythonExeR   t   PYTHONi   i   t
   RegLocatori   t	   AppSearcht   CustomActioni3   i   t   [t   ]s   ]\python.exet   InstallExecuteSequencet   InstallUISequencet	   ConditionR   i    s   NOT TARGETDIRi   i  Ni   i3  i3  i3  (   R<   Rw   t   Win64R   Rz   R1   Rd   (   R   t   startt   vert   install_patht   machine_regt   user_regt   machine_propt	   user_propt   machine_actiont   user_actiont
   exe_actiont   target_dir_propt   exe_propt   Type(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR   E  sJ    









			
c         C   sQ  |  j  r d } x |  j |  j g D]l } d | } d | } t |  j d | d | |  j f g  t |  j d | d | | f g  | d 7} q# Wn  |  j rMt j j	 |  j
 d	  } t | d
  } | j d  | j t |  j  j    | j   t |  j d d t j |  f g  t |  j d d g  t |  j d d g  n  d  S(   Ni  s   install_script.R   R   i2   R   s   &Python%s=3i   s   preinstall.batR   s   rem ="""
%1 %0
exit
"""
t   Binaryt
   PreInstalli   s   NOT Installedi  (   R   i   R   N(   R   s   NOT Installedi  (   R:   R<   R   R   Rz   RL   R;   RC   RD   RE   R2   t   opent   writet   readt   closeRw   R   R1   (   R   R   R   t   install_actionR   t   scriptfnR   (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR   {  s,    	

		

c         C   sA  |  j  } d } } d } d } d } d } d } t | d d d d d d d g  t | d d d d d g  t | d d d d d d g  t | d. t j  t | d/ t j  t | d0 | | | | | | d1 d1 d1  }	 |	 j d2  |	 j d3 d1 d4 d |	 j	 d5 d6 d4 d |	 j d7 d8 d9 d: d; d< d=  |	 j d> d8 d? d: d@ d< dA  |	 j
 d1 d5 dB d1 }
 |
 j dC dD  t | dE | | | | | | d1 d1 d1  } | j dF  | j d3 d1 d4 d | j	 d5 d6 d4 d | j d7 d8 d9 d: d; d< dG  | j d> d8 d? d: d@ d< dA  | j
 d1 d5 dB d1 }
 |
 j dC dD  t | dH | | | | | | d1 d1 d1  } | j dI  | j d3 d1 d4 d | j	 d5 d6 d4 d | j dJ d8 dK d: d@ d< dA  | j
 d1 d5 dB d1 }
 |
 j dC dL  t | dM | | | | dN | dO dO dO dP t } | j dQ d8 dR dS d8 d< dT  | j dJ d@ dU dV d@ d< dW  | j dX d@ dY dZ d d d[  | j d\ d] d@ d^ dZ d_ d` da d  d  d   | j dD db dB dD }
 |
 j dC dD  | j
 db dO dB db }
 |
 j dC db  | j	 dO dD dB dO }
 |
 j dC dO  t | d d d dZ dc dd | de d  d   } | j de d d dV df d dg  | j dh di dj dk dl d dm d   j dC dn  | j do dp dj dk dl d dq d   j dC dr  | j ds d dj dk dl d dt d   j dC du  | j dv dw dj dk dl d d5 d   j dC dx  | j dy dk dj dk dl d db d   j dC dz  | j d{ d| dj dk dl d d} d   j dC d~  | j d d dj dk dl d dO d   j dC d  t | d d d d d d | dm dm dm  } | j dX df d8 d d d d  | j dq dj d d d d dq dm  }
 |
 j dC dD  | j dm d d d d d dm dq  }
 |
 j dC dL  t | d d d d d | | dL dL dL  } | j dX df d8 d d d d  | j dL d d d d d dL d   }
 |
 j dC dD  t | d  | | | | | | d5 d5 d5  } | j dJ d8 d9 d: d d< d  | j d  | j d. d8 d d: d@ d< d  }
 |
 j d. dX  | j d d8 d d: d d< d   }
 |
 j d dX  | j d6 d  d4 d | j
 d d  d4 d | j	 d5 d   }
 |
 j d d  t | d& | | | | | | d d d5  } | j d  | j d d8 d d d@ d d |  j j    | j d3 d  d4 d | j
 d d5  }
 d } |
 j d d d | xF |  j |  j g D]1 } | d 7} |
 j d d | d | d | qW|
 j d d d | d |
 j dC dL d | d | j	 d5 d  }
 |
 j d d  | j d d d8 d d di d d d  d d   }
 |
 j d d  |  j } d | } d | } | j d d8 dS d d8 d d  }
 |
 j d |  |
 j d |  |
 j d |  |
 j d |  | j d d d8 d d d d d | d  d d   }
 |
 j d |  |
 j d |  |
 j d |  |
 j d |  t | d | | | | | | d d d dP t } | j dQ d8 dR dS d8 d< d  | j dJ d@ d@ dV d@ d< d  | j dX d@ d dZ d d d  | j d d d@ d dZ d d d  d d  d   | j d d} d  d  j dC dL  t | d# | | | | | | d d d5  } | j d  | j d d8 d d d d d dg d 	 } | j d d d d d@ d  | j d d d d d@ d  | j d6 d  d4 d | j
 d d5  }
 |
 j d d d d  |
 j dC dL d d | j	 d5 d  }
 |
 j d d  t | d, | | | | | | d5 d5 d5 dP t } | j dQ d@ d8 dS d8 d< d  | j dX d d d d d d  | j d d d d d@ d d  | j d. d9 d | d9 d@ d d  }
 |
 j d. dX  | j d d d di d d d d  d d  d   }
 |
 j d d  | j d3 d d4 t | j
 d d5 d4 t | j	 d5 d6  j d d  t | d) | | | | | | d d d5  } | j d  | j d d8 d dZ dw d d  | j d d8 d dZ d d d dg d 	 } | j d d d dS d d  | j d d d dS d d  | j d3 d  d4 t | j
 d1 d5  }
 |
 j d d d d  |
 j d d d dR  |
 j d d d d`  |
 j d d d d  |
 j d d d d  |
 j d d d d  |
 j d d d d  |
 j d d d d  |
 j dC dL d d@  | j	 d5 d  j d d  d  S(   Ni2   ir  i,  s   [ProductName] Setupi   i   RZ   t   DefaultUIFontt   DlgFont8t   ErrorDialogt   ErrorDlgt	   Progress1t   Installt	   Progress2t   installst   MaintenanceForm_Actiont   Repairt
   WhichUserst   ALLt	   TextStylet   Tahomai	   i    t   DlgFontBold8i   t   VerdanaBold10t   Verdanai
   t   VerdanaRed9i   R   t
   PrepareDlgs(   Not Privileged or Windows9x or Installedi   t   WhichUsersDlgs.   Privileged and not Windows9x and not Installedi   t   SelectFeaturesDlgs   Not Installedi  t   MaintenanceTypeDlgs,   Installed AND NOT RESUME AND NOT Preselectedi  t   ProgressDlgi   t
   ActionTextt   UITextt
   FatalErrort   Finishs)   [ProductName] Installer ended prematurelys   < BackR   R!   R   t   Description1i   iF   i@  iP   i  s   [ProductName] setup ended prematurely because of an error.  Your system has not been modified.  To install this program at a later time, please run the installation again.t   Description2i   i   s.   Click the Finish button to exit the Installer.R   t	   EndDialogt   Exitt   UserExits'   [ProductName] Installer was interrupteds   [ProductName] setup was interrupted.  Your system has not been modified.  To install this program at a later time, please run the installation again.t
   ExitDialogs&   Completing the [ProductName] Installert   Descriptioni   t   Returnt
   FilesInUsei   t   Retryt   bitmapR   i   i   s   {\DlgFontBold8}Files in Usei   i  s8   Some files that need to be updated are currently in use.t   Texti7   iJ  s   The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.t   Listt   ListBoxik   i   i   t   FileInUseProcesst   Ignoreie   i  t	   ErrorTexti0   R   t   Nix   iH   iQ   i   t   Not   ErrorNot   Yi   t   Yest   ErrorYest   At   Abortt
   ErrorAbortt   Ci*   t   ErrorCancelt   It   ErrorIgnoret   Oi   t   Okt   ErrorOkt   Ri   t
   ErrorRetryt	   CancelDlgi  iU   i   i   s;   Are you sure you want to cancel [ProductName] installation?i9   i8   i   i   t   WaitForCostingDlgsR   Please wait while the installer finishes determining your disk space requirements.if   i(   sO   Please wait while the Installer prepares to guide you through the installation.s&   Welcome to the [ProductName] Installerin   s   Pondering...t
   ActionDatai   R#   t   SpawnDialogs   Select Python Installationst   Hints9   Select the Python locations where %s should be installed.s   Next >s   [TARGETDIR]s   [SourceDir]t   orderings   [TARGETDIR%s]s    FEATURE_SELECTED AND &Python%s=3t   SpawnWaitDialogi   t   Featurest   SelectionTreei<   t   FEATUREt   PathEdits   [FEATURE_SELECTED]t   1s!   FEATURE_SELECTED AND &Python%s<>3t   Others$   Provide an alternate Python locationt   Enablet   Showt   Disablet   Hidei   i   R   t   DiskCostDlgt   OKs&   {\DlgFontBold8}Disk Space RequirementssF   The disk space required for the installation of the selected features.i5   s  The highlighted volumes (if any) do not have enough disk space available for the currently selected features.  You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s).t
   VolumeListt   VolumeCostListid   i   i  s   {120}{70}{70}{70}{70}g      ?t   AdminInstallsG   Select whether to install [ProductName] for all users of this computer.i   s   Install for all userst   JUSTMEi   s   Install just for mes
   [ALLUSERS]s   WhichUsers="ALL"s(   {\DlgFontBold8}[Progress1] [ProductName]i#   iA   sY   Please wait while the Installer [Progress2] [ProductName]. This may take several minutes.t   StatusLabels   Status:t   ProgressBari  s   Progress donet   SetProgresst   Progresss)   Welcome to the [ProductName] Setup Wizardt   BodyTexti?   s:   Select whether you want to repair or remove [ProductName].t   RepairRadioGroupil   i   s   &Repair [ProductName]t   Removei$   s   Re&move [ProductName]s   [REINSTALL]s   MaintenanceForm_Action="Repair"s   [Progress1]t	   Repairings   [Progress2]t   repairst	   Reinstalls   [REMOVE]s   MaintenanceForm_Action="Remove"i   t   Removingi   t   removesi   i   s    MaintenanceForm_Action<>"Change"(   R   R   (   R   R   (   R   R   (   R   R   (   R   R   (   R   R   (   R   R   i	   Ni    (   R   R   i   Ni   (   R   R   i
   Ni   (   R   R   i	   i   i    (   R   s(   Not Privileged or Windows9x or Installedi   (   R   s.   Privileged and not Windows9x and not Installedi   (   R   s   Not Installedi  (   R   s,   Installed AND NOT RESUME AND NOT Preselectedi  (   R   Ni   (   Rz   R   R1   R	   R   R   R   R   R    R"   R   t   eventt   Falset   controlR   R   t   mappingRF   Rn   R<   R   t	   conditionR&   t
   radiogroupt   add(   R   Rz   t   xt   yR   R   R   t   modalt   modelesst   fatalR-   t	   user_exitt   exit_dialogt   inuset   errorR"   t   costingt   prept   seldlgt   orderRf   R   t   install_other_condt   dont_install_other_condt   costt
   whichuserst   gt   progresst   maint(    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR     s   	
	
	
	
		.......$$$!!

	

	"%c         C   sT   |  j  r% d | |  j |  j  f } n d | |  j f } t j j |  j |  } | S(   Ns   %s.%s-py%s.msis	   %s.%s.msi(   R7   R3   RC   RD   RE   R8   (   R   R   t	   base_nameR   (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyRo     s    	(   R'   R(   t   descriptionR1   R   t   user_optionst   boolean_optionsRI   R   R=   RO   Rl   R   R   R   R   Ro   (    (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyR*   T   sP   
				)	[	6	6	&	 >(   R)   Re   RC   t	   sysconfigR    t   distutils.coreR   t   distutils.dir_utilR   t   distutils.versionR   t   distutils.errorsR   t	   distutilsR   t   distutils.utilR   Rw   R   R   R	   R
   R   R   R   R   R*   (    (    (    s1   /usr/lib/python2.7/distutils/command/bdist_msi.pyt   <module>   s   "=