»Core Development>Code coverage>Lib/distutils/command/bdist_msi.py

Python code coverage for Lib/distutils/command/bdist_msi.py

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