logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

bdist_msi.py (35519B)


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