blob: b06c2a1a41fa9514e316f6ae5694b891e7aa5a78 [file] [log] [blame]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001# Python MSI Generator
2# (C) 2003 Martin v. Loewis
3# See "FOO" in comments refers to MSDN sections with the title FOO.
Christian Heimes9acba042007-12-04 14:57:30 +00004import msilib, schema, sequence, os, glob, time, re, shutil
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00005from msilib import Feature, CAB, Directory, Dialog, Binary, add_data
6import uisample
7from win32com.client import constants
Martin v. Löwis9fda9312004-12-22 13:41:49 +00008from distutils.spawn import find_executable
Martin v. Löwis1d278fc2006-03-28 18:30:05 +00009from uuids import product_codes
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000010
11# Settings can be overridden in config.py below
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000012# 0 for official python.org releases
13# 1 for intermediate releases by anybody, with
14# a new product code for every package.
15snapshot = 1
16# 1 means that file extension is px, not py,
17# and binaries start with x
18testpackage = 0
19# Location of build tree
20srcdir = os.path.abspath("../..")
21# Text to be displayed as the version in dialogs etc.
22# goes into file name and ProductCode. Defaults to
23# current_version.day for Snapshot, current_version otherwise
24full_current_version = None
Martin v. Löwise0f780d2004-09-01 14:51:06 +000025# Is Tcl available at all?
26have_tcl = True
Martin v. Löwis1a494bd2006-04-04 07:10:59 +000027# Where is sqlite3.dll located, relative to srcdir?
28sqlite_dir = "../sqlite-source-3.3.4"
Christian Heimes9acba042007-12-04 14:57:30 +000029# path to PCbuild directory
Martin v. Löwise7a434e2008-01-06 11:03:43 +000030PCBUILD="PCbuild"
Christian Heimes9acba042007-12-04 14:57:30 +000031# msvcrt version
Martin v. Löwise7a434e2008-01-06 11:03:43 +000032MSVCR = "90"
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000033
34try:
35 from config import *
36except ImportError:
37 pass
38
39# Extract current version from Include/patchlevel.h
40lines = open(srcdir + "/Include/patchlevel.h").readlines()
41major = minor = micro = level = serial = None
42levels = {
43 'PY_RELEASE_LEVEL_ALPHA':0xA,
44 'PY_RELEASE_LEVEL_BETA': 0xB,
45 'PY_RELEASE_LEVEL_GAMMA':0xC,
46 'PY_RELEASE_LEVEL_FINAL':0xF
47 }
48for l in lines:
49 if not l.startswith("#define"):
50 continue
51 l = l.split()
52 if len(l) != 3:
53 continue
54 _, name, value = l
55 if name == 'PY_MAJOR_VERSION': major = value
56 if name == 'PY_MINOR_VERSION': minor = value
57 if name == 'PY_MICRO_VERSION': micro = value
58 if name == 'PY_RELEASE_LEVEL': level = levels[value]
59 if name == 'PY_RELEASE_SERIAL': serial = value
60
61short_version = major+"."+minor
62# See PC/make_versioninfo.c
63FIELD3 = 1000*int(micro) + 10*level + int(serial)
64current_version = "%s.%d" % (short_version, FIELD3)
65
66# This should never change. The UpgradeCode of this package can be
67# used in the Upgrade table of future packages to make the future
68# package replace this one. See "UpgradeCode Property".
69upgrade_code_snapshot='{92A24481-3ECB-40FC-8836-04B7966EC0D5}'
70upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}'
71
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000072if snapshot:
73 current_version = "%s.%s.%s" % (major, minor, int(time.time()/3600/24))
74 product_code = msilib.gen_uuid()
75else:
76 product_code = product_codes[current_version]
77
78if full_current_version is None:
79 full_current_version = current_version
80
81extensions = [
82 'bz2.pyd',
83 'pyexpat.pyd',
84 'select.pyd',
85 'unicodedata.pyd',
86 'winsound.pyd',
Trent Micke97e5a72005-12-15 22:08:46 +000087 '_elementtree.pyd',
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000088 '_bsddb.pyd',
89 '_socket.pyd',
90 '_ssl.pyd',
91 '_testcapi.pyd',
92 '_tkinter.pyd',
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +000093 '_msi.pyd',
Martin v. Löwisa09655e2006-03-10 15:36:28 +000094 '_ctypes.pyd',
Martin v. Löwis1a494bd2006-04-04 07:10:59 +000095 '_ctypes_test.pyd',
Martin v. Löwisa09fd6e2006-08-16 12:55:10 +000096 '_sqlite3.pyd',
97 '_hashlib.pyd'
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000098]
99
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000100# Well-known component UUIDs
101# These are needed for SharedDLLs reference counter; if
102# a different UUID was used for each incarnation of, say,
103# python24.dll, an upgrade would set the reference counter
104# from 1 to 2 (due to what I consider a bug in MSI)
105# Using the same UUID is fine since these files are versioned,
106# so Installer will always keep the newest version.
Christian Heimes9acba042007-12-04 14:57:30 +0000107# NOTE: All uuids are self generated.
Christian Heimes9acba042007-12-04 14:57:30 +0000108msvcr90_uuid = "{9C28CD84-397C-4045-855C-28B02291A272}"
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000109pythondll_uuid = {
110 "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}",
Martin v. Löwis5409c8d2007-08-30 18:15:22 +0000111 "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}",
Martin v. Löwisbe7abbb2007-08-14 05:01:50 +0000112 "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}",
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000113 } [major+minor]
Tim Peterseba28be2005-03-28 01:08:02 +0000114
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000115# Build the mingw import library, libpythonXY.a
116# This requires 'nm' and 'dlltool' executables on your PATH
117def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
118 warning = "WARNING: %s - libpythonXX.a not built"
119 nm = find_executable('nm')
120 dlltool = find_executable('dlltool')
121
122 if not nm or not dlltool:
123 print warning % "nm and/or dlltool were not found"
124 return False
125
126 nm_command = '%s -Cs %s' % (nm, lib_file)
127 dlltool_command = "%s --dllname %s --def %s --output-lib %s" % \
128 (dlltool, dll_file, def_file, mingw_lib)
129 export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match
130
131 f = open(def_file,'w')
132 print >>f, "LIBRARY %s" % dll_file
133 print >>f, "EXPORTS"
134
135 nm_pipe = os.popen(nm_command)
136 for line in nm_pipe.readlines():
137 m = export_match(line)
138 if m:
139 print >>f, m.group(1)
140 f.close()
141 exit = nm_pipe.close()
142
143 if exit:
144 print warning % "nm did not run successfully"
145 return False
146
147 if os.system(dlltool_command) != 0:
148 print warning % "dlltool did not run successfully"
149 return False
150
151 return True
152
153# Target files (.def and .a) go in PCBuild directory
Christian Heimes9acba042007-12-04 14:57:30 +0000154lib_file = os.path.join(srcdir, PCBUILD, "python%s%s.lib" % (major, minor))
155def_file = os.path.join(srcdir, PCBUILD, "python%s%s.def" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000156dll_file = "python%s%s.dll" % (major, minor)
Christian Heimes9acba042007-12-04 14:57:30 +0000157mingw_lib = os.path.join(srcdir, PCBUILD, "libpython%s%s.a" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000158
159have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
160
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000161# Determine the target architechture
Christian Heimes9acba042007-12-04 14:57:30 +0000162dll_path = os.path.join(srcdir, PCBUILD, dll_file)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000163msilib.set_arch_from_file(dll_path)
164if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
165 raise SystemError, "msisupport.dll for incorrect architecture"
166
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000167if testpackage:
168 ext = 'px'
169 testprefix = 'x'
170else:
171 ext = 'py'
172 testprefix = ''
173
174if msilib.Win64:
Martin v. Löwis75c23bd2007-08-30 18:25:47 +0000175 SystemFolderName = "[System64Folder]"
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +0000176 registry_component = 4|256
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000177else:
178 SystemFolderName = "[SystemFolder]"
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +0000179 registry_component = 4
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000180
181msilib.reset()
182
183# condition in which to install pythonxy.dll in system32:
184# a) it is Windows 9x or
185# b) it is NT, the user is privileged, and has chosen per-machine installation
186sys32cond = "(Windows9x or (Privileged and ALLUSERS))"
187
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000188def build_database():
189 """Generate an empty database, with just the schema and the
190 Summary information stream."""
191 if snapshot:
192 uc = upgrade_code_snapshot
193 else:
194 uc = upgrade_code
195 # schema represents the installer 2.0 database schema.
196 # sequence is the set of standard sequences
197 # (ui/execute, admin/advt/install)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000198 db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000199 schema, ProductName="Python "+full_current_version,
200 ProductCode=product_code,
201 ProductVersion=current_version,
Martin v. Löwis8bc77e42007-09-01 06:36:03 +0000202 Manufacturer=u"Python Software Foundation")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000203 # The default sequencing of the RemoveExistingProducts action causes
204 # removal of files that got just installed. Place it after
205 # InstallInitialize, so we first uninstall everything, but still roll
206 # back in case the installation is interrupted
207 msilib.change_sequence(sequence.InstallExecuteSequence,
208 "RemoveExistingProducts", 1510)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000209 msilib.add_tables(db, sequence)
210 # We cannot set ALLUSERS in the property table, as this cannot be
211 # reset if the user choses a per-user installation. Instead, we
212 # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages
213 # this property, and when the execution starts, ALLUSERS is set
214 # accordingly.
215 add_data(db, "Property", [("UpgradeCode", uc),
216 ("WhichUsers", "ALL"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000217 ("ProductLine", "Python%s%s" % (major, minor)),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000218 ])
219 db.Commit()
220 return db
221
222def remove_old_versions(db):
223 "Fill the upgrade table."
224 start = "%s.%s.0" % (major, minor)
225 # This requests that feature selection states of an older
226 # installation should be forwarded into this one. Upgrading
227 # requires that both the old and the new installation are
228 # either both per-machine or per-user.
229 migrate_features = 1
230 # See "Upgrade Table". We remove releases with the same major and
231 # minor version. For an snapshot, we remove all earlier snapshots. For
232 # a release, we remove all snapshots, and all earlier releases.
233 if snapshot:
234 add_data(db, "Upgrade",
Tim Peters66cb0182004-08-26 05:23:19 +0000235 [(upgrade_code_snapshot, start,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000236 current_version,
237 None, # Ignore language
Tim Peters66cb0182004-08-26 05:23:19 +0000238 migrate_features,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000239 None, # Migrate ALL features
240 "REMOVEOLDSNAPSHOT")])
241 props = "REMOVEOLDSNAPSHOT"
242 else:
243 add_data(db, "Upgrade",
244 [(upgrade_code, start, current_version,
245 None, migrate_features, None, "REMOVEOLDVERSION"),
246 (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1),
247 None, migrate_features, None, "REMOVEOLDSNAPSHOT")])
248 props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION"
249 # Installer collects the product codes of the earlier releases in
250 # these properties. In order to allow modification of the properties,
251 # they must be declared as secure. See "SecureCustomProperties Property"
252 add_data(db, "Property", [("SecureCustomProperties", props)])
253
254class PyDialog(Dialog):
255 """Dialog class with a fixed layout: controls at the top, then a ruler,
256 then a list of buttons: back, next, cancel. Optionally a bitmap at the
257 left."""
258 def __init__(self, *args, **kw):
259 """Dialog(database, name, x, y, w, h, attributes, title, first,
260 default, cancel, bitmap=true)"""
261 Dialog.__init__(self, *args)
262 ruler = self.h - 36
263 bmwidth = 152*ruler/328
264 if kw.get("bitmap", True):
265 self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
266 self.line("BottomLine", 0, ruler, self.w, 0)
267
268 def title(self, title):
269 "Set the title text of the dialog at the top."
270 # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
271 # text, in VerdanaBold10
272 self.text("Title", 135, 10, 220, 60, 0x30003,
273 r"{\VerdanaBold10}%s" % title)
274
275 def back(self, title, next, name = "Back", active = 1):
276 """Add a back button with a given title, the tab-next button,
277 its name in the Control table, possibly initially disabled.
278
279 Return the button, so that events can be associated"""
280 if active:
281 flags = 3 # Visible|Enabled
282 else:
283 flags = 1 # Visible
284 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
285
286 def cancel(self, title, next, name = "Cancel", active = 1):
287 """Add a cancel button with a given title, the tab-next button,
288 its name in the Control table, possibly initially disabled.
289
290 Return the button, so that events can be associated"""
291 if active:
292 flags = 3 # Visible|Enabled
293 else:
294 flags = 1 # Visible
295 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
296
297 def next(self, title, next, name = "Next", active = 1):
298 """Add a Next button with a given title, the tab-next button,
299 its name in the Control table, possibly initially disabled.
300
301 Return the button, so that events can be associated"""
302 if active:
303 flags = 3 # Visible|Enabled
304 else:
305 flags = 1 # Visible
306 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
307
308 def xbutton(self, name, title, next, xpos):
309 """Add a button with a given title, the tab-next button,
310 its name in the Control table, giving its x position; the
311 y-position is aligned with the other buttons.
312
313 Return the button, so that events can be associated"""
314 return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
315
316def add_ui(db):
317 x = y = 50
318 w = 370
319 h = 300
320 title = "[ProductName] Setup"
321
322 # see "Dialog Style Bits"
323 modal = 3 # visible | modal
324 modeless = 1 # visible
325 track_disk_space = 32
326
327 add_data(db, 'ActionText', uisample.ActionText)
328 add_data(db, 'UIText', uisample.UIText)
329
330 # Bitmaps
331 if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
332 raise "Run icons.mak in PC directory"
333 add_data(db, "Binary",
Christian Heimes7e28e492008-01-01 13:52:57 +0000334 [("PythonWin", msilib.Binary(r"%s\PCbuild\installer.bmp" % srcdir)), # 152x328 pixels
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000335 ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
336 ])
337 add_data(db, "Icon",
338 [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))])
339
340 # Scripts
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000341 # CheckDir sets TargetExists if TARGETDIR exists.
342 # UpdateEditIDLE sets the REGISTRY.tcl component into
343 # the installed/uninstalled state according to both the
344 # Extensions and TclTk features.
Martin v. Löwiseb68be42004-12-12 15:29:21 +0000345 if os.system("nmake /nologo /c /f msisupport.mak") != 0:
346 raise "'nmake /f msisupport.mak' failed"
347 add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
348 # See "Custom Action Type 1"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000349 if msilib.Win64:
350 CheckDir = "CheckDir"
Martin v. Löwisdf40ce32006-02-16 14:38:30 +0000351 UpdateEditIDLE = "UpdateEditIDLE"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000352 else:
353 CheckDir = "_CheckDir@4"
354 UpdateEditIDLE = "_UpdateEditIDLE@4"
Tim Peters0e9980f2004-09-12 03:49:31 +0000355 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000356 [("CheckDir", 1, "Script", CheckDir)])
Martin v. Löwiseac02e62004-11-18 08:00:33 +0000357 if have_tcl:
358 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000359 [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)])
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000360
361 # UI customization properties
362 add_data(db, "Property",
363 # See "DefaultUIFont Property"
364 [("DefaultUIFont", "DlgFont8"),
365 # See "ErrorDialog Style Bit"
366 ("ErrorDialog", "ErrorDlg"),
367 ("Progress1", "Install"), # modified in maintenance type dlg
368 ("Progress2", "installs"),
369 ("MaintenanceForm_Action", "Repair")])
370
371 # Fonts, see "TextStyle Table"
372 add_data(db, "TextStyle",
373 [("DlgFont8", "Tahoma", 9, None, 0),
374 ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
375 ("VerdanaBold10", "Verdana", 10, None, 1),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000376 ("VerdanaRed9", "Verdana", 9, 255, 0),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000377 ])
378
Martin v. Löwis4cbd05c2006-07-06 07:05:21 +0000379 compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x bad_coding|badsyntax|site-packages "[TARGETDIR]Lib"'
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000380 # See "CustomAction Table"
381 add_data(db, "CustomAction", [
382 # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
383 # See "Custom Action Type 51",
384 # "Custom Action Execution Scheduling Options"
385 ("InitialTargetDir", 307, "TARGETDIR",
386 "[WindowsVolume]Python%s%s" % (major, minor)),
387 ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"),
388 ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName),
389 # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile
390 # See "Custom Action Type 18"
Martin v. Löwis7b2563b2004-11-02 22:59:56 +0000391 ("CompilePyc", 18, "python.exe", compileargs),
392 ("CompilePyo", 18, "python.exe", "-O "+compileargs),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000393 ])
394
395 # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
396 # Numbers indicate sequence; see sequence.py for how these action integrate
397 add_data(db, "InstallUISequence",
398 [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
399 ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
400 ("InitialTargetDir", 'TARGETDIR=""', 750),
401 # In the user interface, assume all-users installation if privileged.
402 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
403 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
404 ("SelectDirectoryDlg", "Not Installed", 1230),
405 # XXX no support for resume installations yet
406 #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
407 ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
408 ("ProgressDlg", None, 1280)])
409 add_data(db, "AdminUISequence",
410 [("InitialTargetDir", 'TARGETDIR=""', 750),
411 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
412 ])
413
414 # Execute Sequences
415 add_data(db, "InstallExecuteSequence",
416 [("InitialTargetDir", 'TARGETDIR=""', 750),
417 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
418 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000419 ("UpdateEditIDLE", None, 1050),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000420 ("CompilePyc", "COMPILEALL", 6800),
421 ("CompilePyo", "COMPILEALL", 6801),
422 ])
423 add_data(db, "AdminExecuteSequence",
424 [("InitialTargetDir", 'TARGETDIR=""', 750),
425 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
426 ("CompilePyc", "COMPILEALL", 6800),
427 ("CompilePyo", "COMPILEALL", 6801),
428 ])
429
430 #####################################################################
431 # Standard dialogs: FatalError, UserExit, ExitDialog
432 fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
433 "Finish", "Finish", "Finish")
434 fatal.title("[ProductName] Installer ended prematurely")
435 fatal.back("< Back", "Finish", active = 0)
436 fatal.cancel("Cancel", "Back", active = 0)
437 fatal.text("Description1", 135, 70, 220, 80, 0x30003,
438 "[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.")
439 fatal.text("Description2", 135, 155, 220, 20, 0x30003,
440 "Click the Finish button to exit the Installer.")
441 c=fatal.next("Finish", "Cancel", name="Finish")
442 # See "ControlEvent Table". Parameters are the event, the parameter
443 # to the action, and optionally the condition for the event, and the order
444 # of events.
445 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000446
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000447 user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
448 "Finish", "Finish", "Finish")
449 user_exit.title("[ProductName] Installer was interrupted")
450 user_exit.back("< Back", "Finish", active = 0)
451 user_exit.cancel("Cancel", "Back", active = 0)
452 user_exit.text("Description1", 135, 70, 220, 80, 0x30003,
453 "[ProductName] setup was interrupted. Your system has not been modified. "
454 "To install this program at a later time, please run the installation again.")
455 user_exit.text("Description2", 135, 155, 220, 20, 0x30003,
456 "Click the Finish button to exit the Installer.")
457 c = user_exit.next("Finish", "Cancel", name="Finish")
458 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000459
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000460 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
461 "Finish", "Finish", "Finish")
462 exit_dialog.title("Completing the [ProductName] Installer")
463 exit_dialog.back("< Back", "Finish", active = 0)
464 exit_dialog.cancel("Cancel", "Back", active = 0)
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000465 exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003,
466 "Special Windows thanks to:\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000467 " Mark Hammond, without whose years of freely \n"
468 " shared Windows expertise, Python for Windows \n"
469 " would still be Python for DOS.")
Tim Peters66cb0182004-08-26 05:23:19 +0000470
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000471 c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003,
472 "{\\VerdanaRed9}Warning: Python 2.5.x is the last "
473 "Python release for Windows 9x.")
Martin v. Löwisdf511792006-03-28 07:51:51 +0000474 c.condition("Hide", "NOT Version9X")
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000475
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000476 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000477 "Click the Finish button to exit the Installer.")
478 c = exit_dialog.next("Finish", "Cancel", name="Finish")
479 c.event("EndDialog", "Return")
480
481 #####################################################################
482 # Required dialog: FilesInUse, ErrorDlg
483 inuse = PyDialog(db, "FilesInUse",
484 x, y, w, h,
485 19, # KeepModeless|Modal|Visible
486 title,
487 "Retry", "Retry", "Retry", bitmap=False)
488 inuse.text("Title", 15, 6, 200, 15, 0x30003,
489 r"{\DlgFontBold8}Files in Use")
490 inuse.text("Description", 20, 23, 280, 20, 0x30003,
491 "Some files that need to be updated are currently in use.")
492 inuse.text("Text", 20, 55, 330, 50, 3,
493 "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.")
494 inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
495 None, None, None)
496 c=inuse.back("Exit", "Ignore", name="Exit")
497 c.event("EndDialog", "Exit")
498 c=inuse.next("Ignore", "Retry", name="Ignore")
499 c.event("EndDialog", "Ignore")
500 c=inuse.cancel("Retry", "Exit", name="Retry")
501 c.event("EndDialog","Retry")
502
503
504 # See "Error Dialog". See "ICE20" for the required names of the controls.
505 error = Dialog(db, "ErrorDlg",
506 50, 10, 330, 101,
507 65543, # Error|Minimize|Modal|Visible
508 title,
509 "ErrorText", None, None)
510 error.text("ErrorText", 50,9,280,48,3, "")
511 error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
512 error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
513 error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
514 error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
515 error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
516 error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
517 error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
518 error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
519
520 #####################################################################
521 # Global "Query Cancel" dialog
522 cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
523 "No", "No", "No")
Tim Peters66cb0182004-08-26 05:23:19 +0000524 cancel.text("Text", 48, 15, 194, 30, 3,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000525 "Are you sure you want to cancel [ProductName] installation?")
526 cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
527 "py.ico", None, None)
528 c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
529 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000530
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000531 c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
532 c.event("EndDialog", "Return")
533
534 #####################################################################
535 # Global "Wait for costing" dialog
536 costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
537 "Return", "Return", "Return")
538 costing.text("Text", 48, 15, 194, 30, 3,
539 "Please wait while the installer finishes determining your disk space requirements.")
540 costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
541 "py.ico", None, None)
542 c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
543 c.event("EndDialog", "Exit")
544
545 #####################################################################
546 # Preparation dialog: no user input except cancellation
547 prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
548 "Cancel", "Cancel", "Cancel")
549 prep.text("Description", 135, 70, 220, 40, 0x30003,
550 "Please wait while the Installer prepares to guide you through the installation.")
551 prep.title("Welcome to the [ProductName] Installer")
552 c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...")
553 c.mapping("ActionText", "Text")
554 c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None)
555 c.mapping("ActionData", "Text")
556 prep.back("Back", None, active=0)
557 prep.next("Next", None, active=0)
558 c=prep.cancel("Cancel", None)
559 c.event("SpawnDialog", "CancelDlg")
560
561 #####################################################################
562 # Target directory selection
563 seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
564 "Next", "Next", "Cancel")
565 seldlg.title("Select Destination Directory")
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000566 c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003,
567 "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.")
568 c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""')
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000569 seldlg.text("Description", 135, 50, 220, 40, 0x30003,
570 "Please select a directory for the [ProductName] files.")
571
572 seldlg.back("< Back", None, active=0)
573 c = seldlg.next("Next >", "Cancel")
574 c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1)
575 # If the target exists, but we found that we are going to remove old versions, don't bother
576 # confirming that the target directory exists. Strictly speaking, we should determine that
577 # the target directory is indeed the target of the product that we are going to remove, but
578 # I don't know how to do that.
579 c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2)
580 c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3)
581 c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4)
582 c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5)
583
584 c = seldlg.cancel("Cancel", "DirectoryCombo")
585 c.event("SpawnDialog", "CancelDlg")
586
587 seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219,
588 "TARGETDIR", None, "DirectoryList", None)
589 seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR",
590 None, "PathEdit", None)
591 seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None)
592 c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
593 c.event("DirectoryListUp", "0")
594 c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
595 c.event("DirectoryListNew", "0")
596
597 #####################################################################
598 # SelectFeaturesDlg
599 features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space,
600 title, "Tree", "Next", "Cancel")
601 features.title("Customize [ProductName]")
602 features.text("Description", 135, 35, 220, 15, 0x30003,
603 "Select the way you want features to be installed.")
604 features.text("Text", 135,45,220,30, 3,
605 "Click on the icons in the tree below to change the way features will be installed.")
606
607 c=features.back("< Back", "Next")
608 c.event("NewDialog", "SelectDirectoryDlg")
609
610 c=features.next("Next >", "Cancel")
611 c.mapping("SelectionNoItems", "Enabled")
612 c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1)
613 c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2)
614
615 c=features.cancel("Cancel", "Tree")
616 c.event("SpawnDialog", "CancelDlg")
617
Tim Peters66cb0182004-08-26 05:23:19 +0000618 # The browse property is not used, since we have only a single target path (selected already)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000619 features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty",
620 "Tree of selections", "Back", None)
621
622 #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost")
623 #c.mapping("SelectionNoItems", "Enabled")
624 #c.event("Reset", "0")
Tim Peters66cb0182004-08-26 05:23:19 +0000625
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000626 features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None)
627
628 c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10)
629 c.mapping("SelectionNoItems","Enabled")
630 c.event("SpawnDialog", "DiskCostDlg")
631
632 c=features.xbutton("Advanced", "Advanced", None, 0.30)
633 c.event("SpawnDialog", "AdvancedDlg")
634
635 c=features.text("ItemDescription", 140, 180, 210, 30, 3,
636 "Multiline description of the currently selected item.")
637 c.mapping("SelectionDescription","Text")
Tim Peters66cb0182004-08-26 05:23:19 +0000638
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000639 c=features.text("ItemSize", 140, 210, 210, 45, 3,
640 "The size of the currently selected item.")
641 c.mapping("SelectionSize", "Text")
642
643 #####################################################################
644 # Disk cost
645 cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
646 "OK", "OK", "OK", bitmap=False)
647 cost.text("Title", 15, 6, 200, 15, 0x30003,
648 "{\DlgFontBold8}Disk Space Requirements")
649 cost.text("Description", 20, 20, 280, 20, 0x30003,
650 "The disk space required for the installation of the selected features.")
651 cost.text("Text", 20, 53, 330, 60, 3,
652 "The highlighted volumes (if any) do not have enough disk space "
653 "available for the currently selected features. You can either "
654 "remove some files from the highlighted volumes, or choose to "
655 "install less features onto local drive(s), or select different "
656 "destination drive(s).")
657 cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
658 None, "{120}{70}{70}{70}{70}", None, None)
659 cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
660
661 #####################################################################
662 # WhichUsers Dialog. Only available on NT, and for privileged users.
663 # This must be run before FindRelatedProducts, because that will
664 # take into account whether the previous installation was per-user
665 # or per-machine. We currently don't support going back to this
666 # dialog after "Next" was selected; to support this, we would need to
667 # find how to reset the ALLUSERS property, and how to re-run
668 # FindRelatedProducts.
669 # On Windows9x, the ALLUSERS property is ignored on the command line
670 # and in the Property table, but installer fails according to the documentation
671 # if a dialog attempts to set ALLUSERS.
672 whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
673 "AdminInstall", "Next", "Cancel")
674 whichusers.title("Select whether to install [ProductName] for all users of this computer.")
675 # A radio group with two options: allusers, justme
676 g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3,
677 "WhichUsers", "", "Next")
678 g.add("ALL", 0, 5, 150, 20, "Install for all users")
679 g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
680
Tim Peters66cb0182004-08-26 05:23:19 +0000681 whichusers.back("Back", None, active=0)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000682
683 c = whichusers.next("Next >", "Cancel")
684 c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
685 c.event("EndDialog", "Return", order = 2)
686
687 c = whichusers.cancel("Cancel", "AdminInstall")
688 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000689
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000690 #####################################################################
691 # Advanced Dialog.
692 advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
693 "CompilePyc", "Next", "Cancel")
694 advanced.title("Advanced Options for [ProductName]")
695 # A radio group with two options: allusers, justme
696 advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
697 "COMPILEALL", "Compile .py files to byte code after installation", "Next")
698
699 c = advanced.next("Finish", "Cancel")
700 c.event("EndDialog", "Return")
701
702 c = advanced.cancel("Cancel", "CompilePyc")
703 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000704
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000705 #####################################################################
Tim Peters66cb0182004-08-26 05:23:19 +0000706 # Existing Directory dialog
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000707 dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
708 "No", "No", "No")
709 dlg.text("Title", 10, 20, 180, 40, 3,
710 "[TARGETDIR] exists. Are you sure you want to overwrite existing files?")
711 c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No")
712 c.event("[TargetExists]", "0", order=1)
713 c.event("[TargetExistsOk]", "1", order=2)
714 c.event("EndDialog", "Return", order=3)
715 c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes")
716 c.event("EndDialog", "Return")
717
718 #####################################################################
719 # Installation Progress dialog (modeless)
720 progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
721 "Cancel", "Cancel", "Cancel", bitmap=False)
722 progress.text("Title", 20, 15, 200, 15, 0x30003,
723 "{\DlgFontBold8}[Progress1] [ProductName]")
724 progress.text("Text", 35, 65, 300, 30, 3,
725 "Please wait while the Installer [Progress2] [ProductName]. "
726 "This may take several minutes.")
727 progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
728
729 c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
730 c.mapping("ActionText", "Text")
731
732 #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
733 #c.mapping("ActionData", "Text")
734
735 c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
736 None, "Progress done", None, None)
737 c.mapping("SetProgress", "Progress")
738
739 progress.back("< Back", "Next", active=False)
740 progress.next("Next >", "Cancel", active=False)
741 progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
742
743 # Maintenance type: repair/uninstall
744 maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
745 "Next", "Next", "Cancel")
746 maint.title("Welcome to the [ProductName] Setup Wizard")
747 maint.text("BodyText", 135, 63, 230, 42, 3,
748 "Select whether you want to repair or remove [ProductName].")
749 g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3,
750 "MaintenanceForm_Action", "", "Next")
751 g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
752 g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
753 g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
Tim Peters66cb0182004-08-26 05:23:19 +0000754
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000755 maint.back("< Back", None, active=False)
756 c=maint.next("Finish", "Cancel")
757 # Change installation: Change progress dialog to "Change", then ask
758 # for feature selection
759 c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
760 c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
761
762 # Reinstall: Change progress dialog to "Repair", then invoke reinstall
763 # Also set list of reinstalled features to "ALL"
764 c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
765 c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
Raymond Hettinger72f08012004-11-07 07:08:25 +0000766 c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000767 c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
768
769 # Uninstall: Change progress to "Remove", then invoke uninstall
770 # Also set list of removed features to "ALL"
771 c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
772 c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
773 c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
774 c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
775
Tim Peters66cb0182004-08-26 05:23:19 +0000776 # Close dialog when maintenance action scheduled
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000777 c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
778 c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
Tim Peters66cb0182004-08-26 05:23:19 +0000779
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000780 maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000781
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000782
783# See "Feature Table". The feature level is 1 for all features,
784# and the feature attributes are 0 for the DefaultFeature, and
785# FollowParent for all other features. The numbers are the Display
786# column.
787def add_features(db):
788 # feature attributes:
789 # msidbFeatureAttributesFollowParent == 2
790 # msidbFeatureAttributesDisallowAdvertise == 8
791 # Features that need to be installed with together with the main feature
792 # (i.e. additional Python libraries) need to follow the parent feature.
793 # Features that have no advertisement trigger (e.g. the test suite)
794 # must not support advertisement
Martin v. Löwise411f892008-04-07 14:54:16 +0000795 global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature, private_crt
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000796 default_feature = Feature(db, "DefaultFeature", "Python",
797 "Python Interpreter and Libraries",
798 1, directory = "TARGETDIR")
Martin v. Löwis4dc34152008-04-05 15:48:36 +0000799 shared_crt = Feature(db, "SharedCRT", "MSVCRT", "C Run-Time (system-wide)", 0,
800 level=0)
801 private_crt = Feature(db, "PrivateCRT", "MSVCRT", "C Run-Time (private)", 0,
802 level=0)
803 add_data(db, "Condition", [("SharedCRT", 1, sys32cond),
804 ("PrivateCRT", 1, "not "+sys32cond)])
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000805 # We don't support advertisement of extensions
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000806 ext_feature = Feature(db, "Extensions", "Register Extensions",
807 "Make this Python installation the default Python installation", 3,
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000808 parent = default_feature, attributes=2|8)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000809 if have_tcl:
810 tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000811 parent = default_feature, attributes=2)
812 htmlfiles = Feature(db, "Documentation", "Documentation",
813 "Python HTMLHelp File", 7, parent = default_feature)
814 tools = Feature(db, "Tools", "Utility Scripts",
Tim Peters66cb0182004-08-26 05:23:19 +0000815 "Python utility scripts (Tools/", 9,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000816 parent = default_feature, attributes=2)
817 testsuite = Feature(db, "Testsuite", "Test suite",
818 "Python test suite (Lib/test/)", 11,
819 parent = default_feature, attributes=2|8)
Tim Peters66cb0182004-08-26 05:23:19 +0000820
Christian Heimes9acba042007-12-04 14:57:30 +0000821def extract_msvcr90():
Martin v. Löwis03dc56c2008-02-28 22:20:50 +0000822 # Find the redistributable files
823 dir = os.path.join(os.environ['VS90COMNTOOLS'], r"..\..\VC\redist\x86\Microsoft.VC90.CRT")
Christian Heimes9acba042007-12-04 14:57:30 +0000824
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000825 result = []
Christian Heimes9acba042007-12-04 14:57:30 +0000826 installer = msilib.MakeInstaller()
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000827 # omit msvcm90 and msvcp90, as they aren't really needed
828 files = ["Microsoft.VC90.CRT.manifest", "msvcr90.dll"]
829 for f in files:
830 path = os.path.join(dir, f)
831 kw = {'src':path}
832 if f.endswith('.dll'):
833 kw['version'] = installer.FileVersion(path, 0)
834 kw['language'] = installer.FileVersion(path, 1)
835 result.append((f, kw))
836 return result
Christian Heimes9acba042007-12-04 14:57:30 +0000837
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000838class PyDirectory(Directory):
839 """By default, all components in the Python installer
840 can run from source."""
841 def __init__(self, *args, **kw):
842 if not kw.has_key("componentflags"):
843 kw['componentflags'] = 2 #msidbComponentAttributesOptional
844 Directory.__init__(self, *args, **kw)
845
846# See "File Table", "Component Table", "Directory Table",
847# "FeatureComponents Table"
848def add_files(db):
849 cab = CAB("python")
850 tmpfiles = []
851 # Add all executables, icons, text files into the TARGETDIR component
852 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
853 default_feature.set_current()
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000854 if not msilib.Win64:
Christian Heimes9acba042007-12-04 14:57:30 +0000855 root.add_file("%s/w9xpopen.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000856 root.add_file("README.txt", src="README")
857 root.add_file("NEWS.txt", src="Misc/NEWS")
858 root.add_file("LICENSE.txt", src="LICENSE")
859 root.start_component("python.exe", keyfile="python.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000860 root.add_file("%s/python.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000861 root.start_component("pythonw.exe", keyfile="pythonw.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000862 root.add_file("%s/pythonw.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000863
864 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000865 #dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
866 #install python30.dll into root dir for now
867 dlldir = root
868
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000869 pydll = "python%s%s.dll" % (major, minor)
Christian Heimes9acba042007-12-04 14:57:30 +0000870 pydllsrc = os.path.join(srcdir, PCBUILD, pydll)
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000871 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000872 installer = msilib.MakeInstaller()
873 pyversion = installer.FileVersion(pydllsrc, 0)
874 if not snapshot:
875 # For releases, the Python DLL has the same version as the
876 # installer package.
877 assert pyversion.split(".")[:3] == current_version.split(".")
Christian Heimes9acba042007-12-04 14:57:30 +0000878 dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000879 version=pyversion,
880 language=installer.FileVersion(pydllsrc, 1))
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000881 DLLs = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
Martin v. Löwis46a8be72008-04-07 14:55:53 +0000882 root.start_component("msvcr90", feature=private_crt)
883 for file, kw in extract_msvcr90():
884 root.add_file(file, **kw)
885 if file.endswith("manifest"):
886 DLLs.add_file(file, **kw)
Tim Peters66cb0182004-08-26 05:23:19 +0000887
Martin v. Löwis38325b72006-08-25 00:03:34 +0000888 # Check if _ctypes.pyd exists
Christian Heimes9acba042007-12-04 14:57:30 +0000889 have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
Martin v. Löwis38325b72006-08-25 00:03:34 +0000890 if not have_ctypes:
891 print "WARNING: _ctypes.pyd not found, ctypes will not be included"
892 extensions.remove("_ctypes.pyd")
Tim Peters147f9ae2006-08-25 22:05:39 +0000893
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000894 # Add all .py files in Lib, except lib-tk, test
895 dirs={}
896 pydirs = [(root,"Lib")]
897 while pydirs:
898 parent, dir = pydirs.pop()
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000899 if dir == ".svn" or dir.startswith("plat-"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000900 continue
901 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000902 if not have_tcl:
903 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000904 tcltk.set_current()
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000905 elif dir in ['test', 'tests', 'data', 'output']:
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000906 # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000907 # tests: Lib/distutils
908 # data: Lib/email/test
909 # output: Lib/test
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000910 testsuite.set_current()
Martin v. Löwis38325b72006-08-25 00:03:34 +0000911 elif not have_ctypes and dir == "ctypes":
912 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000913 else:
914 default_feature.set_current()
915 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
916 # Add additional files
917 dirs[dir]=lib
918 lib.glob("*.txt")
919 if dir=='site-packages':
Martin v. Löwis6d60c092004-11-21 10:16:26 +0000920 lib.add_file("README.txt", src="README")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000921 continue
922 files = lib.glob("*.py")
923 files += lib.glob("*.pyw")
924 if files:
925 # Add an entry to the RemoveFile table to remove bytecode files.
926 lib.remove_pyc()
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000927 if dir.endswith('.egg-info'):
928 lib.add_file('entry_points.txt')
929 lib.add_file('PKG-INFO')
930 lib.add_file('top_level.txt')
931 lib.add_file('zip-safe')
932 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000933 if dir=='test' and parent.physical=='Lib':
934 lib.add_file("185test.db")
935 lib.add_file("audiotest.au")
936 lib.add_file("cfgparser.1")
Martin v. Löwisc0fdb182006-09-12 19:49:20 +0000937 lib.add_file("sgml_input.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000938 lib.add_file("test.xml")
939 lib.add_file("test.xml.out")
940 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000941 lib.add_file("test_difflib_expect.html")
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000942 lib.add_file("check_soundcard.vbs")
Thomas Heller3bd33152006-04-04 18:41:13 +0000943 lib.add_file("empty.vbs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000944 lib.glob("*.uue")
Martin v. Löwis0ffdacd2007-11-20 02:46:02 +0000945 lib.glob("*.pem")
Martin v. Löwis6b449f42007-12-03 19:20:02 +0000946 lib.glob("*.pck")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000947 lib.add_file("readme.txt", src="README")
948 if dir=='decimaltestdata':
949 lib.glob("*.decTest")
950 if dir=='output':
951 lib.glob("test_*")
952 if dir=='idlelib':
953 lib.glob("*.def")
954 lib.add_file("idle.bat")
955 if dir=="Icons":
956 lib.glob("*.gif")
957 lib.add_file("idle.icns")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000958 if dir=="command" and parent.physical=="distutils":
Christian Heimes7e28e492008-01-01 13:52:57 +0000959 lib.add_file("wininst-6.0.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000960 lib.add_file("wininst-7.1.exe")
Christian Heimes7e28e492008-01-01 13:52:57 +0000961 lib.add_file("wininst-8.0.exe")
962 lib.add_file("wininst-9.0.exe")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000963 if dir=="setuptools":
964 lib.add_file("cli.exe")
965 lib.add_file("gui.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000966 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000967 # This should contain all non-.svn files listed in subversion
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000968 for f in os.listdir(lib.absolute):
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000969 if f.endswith(".txt") or f==".svn":continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000970 if f.endswith(".au") or f.endswith(".gif"):
971 lib.add_file(f)
972 else:
973 print "WARNING: New file %s in email/test/data" % f
974 for f in os.listdir(lib.absolute):
975 if os.path.isdir(os.path.join(lib.absolute, f)):
976 pydirs.append((lib, f))
977 # Add DLLs
978 default_feature.set_current()
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000979 lib = DLLs
Christian Heimes7e28e492008-01-01 13:52:57 +0000980 lib.add_file("py.ico", src=srcdir+"/PC/py.ico")
Christian Heimese1c6af02008-01-01 13:58:16 +0000981 lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000982 dlls = []
983 tclfiles = []
984 for f in extensions:
985 if f=="_tkinter.pyd":
986 continue
Christian Heimes9acba042007-12-04 14:57:30 +0000987 if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000988 print "WARNING: Missing extension", f
989 continue
990 dlls.append(f)
991 lib.add_file(f)
Martin v. Löwis88ef6372006-07-06 06:55:58 +0000992 # Add sqlite
993 if msilib.msi_type=="Intel64;1033":
994 sqlite_arch = "/ia64"
995 elif msilib.msi_type=="x64;1033":
996 sqlite_arch = "/amd64"
Martin v. Löwis0e795e72008-02-29 20:54:44 +0000997 tclsuffix = "64"
Martin v. Löwis88ef6372006-07-06 06:55:58 +0000998 else:
999 sqlite_arch = ""
Martin v. Löwis0e795e72008-02-29 20:54:44 +00001000 tclsuffix = ""
Martin v. Löwis88ef6372006-07-06 06:55:58 +00001001 lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001002 if have_tcl:
Christian Heimes9acba042007-12-04 14:57:30 +00001003 if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001004 print "WARNING: Missing _tkinter.pyd"
1005 else:
1006 lib.start_component("TkDLLs", tcltk)
1007 lib.add_file("_tkinter.pyd")
1008 dlls.append("_tkinter.pyd")
Martin v. Löwis0e795e72008-02-29 20:54:44 +00001009 tcldir = os.path.normpath(srcdir+("/../tcltk%s/bin" % tclsuffix))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001010 for f in glob.glob1(tcldir, "*.dll"):
1011 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001012 # check whether there are any unknown extensions
Christian Heimes9acba042007-12-04 14:57:30 +00001013 for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001014 if f.endswith("_d.pyd"): continue # debug version
1015 if f in dlls: continue
1016 print "WARNING: Unknown extension", f
Tim Peters66cb0182004-08-26 05:23:19 +00001017
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001018 # Add headers
1019 default_feature.set_current()
1020 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
1021 lib.glob("*.h")
1022 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
1023 # Add import libraries
Christian Heimes9acba042007-12-04 14:57:30 +00001024 lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001025 for f in dlls:
1026 lib.add_file(f.replace('pyd','lib'))
1027 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +00001028 # Add the mingw-format library
1029 if have_mingw:
Tim Peters5a9fb3c2005-01-07 16:01:32 +00001030 lib.add_file('libpython%s%s.a' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001031 if have_tcl:
1032 # Add Tcl/Tk
Martin v. Löwis0e795e72008-02-29 20:54:44 +00001033 tcldirs = [(root, '../tcltk%s/lib' % tclsuffix, 'tcl')]
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001034 tcltk.set_current()
1035 while tcldirs:
1036 parent, phys, dir = tcldirs.pop()
1037 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
1038 if not os.path.exists(lib.absolute):
1039 continue
1040 for f in os.listdir(lib.absolute):
1041 if os.path.isdir(os.path.join(lib.absolute, f)):
1042 tcldirs.append((lib, f, f))
1043 else:
1044 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001045 # Add tools
1046 tools.set_current()
1047 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
1048 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
1049 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1050 lib.glob("*.py")
1051 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1052 lib.remove_pyc()
1053 lib.glob("*.txt")
1054 if f == "pynche":
1055 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1056 x.glob("*.txt")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001057 if os.path.exists(os.path.join(lib.absolute, "README")):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001058 lib.add_file("README.txt", src="README")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001059 if f == 'Scripts':
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001060 if have_tcl:
1061 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1062 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001063 # Add documentation
1064 htmlfiles.set_current()
1065 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
1066 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
Martin v. Löwis8628f752007-09-10 10:21:22 +00001067 lib.add_file("Python%s%s.chm" % (major, minor), src="build/htmlhelp/pydoc.chm")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001068
1069 cab.commit(db)
1070
1071 for f in tmpfiles:
1072 os.unlink(f)
1073
1074# See "Registry Table", "Component Table"
1075def add_registry(db):
1076 # File extensions, associated with the REGISTRY.def component
1077 # IDLE verbs depend on the tcltk feature.
1078 # msidbComponentAttributesRegistryKeyPath = 4
1079 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001080 tcldata = []
1081 if have_tcl:
1082 tcldata = [
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001083 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001084 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001085 add_data(db, "Component",
1086 # msidbComponentAttributesRegistryKeyPath = 4
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001087 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001088 "InstallPath"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001089 ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001090 "Documentation"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001091 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001092 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001093 # See "FeatureComponents Table".
1094 # The association between TclTk and pythonw.exe is necessary to make ICE59
1095 # happy, because the installer otherwise believes that the IDLE and PyDoc
1096 # shortcuts might get installed without pythonw.exe being install. This
1097 # is not true, since installing TclTk will install the default feature, which
1098 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001099 # REGISTRY.tcl is not associated with any feature, as it will be requested
1100 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001101 tcldata = []
1102 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001103 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001104 add_data(db, "FeatureComponents",
1105 [(default_feature.id, "REGISTRY"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001106 (htmlfiles.id, "REGISTRY.doc"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001107 (ext_feature.id, "REGISTRY.def")] +
1108 tcldata
1109 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001110 # Extensions are not advertised. For advertised extensions,
1111 # we would need separate binaries that install along with the
1112 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001113 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1114 ewi = "Edit with IDLE"
1115 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1116 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001117 tcl_verbs = []
1118 if have_tcl:
1119 tcl_verbs=[
1120 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1121 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1122 "REGISTRY.tcl"),
1123 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1124 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1125 "REGISTRY.tcl"),
1126 ]
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001127 add_data(db, "Registry",
1128 [# Extensions
1129 ("py.ext", -1, r"Software\Classes\."+ext, "",
1130 "Python.File", "REGISTRY.def"),
1131 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1132 "Python.NoConFile", "REGISTRY.def"),
1133 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1134 "Python.CompiledFile", "REGISTRY.def"),
1135 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1136 "Python.CompiledFile", "REGISTRY.def"),
1137 # MIME types
1138 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1139 "text/plain", "REGISTRY.def"),
1140 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1141 "text/plain", "REGISTRY.def"),
1142 #Verbs
1143 ("py.open", -1, pat % (testprefix, "", "open"), "",
1144 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1145 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1146 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1147 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1148 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001149 ] + tcl_verbs + [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001150 #Icons
1151 ("py.icon", -1, pat2 % (testprefix, ""), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001152 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001153 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001154 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001155 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001156 r'[DLLs]pyc.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001157 # Descriptions
1158 ("py.txt", -1, pat3 % (testprefix, ""), "",
1159 "Python File", "REGISTRY.def"),
1160 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1161 "Python File (no console)", "REGISTRY.def"),
1162 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1163 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001164 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001165
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001166 # Registry keys
1167 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1168 add_data(db, "Registry",
1169 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1170 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1171 "Python %s" % short_version, "REGISTRY"),
1172 ("PythonPath", -1, prefix+r"\PythonPath", "",
Martin v. Löwisf13337d2004-09-19 18:36:45 +00001173 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001174 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001175 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001176 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1177 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1178 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1179 ])
1180 # Shortcuts, see "Shortcut Table"
1181 add_data(db, "Directory",
1182 [("ProgramMenuFolder", "TARGETDIR", "."),
1183 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1184 add_data(db, "RemoveFile",
1185 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001186 tcltkshortcuts = []
1187 if have_tcl:
1188 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001189 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001190 tcltk.id, r'"[TARGETDIR]Lib\idlelib\idle.pyw"', None, None, "python_icon.exe", 0, None, "TARGETDIR"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001191 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001192 tcltk.id, r'"[TARGETDIR]Tools\scripts\pydocgui.pyw"', None, None, "python_icon.exe", 0, None, "TARGETDIR"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001193 ]
1194 add_data(db, "Shortcut",
1195 tcltkshortcuts +
1196 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001197 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1198 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001199 # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an
1200 # icon first.
1201 #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1202 # htmlfiles.id, None, None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001203 ## Non-advertised shortcuts: must be associated with a registry component
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001204 ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
1205 "[#Python%s%s.chm]" % (major,minor), None,
1206 None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001207 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1208 SystemFolderName+"msiexec", "/x%s" % product_code,
1209 None, None, None, None, None, None),
1210 ])
1211 db.Commit()
1212
1213db = build_database()
1214try:
1215 add_features(db)
1216 add_ui(db)
1217 add_files(db)
1218 add_registry(db)
1219 remove_old_versions(db)
1220 db.Commit()
1221finally:
1222 del db