PageRenderTime 52ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/lib-python/2.7/distutils/command/bdist_msi.py

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