/Lib/distutils/command/bdist_msi.py

http://unladen-swallow.googlecode.com/ · Python · 651 lines · 458 code · 71 blank · 122 comment · 39 complexity · dcdc146876db8221670e375c0527b65d MD5 · raw file

  1. # -*- coding: iso-8859-1 -*-
  2. # Copyright (C) 2005, 2006 Martin v. Löwis
  3. # Licensed to PSF under a Contributor Agreement.
  4. # The bdist_wininst command proper
  5. # based on bdist_wininst
  6. """
  7. Implements the bdist_msi command.
  8. """
  9. import sys, os
  10. from distutils.core import Command
  11. from distutils.dir_util import remove_tree
  12. from distutils.sysconfig import get_python_version
  13. from distutils.version import StrictVersion
  14. from distutils.errors import DistutilsOptionError
  15. from distutils.util import get_platform
  16. from distutils import log
  17. import msilib
  18. from msilib import schema, sequence, text
  19. from msilib import Directory, Feature, Dialog, add_data
  20. class PyDialog(Dialog):
  21. """Dialog class with a fixed layout: controls at the top, then a ruler,
  22. then a list of buttons: back, next, cancel. Optionally a bitmap at the
  23. left."""
  24. def __init__(self, *args, **kw):
  25. """Dialog(database, name, x, y, w, h, attributes, title, first,
  26. default, cancel, bitmap=true)"""
  27. Dialog.__init__(self, *args)
  28. ruler = self.h - 36
  29. bmwidth = 152*ruler/328
  30. #if kw.get("bitmap", True):
  31. # self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
  32. self.line("BottomLine", 0, ruler, self.w, 0)
  33. def title(self, title):
  34. "Set the title text of the dialog at the top."
  35. # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
  36. # text, in VerdanaBold10
  37. self.text("Title", 15, 10, 320, 60, 0x30003,
  38. r"{\VerdanaBold10}%s" % title)
  39. def back(self, title, next, name = "Back", active = 1):
  40. """Add a back button with a given title, the tab-next button,
  41. its name in the Control table, possibly initially disabled.
  42. Return the button, so that events can be associated"""
  43. if active:
  44. flags = 3 # Visible|Enabled
  45. else:
  46. flags = 1 # Visible
  47. return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
  48. def cancel(self, title, next, name = "Cancel", active = 1):
  49. """Add a cancel button with a given title, the tab-next button,
  50. its name in the Control table, possibly initially disabled.
  51. Return the button, so that events can be associated"""
  52. if active:
  53. flags = 3 # Visible|Enabled
  54. else:
  55. flags = 1 # Visible
  56. return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
  57. def next(self, title, next, name = "Next", active = 1):
  58. """Add a Next button with a given title, the tab-next button,
  59. its name in the Control table, possibly initially disabled.
  60. Return the button, so that events can be associated"""
  61. if active:
  62. flags = 3 # Visible|Enabled
  63. else:
  64. flags = 1 # Visible
  65. return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
  66. def xbutton(self, name, title, next, xpos):
  67. """Add a button with a given title, the tab-next button,
  68. its name in the Control table, giving its x position; the
  69. y-position is aligned with the other buttons.
  70. Return the button, so that events can be associated"""
  71. return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
  72. class bdist_msi (Command):
  73. description = "create a Microsoft Installer (.msi) binary distribution"
  74. user_options = [('bdist-dir=', None,
  75. "temporary directory for creating the distribution"),
  76. ('plat-name=', 'p',
  77. "platform name to embed in generated filenames "
  78. "(default: %s)" % get_platform()),
  79. ('keep-temp', 'k',
  80. "keep the pseudo-installation tree around after " +
  81. "creating the distribution archive"),
  82. ('target-version=', None,
  83. "require a specific python version" +
  84. " on the target system"),
  85. ('no-target-compile', 'c',
  86. "do not compile .py to .pyc on the target system"),
  87. ('no-target-optimize', 'o',
  88. "do not compile .py to .pyo (optimized)"
  89. "on the target system"),
  90. ('dist-dir=', 'd',
  91. "directory to put final built distributions in"),
  92. ('skip-build', None,
  93. "skip rebuilding everything (for testing/debugging)"),
  94. ('install-script=', None,
  95. "basename of installation script to be run after"
  96. "installation or before deinstallation"),
  97. ('pre-install-script=', None,
  98. "Fully qualified filename of a script to be run before "
  99. "any files are installed. This script need not be in the "
  100. "distribution"),
  101. ]
  102. boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',
  103. 'skip-build']
  104. def initialize_options (self):
  105. self.bdist_dir = None
  106. self.plat_name = None
  107. self.keep_temp = 0
  108. self.no_target_compile = 0
  109. self.no_target_optimize = 0
  110. self.target_version = None
  111. self.dist_dir = None
  112. self.skip_build = 0
  113. self.install_script = None
  114. self.pre_install_script = None
  115. def finalize_options (self):
  116. if self.bdist_dir is None:
  117. bdist_base = self.get_finalized_command('bdist').bdist_base
  118. self.bdist_dir = os.path.join(bdist_base, 'msi')
  119. short_version = get_python_version()
  120. if self.target_version:
  121. if not self.skip_build and self.distribution.has_ext_modules()\
  122. and self.target_version != short_version:
  123. raise DistutilsOptionError, \
  124. "target version can only be %s, or the '--skip_build'" \
  125. " option must be specified" % (short_version,)
  126. else:
  127. self.target_version = short_version
  128. self.set_undefined_options('bdist',
  129. ('dist_dir', 'dist_dir'),
  130. ('plat_name', 'plat_name'),
  131. )
  132. if self.pre_install_script:
  133. raise DistutilsOptionError, "the pre-install-script feature is not yet implemented"
  134. if self.install_script:
  135. for script in self.distribution.scripts:
  136. if self.install_script == os.path.basename(script):
  137. break
  138. else:
  139. raise DistutilsOptionError, \
  140. "install_script '%s' not found in scripts" % \
  141. self.install_script
  142. self.install_script_key = None
  143. # finalize_options()
  144. def run (self):
  145. if not self.skip_build:
  146. self.run_command('build')
  147. install = self.reinitialize_command('install', reinit_subcommands=1)
  148. install.prefix = self.bdist_dir
  149. install.skip_build = self.skip_build
  150. install.warn_dir = 0
  151. install_lib = self.reinitialize_command('install_lib')
  152. # we do not want to include pyc or pyo files
  153. install_lib.compile = 0
  154. install_lib.optimize = 0
  155. if self.distribution.has_ext_modules():
  156. # If we are building an installer for a Python version other
  157. # than the one we are currently running, then we need to ensure
  158. # our build_lib reflects the other Python version rather than ours.
  159. # Note that for target_version!=sys.version, we must have skipped the
  160. # build step, so there is no issue with enforcing the build of this
  161. # version.
  162. target_version = self.target_version
  163. if not target_version:
  164. assert self.skip_build, "Should have already checked this"
  165. target_version = sys.version[0:3]
  166. plat_specifier = ".%s-%s" % (self.plat_name, target_version)
  167. build = self.get_finalized_command('build')
  168. build.build_lib = os.path.join(build.build_base,
  169. 'lib' + plat_specifier)
  170. log.info("installing to %s", self.bdist_dir)
  171. install.ensure_finalized()
  172. # avoid warning of 'install_lib' about installing
  173. # into a directory not in sys.path
  174. sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))
  175. install.run()
  176. del sys.path[0]
  177. self.mkpath(self.dist_dir)
  178. fullname = self.distribution.get_fullname()
  179. installer_name = self.get_installer_filename(fullname)
  180. installer_name = os.path.abspath(installer_name)
  181. if os.path.exists(installer_name): os.unlink(installer_name)
  182. metadata = self.distribution.metadata
  183. author = metadata.author
  184. if not author:
  185. author = metadata.maintainer
  186. if not author:
  187. author = "UNKNOWN"
  188. version = metadata.get_version()
  189. # ProductVersion must be strictly numeric
  190. # XXX need to deal with prerelease versions
  191. sversion = "%d.%d.%d" % StrictVersion(version).version
  192. # Prefix ProductName with Python x.y, so that
  193. # it sorts together with the other Python packages
  194. # in Add-Remove-Programs (APR)
  195. product_name = "Python %s %s" % (self.target_version,
  196. self.distribution.get_fullname())
  197. self.db = msilib.init_database(installer_name, schema,
  198. product_name, msilib.gen_uuid(),
  199. sversion, author)
  200. msilib.add_tables(self.db, sequence)
  201. props = [('DistVersion', version)]
  202. email = metadata.author_email or metadata.maintainer_email
  203. if email:
  204. props.append(("ARPCONTACT", email))
  205. if metadata.url:
  206. props.append(("ARPURLINFOABOUT", metadata.url))
  207. if props:
  208. add_data(self.db, 'Property', props)
  209. self.add_find_python()
  210. self.add_files()
  211. self.add_scripts()
  212. self.add_ui()
  213. self.db.Commit()
  214. if hasattr(self.distribution, 'dist_files'):
  215. self.distribution.dist_files.append(('bdist_msi', self.target_version, fullname))
  216. if not self.keep_temp:
  217. remove_tree(self.bdist_dir, dry_run=self.dry_run)
  218. def add_files(self):
  219. db = self.db
  220. cab = msilib.CAB("distfiles")
  221. f = Feature(db, "default", "Default Feature", "Everything", 1, directory="TARGETDIR")
  222. f.set_current()
  223. rootdir = os.path.abspath(self.bdist_dir)
  224. root = Directory(db, cab, None, rootdir, "TARGETDIR", "SourceDir")
  225. db.Commit()
  226. todo = [root]
  227. while todo:
  228. dir = todo.pop()
  229. for file in os.listdir(dir.absolute):
  230. afile = os.path.join(dir.absolute, file)
  231. if os.path.isdir(afile):
  232. newdir = Directory(db, cab, dir, file, file, "%s|%s" % (dir.make_short(file), file))
  233. todo.append(newdir)
  234. else:
  235. key = dir.add_file(file)
  236. if file==self.install_script:
  237. if self.install_script_key:
  238. raise DistutilsOptionError, "Multiple files with name %s" % file
  239. self.install_script_key = '[#%s]' % key
  240. cab.commit(db)
  241. def add_find_python(self):
  242. """Adds code to the installer to compute the location of Python.
  243. Properties PYTHON.MACHINE, PYTHON.USER, PYTHONDIR and PYTHON will be set
  244. in both the execute and UI sequences; PYTHONDIR will be set from
  245. PYTHON.USER if defined, else from PYTHON.MACHINE.
  246. PYTHON is PYTHONDIR\python.exe"""
  247. install_path = r"SOFTWARE\Python\PythonCore\%s\InstallPath" % self.target_version
  248. if msilib.Win64:
  249. # type: msidbLocatorTypeRawValue + msidbLocatorType64bit
  250. Type = 2+16
  251. else:
  252. Type = 2
  253. add_data(self.db, "RegLocator",
  254. [("python.machine", 2, install_path, None, Type),
  255. ("python.user", 1, install_path, None, Type)])
  256. add_data(self.db, "AppSearch",
  257. [("PYTHON.MACHINE", "python.machine"),
  258. ("PYTHON.USER", "python.user")])
  259. add_data(self.db, "CustomAction",
  260. [("PythonFromMachine", 51+256, "PYTHONDIR", "[PYTHON.MACHINE]"),
  261. ("PythonFromUser", 51+256, "PYTHONDIR", "[PYTHON.USER]"),
  262. ("PythonExe", 51+256, "PYTHON", "[PYTHONDIR]\\python.exe"),
  263. ("InitialTargetDir", 51+256, "TARGETDIR", "[PYTHONDIR]")])
  264. add_data(self.db, "InstallExecuteSequence",
  265. [("PythonFromMachine", "PYTHON.MACHINE", 401),
  266. ("PythonFromUser", "PYTHON.USER", 402),
  267. ("PythonExe", None, 403),
  268. ("InitialTargetDir", 'TARGETDIR=""', 404),
  269. ])
  270. add_data(self.db, "InstallUISequence",
  271. [("PythonFromMachine", "PYTHON.MACHINE", 401),
  272. ("PythonFromUser", "PYTHON.USER", 402),
  273. ("PythonExe", None, 403),
  274. ("InitialTargetDir", 'TARGETDIR=""', 404),
  275. ])
  276. def add_scripts(self):
  277. if self.install_script:
  278. add_data(self.db, "CustomAction",
  279. [("install_script", 50, "PYTHON", self.install_script_key)])
  280. add_data(self.db, "InstallExecuteSequence",
  281. [("install_script", "NOT Installed", 6800)])
  282. if self.pre_install_script:
  283. scriptfn = os.path.join(self.bdist_dir, "preinstall.bat")
  284. f = open(scriptfn, "w")
  285. # The batch file will be executed with [PYTHON], so that %1
  286. # is the path to the Python interpreter; %0 will be the path
  287. # of the batch file.
  288. # rem ="""
  289. # %1 %0
  290. # exit
  291. # """
  292. # <actual script>
  293. f.write('rem ="""\n%1 %0\nexit\n"""\n')
  294. f.write(open(self.pre_install_script).read())
  295. f.close()
  296. add_data(self.db, "Binary",
  297. [("PreInstall", msilib.Binary(scriptfn))
  298. ])
  299. add_data(self.db, "CustomAction",
  300. [("PreInstall", 2, "PreInstall", None)
  301. ])
  302. add_data(self.db, "InstallExecuteSequence",
  303. [("PreInstall", "NOT Installed", 450)])
  304. def add_ui(self):
  305. db = self.db
  306. x = y = 50
  307. w = 370
  308. h = 300
  309. title = "[ProductName] Setup"
  310. # see "Dialog Style Bits"
  311. modal = 3 # visible | modal
  312. modeless = 1 # visible
  313. track_disk_space = 32
  314. # UI customization properties
  315. add_data(db, "Property",
  316. # See "DefaultUIFont Property"
  317. [("DefaultUIFont", "DlgFont8"),
  318. # See "ErrorDialog Style Bit"
  319. ("ErrorDialog", "ErrorDlg"),
  320. ("Progress1", "Install"), # modified in maintenance type dlg
  321. ("Progress2", "installs"),
  322. ("MaintenanceForm_Action", "Repair"),
  323. # possible values: ALL, JUSTME
  324. ("WhichUsers", "ALL")
  325. ])
  326. # Fonts, see "TextStyle Table"
  327. add_data(db, "TextStyle",
  328. [("DlgFont8", "Tahoma", 9, None, 0),
  329. ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
  330. ("VerdanaBold10", "Verdana", 10, None, 1),
  331. ("VerdanaRed9", "Verdana", 9, 255, 0),
  332. ])
  333. # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
  334. # Numbers indicate sequence; see sequence.py for how these action integrate
  335. add_data(db, "InstallUISequence",
  336. [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
  337. ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
  338. # In the user interface, assume all-users installation if privileged.
  339. ("SelectDirectoryDlg", "Not Installed", 1230),
  340. # XXX no support for resume installations yet
  341. #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
  342. ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
  343. ("ProgressDlg", None, 1280)])
  344. add_data(db, 'ActionText', text.ActionText)
  345. add_data(db, 'UIText', text.UIText)
  346. #####################################################################
  347. # Standard dialogs: FatalError, UserExit, ExitDialog
  348. fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
  349. "Finish", "Finish", "Finish")
  350. fatal.title("[ProductName] Installer ended prematurely")
  351. fatal.back("< Back", "Finish", active = 0)
  352. fatal.cancel("Cancel", "Back", active = 0)
  353. fatal.text("Description1", 15, 70, 320, 80, 0x30003,
  354. "[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.")
  355. fatal.text("Description2", 15, 155, 320, 20, 0x30003,
  356. "Click the Finish button to exit the Installer.")
  357. c=fatal.next("Finish", "Cancel", name="Finish")
  358. c.event("EndDialog", "Exit")
  359. user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
  360. "Finish", "Finish", "Finish")
  361. user_exit.title("[ProductName] Installer was interrupted")
  362. user_exit.back("< Back", "Finish", active = 0)
  363. user_exit.cancel("Cancel", "Back", active = 0)
  364. user_exit.text("Description1", 15, 70, 320, 80, 0x30003,
  365. "[ProductName] setup was interrupted. Your system has not been modified. "
  366. "To install this program at a later time, please run the installation again.")
  367. user_exit.text("Description2", 15, 155, 320, 20, 0x30003,
  368. "Click the Finish button to exit the Installer.")
  369. c = user_exit.next("Finish", "Cancel", name="Finish")
  370. c.event("EndDialog", "Exit")
  371. exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
  372. "Finish", "Finish", "Finish")
  373. exit_dialog.title("Completing the [ProductName] Installer")
  374. exit_dialog.back("< Back", "Finish", active = 0)
  375. exit_dialog.cancel("Cancel", "Back", active = 0)
  376. exit_dialog.text("Description", 15, 235, 320, 20, 0x30003,
  377. "Click the Finish button to exit the Installer.")
  378. c = exit_dialog.next("Finish", "Cancel", name="Finish")
  379. c.event("EndDialog", "Return")
  380. #####################################################################
  381. # Required dialog: FilesInUse, ErrorDlg
  382. inuse = PyDialog(db, "FilesInUse",
  383. x, y, w, h,
  384. 19, # KeepModeless|Modal|Visible
  385. title,
  386. "Retry", "Retry", "Retry", bitmap=False)
  387. inuse.text("Title", 15, 6, 200, 15, 0x30003,
  388. r"{\DlgFontBold8}Files in Use")
  389. inuse.text("Description", 20, 23, 280, 20, 0x30003,
  390. "Some files that need to be updated are currently in use.")
  391. inuse.text("Text", 20, 55, 330, 50, 3,
  392. "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.")
  393. inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
  394. None, None, None)
  395. c=inuse.back("Exit", "Ignore", name="Exit")
  396. c.event("EndDialog", "Exit")
  397. c=inuse.next("Ignore", "Retry", name="Ignore")
  398. c.event("EndDialog", "Ignore")
  399. c=inuse.cancel("Retry", "Exit", name="Retry")
  400. c.event("EndDialog","Retry")
  401. # See "Error Dialog". See "ICE20" for the required names of the controls.
  402. error = Dialog(db, "ErrorDlg",
  403. 50, 10, 330, 101,
  404. 65543, # Error|Minimize|Modal|Visible
  405. title,
  406. "ErrorText", None, None)
  407. error.text("ErrorText", 50,9,280,48,3, "")
  408. #error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
  409. error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
  410. error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
  411. error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
  412. error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
  413. error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
  414. error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
  415. error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
  416. #####################################################################
  417. # Global "Query Cancel" dialog
  418. cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
  419. "No", "No", "No")
  420. cancel.text("Text", 48, 15, 194, 30, 3,
  421. "Are you sure you want to cancel [ProductName] installation?")
  422. #cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
  423. # "py.ico", None, None)
  424. c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
  425. c.event("EndDialog", "Exit")
  426. c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
  427. c.event("EndDialog", "Return")
  428. #####################################################################
  429. # Global "Wait for costing" dialog
  430. costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
  431. "Return", "Return", "Return")
  432. costing.text("Text", 48, 15, 194, 30, 3,
  433. "Please wait while the installer finishes determining your disk space requirements.")
  434. c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
  435. c.event("EndDialog", "Exit")
  436. #####################################################################
  437. # Preparation dialog: no user input except cancellation
  438. prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
  439. "Cancel", "Cancel", "Cancel")
  440. prep.text("Description", 15, 70, 320, 40, 0x30003,
  441. "Please wait while the Installer prepares to guide you through the installation.")
  442. prep.title("Welcome to the [ProductName] Installer")
  443. c=prep.text("ActionText", 15, 110, 320, 20, 0x30003, "Pondering...")
  444. c.mapping("ActionText", "Text")
  445. c=prep.text("ActionData", 15, 135, 320, 30, 0x30003, None)
  446. c.mapping("ActionData", "Text")
  447. prep.back("Back", None, active=0)
  448. prep.next("Next", None, active=0)
  449. c=prep.cancel("Cancel", None)
  450. c.event("SpawnDialog", "CancelDlg")
  451. #####################################################################
  452. # Target directory selection
  453. seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
  454. "Next", "Next", "Cancel")
  455. seldlg.title("Select Destination Directory")
  456. version = sys.version[:3]+" "
  457. seldlg.text("Hint", 15, 30, 300, 40, 3,
  458. "The destination directory should contain a Python %sinstallation" % version)
  459. seldlg.back("< Back", None, active=0)
  460. c = seldlg.next("Next >", "Cancel")
  461. c.event("SetTargetPath", "TARGETDIR", ordering=1)
  462. c.event("SpawnWaitDialog", "WaitForCostingDlg", ordering=2)
  463. c.event("EndDialog", "Return", ordering=3)
  464. c = seldlg.cancel("Cancel", "DirectoryCombo")
  465. c.event("SpawnDialog", "CancelDlg")
  466. seldlg.control("DirectoryCombo", "DirectoryCombo", 15, 70, 272, 80, 393219,
  467. "TARGETDIR", None, "DirectoryList", None)
  468. seldlg.control("DirectoryList", "DirectoryList", 15, 90, 308, 136, 3, "TARGETDIR",
  469. None, "PathEdit", None)
  470. seldlg.control("PathEdit", "PathEdit", 15, 230, 306, 16, 3, "TARGETDIR", None, "Next", None)
  471. c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
  472. c.event("DirectoryListUp", "0")
  473. c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
  474. c.event("DirectoryListNew", "0")
  475. #####################################################################
  476. # Disk cost
  477. cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
  478. "OK", "OK", "OK", bitmap=False)
  479. cost.text("Title", 15, 6, 200, 15, 0x30003,
  480. "{\DlgFontBold8}Disk Space Requirements")
  481. cost.text("Description", 20, 20, 280, 20, 0x30003,
  482. "The disk space required for the installation of the selected features.")
  483. cost.text("Text", 20, 53, 330, 60, 3,
  484. "The highlighted volumes (if any) do not have enough disk space "
  485. "available for the currently selected features. You can either "
  486. "remove some files from the highlighted volumes, or choose to "
  487. "install less features onto local drive(s), or select different "
  488. "destination drive(s).")
  489. cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
  490. None, "{120}{70}{70}{70}{70}", None, None)
  491. cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
  492. #####################################################################
  493. # WhichUsers Dialog. Only available on NT, and for privileged users.
  494. # This must be run before FindRelatedProducts, because that will
  495. # take into account whether the previous installation was per-user
  496. # or per-machine. We currently don't support going back to this
  497. # dialog after "Next" was selected; to support this, we would need to
  498. # find how to reset the ALLUSERS property, and how to re-run
  499. # FindRelatedProducts.
  500. # On Windows9x, the ALLUSERS property is ignored on the command line
  501. # and in the Property table, but installer fails according to the documentation
  502. # if a dialog attempts to set ALLUSERS.
  503. whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
  504. "AdminInstall", "Next", "Cancel")
  505. whichusers.title("Select whether to install [ProductName] for all users of this computer.")
  506. # A radio group with two options: allusers, justme
  507. g = whichusers.radiogroup("AdminInstall", 15, 60, 260, 50, 3,
  508. "WhichUsers", "", "Next")
  509. g.add("ALL", 0, 5, 150, 20, "Install for all users")
  510. g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
  511. whichusers.back("Back", None, active=0)
  512. c = whichusers.next("Next >", "Cancel")
  513. c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
  514. c.event("EndDialog", "Return", ordering = 2)
  515. c = whichusers.cancel("Cancel", "AdminInstall")
  516. c.event("SpawnDialog", "CancelDlg")
  517. #####################################################################
  518. # Installation Progress dialog (modeless)
  519. progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
  520. "Cancel", "Cancel", "Cancel", bitmap=False)
  521. progress.text("Title", 20, 15, 200, 15, 0x30003,
  522. "{\DlgFontBold8}[Progress1] [ProductName]")
  523. progress.text("Text", 35, 65, 300, 30, 3,
  524. "Please wait while the Installer [Progress2] [ProductName]. "
  525. "This may take several minutes.")
  526. progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
  527. c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
  528. c.mapping("ActionText", "Text")
  529. #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
  530. #c.mapping("ActionData", "Text")
  531. c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
  532. None, "Progress done", None, None)
  533. c.mapping("SetProgress", "Progress")
  534. progress.back("< Back", "Next", active=False)
  535. progress.next("Next >", "Cancel", active=False)
  536. progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
  537. ###################################################################
  538. # Maintenance type: repair/uninstall
  539. maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
  540. "Next", "Next", "Cancel")
  541. maint.title("Welcome to the [ProductName] Setup Wizard")
  542. maint.text("BodyText", 15, 63, 330, 42, 3,
  543. "Select whether you want to repair or remove [ProductName].")
  544. g=maint.radiogroup("RepairRadioGroup", 15, 108, 330, 60, 3,
  545. "MaintenanceForm_Action", "", "Next")
  546. #g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
  547. g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
  548. g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
  549. maint.back("< Back", None, active=False)
  550. c=maint.next("Finish", "Cancel")
  551. # Change installation: Change progress dialog to "Change", then ask
  552. # for feature selection
  553. #c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
  554. #c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
  555. # Reinstall: Change progress dialog to "Repair", then invoke reinstall
  556. # Also set list of reinstalled features to "ALL"
  557. c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
  558. c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
  559. c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
  560. c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
  561. # Uninstall: Change progress to "Remove", then invoke uninstall
  562. # Also set list of removed features to "ALL"
  563. c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
  564. c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
  565. c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
  566. c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
  567. # Close dialog when maintenance action scheduled
  568. c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
  569. #c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
  570. maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
  571. def get_installer_filename(self, fullname):
  572. # Factored out to allow overriding in subclasses
  573. base_name = "%s.%s-py%s.msi" % (fullname, self.plat_name,
  574. self.target_version)
  575. installer_name = os.path.join(self.dist_dir, base_name)
  576. return installer_name