blob: f3e2e7fcb083e5f11624244cca29f529e8cb8d8f [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 +000032#MSVCR = "71"
33MSVCR = "90"
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000034
35try:
36 from config import *
37except ImportError:
38 pass
39
40# Extract current version from Include/patchlevel.h
41lines = open(srcdir + "/Include/patchlevel.h").readlines()
42major = minor = micro = level = serial = None
43levels = {
44 'PY_RELEASE_LEVEL_ALPHA':0xA,
45 'PY_RELEASE_LEVEL_BETA': 0xB,
46 'PY_RELEASE_LEVEL_GAMMA':0xC,
47 'PY_RELEASE_LEVEL_FINAL':0xF
48 }
49for l in lines:
50 if not l.startswith("#define"):
51 continue
52 l = l.split()
53 if len(l) != 3:
54 continue
55 _, name, value = l
56 if name == 'PY_MAJOR_VERSION': major = value
57 if name == 'PY_MINOR_VERSION': minor = value
58 if name == 'PY_MICRO_VERSION': micro = value
59 if name == 'PY_RELEASE_LEVEL': level = levels[value]
60 if name == 'PY_RELEASE_SERIAL': serial = value
61
62short_version = major+"."+minor
63# See PC/make_versioninfo.c
64FIELD3 = 1000*int(micro) + 10*level + int(serial)
65current_version = "%s.%d" % (short_version, FIELD3)
66
67# This should never change. The UpgradeCode of this package can be
68# used in the Upgrade table of future packages to make the future
69# package replace this one. See "UpgradeCode Property".
70upgrade_code_snapshot='{92A24481-3ECB-40FC-8836-04B7966EC0D5}'
71upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}'
72
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000073if snapshot:
74 current_version = "%s.%s.%s" % (major, minor, int(time.time()/3600/24))
75 product_code = msilib.gen_uuid()
76else:
77 product_code = product_codes[current_version]
78
79if full_current_version is None:
80 full_current_version = current_version
81
82extensions = [
83 'bz2.pyd',
84 'pyexpat.pyd',
85 'select.pyd',
86 'unicodedata.pyd',
87 'winsound.pyd',
Trent Micke97e5a72005-12-15 22:08:46 +000088 '_elementtree.pyd',
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000089 '_bsddb.pyd',
90 '_socket.pyd',
91 '_ssl.pyd',
92 '_testcapi.pyd',
93 '_tkinter.pyd',
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +000094 '_msi.pyd',
Martin v. Löwisa09655e2006-03-10 15:36:28 +000095 '_ctypes.pyd',
Martin v. Löwis1a494bd2006-04-04 07:10:59 +000096 '_ctypes_test.pyd',
Martin v. Löwisa09fd6e2006-08-16 12:55:10 +000097 '_sqlite3.pyd',
98 '_hashlib.pyd'
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000099]
100
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000101# Well-known component UUIDs
102# These are needed for SharedDLLs reference counter; if
103# a different UUID was used for each incarnation of, say,
104# python24.dll, an upgrade would set the reference counter
105# from 1 to 2 (due to what I consider a bug in MSI)
106# Using the same UUID is fine since these files are versioned,
107# so Installer will always keep the newest version.
Christian Heimes9acba042007-12-04 14:57:30 +0000108# NOTE: All uuids are self generated.
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000109msvcr71_uuid = "{8666C8DD-D0B4-4B42-928E-A69E32FA5D4D}"
Christian Heimes9acba042007-12-04 14:57:30 +0000110msvcr90_uuid = "{9C28CD84-397C-4045-855C-28B02291A272}"
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000111pythondll_uuid = {
112 "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}",
Martin v. Löwis5409c8d2007-08-30 18:15:22 +0000113 "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}",
Martin v. Löwisbe7abbb2007-08-14 05:01:50 +0000114 "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}",
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000115 } [major+minor]
Tim Peterseba28be2005-03-28 01:08:02 +0000116
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000117# Build the mingw import library, libpythonXY.a
118# This requires 'nm' and 'dlltool' executables on your PATH
119def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
120 warning = "WARNING: %s - libpythonXX.a not built"
121 nm = find_executable('nm')
122 dlltool = find_executable('dlltool')
123
124 if not nm or not dlltool:
125 print warning % "nm and/or dlltool were not found"
126 return False
127
128 nm_command = '%s -Cs %s' % (nm, lib_file)
129 dlltool_command = "%s --dllname %s --def %s --output-lib %s" % \
130 (dlltool, dll_file, def_file, mingw_lib)
131 export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match
132
133 f = open(def_file,'w')
134 print >>f, "LIBRARY %s" % dll_file
135 print >>f, "EXPORTS"
136
137 nm_pipe = os.popen(nm_command)
138 for line in nm_pipe.readlines():
139 m = export_match(line)
140 if m:
141 print >>f, m.group(1)
142 f.close()
143 exit = nm_pipe.close()
144
145 if exit:
146 print warning % "nm did not run successfully"
147 return False
148
149 if os.system(dlltool_command) != 0:
150 print warning % "dlltool did not run successfully"
151 return False
152
153 return True
154
155# Target files (.def and .a) go in PCBuild directory
Christian Heimes9acba042007-12-04 14:57:30 +0000156lib_file = os.path.join(srcdir, PCBUILD, "python%s%s.lib" % (major, minor))
157def_file = os.path.join(srcdir, PCBUILD, "python%s%s.def" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000158dll_file = "python%s%s.dll" % (major, minor)
Christian Heimes9acba042007-12-04 14:57:30 +0000159mingw_lib = os.path.join(srcdir, PCBUILD, "libpython%s%s.a" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000160
161have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
162
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000163# Determine the target architechture
Christian Heimes9acba042007-12-04 14:57:30 +0000164dll_path = os.path.join(srcdir, PCBUILD, dll_file)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000165msilib.set_arch_from_file(dll_path)
166if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
167 raise SystemError, "msisupport.dll for incorrect architecture"
168
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000169if testpackage:
170 ext = 'px'
171 testprefix = 'x'
172else:
173 ext = 'py'
174 testprefix = ''
175
176if msilib.Win64:
Martin v. Löwis75c23bd2007-08-30 18:25:47 +0000177 SystemFolderName = "[System64Folder]"
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +0000178 registry_component = 4|256
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000179else:
180 SystemFolderName = "[SystemFolder]"
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +0000181 registry_component = 4
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000182
183msilib.reset()
184
185# condition in which to install pythonxy.dll in system32:
186# a) it is Windows 9x or
187# b) it is NT, the user is privileged, and has chosen per-machine installation
188sys32cond = "(Windows9x or (Privileged and ALLUSERS))"
189
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000190def build_database():
191 """Generate an empty database, with just the schema and the
192 Summary information stream."""
193 if snapshot:
194 uc = upgrade_code_snapshot
195 else:
196 uc = upgrade_code
197 # schema represents the installer 2.0 database schema.
198 # sequence is the set of standard sequences
199 # (ui/execute, admin/advt/install)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000200 db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000201 schema, ProductName="Python "+full_current_version,
202 ProductCode=product_code,
203 ProductVersion=current_version,
Martin v. Löwis8bc77e42007-09-01 06:36:03 +0000204 Manufacturer=u"Python Software Foundation")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000205 # The default sequencing of the RemoveExistingProducts action causes
206 # removal of files that got just installed. Place it after
207 # InstallInitialize, so we first uninstall everything, but still roll
208 # back in case the installation is interrupted
209 msilib.change_sequence(sequence.InstallExecuteSequence,
210 "RemoveExistingProducts", 1510)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000211 msilib.add_tables(db, sequence)
212 # We cannot set ALLUSERS in the property table, as this cannot be
213 # reset if the user choses a per-user installation. Instead, we
214 # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages
215 # this property, and when the execution starts, ALLUSERS is set
216 # accordingly.
217 add_data(db, "Property", [("UpgradeCode", uc),
218 ("WhichUsers", "ALL"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000219 ("ProductLine", "Python%s%s" % (major, minor)),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000220 ])
221 db.Commit()
222 return db
223
224def remove_old_versions(db):
225 "Fill the upgrade table."
226 start = "%s.%s.0" % (major, minor)
227 # This requests that feature selection states of an older
228 # installation should be forwarded into this one. Upgrading
229 # requires that both the old and the new installation are
230 # either both per-machine or per-user.
231 migrate_features = 1
232 # See "Upgrade Table". We remove releases with the same major and
233 # minor version. For an snapshot, we remove all earlier snapshots. For
234 # a release, we remove all snapshots, and all earlier releases.
235 if snapshot:
236 add_data(db, "Upgrade",
Tim Peters66cb0182004-08-26 05:23:19 +0000237 [(upgrade_code_snapshot, start,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000238 current_version,
239 None, # Ignore language
Tim Peters66cb0182004-08-26 05:23:19 +0000240 migrate_features,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000241 None, # Migrate ALL features
242 "REMOVEOLDSNAPSHOT")])
243 props = "REMOVEOLDSNAPSHOT"
244 else:
245 add_data(db, "Upgrade",
246 [(upgrade_code, start, current_version,
247 None, migrate_features, None, "REMOVEOLDVERSION"),
248 (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1),
249 None, migrate_features, None, "REMOVEOLDSNAPSHOT")])
250 props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION"
251 # Installer collects the product codes of the earlier releases in
252 # these properties. In order to allow modification of the properties,
253 # they must be declared as secure. See "SecureCustomProperties Property"
254 add_data(db, "Property", [("SecureCustomProperties", props)])
255
256class PyDialog(Dialog):
257 """Dialog class with a fixed layout: controls at the top, then a ruler,
258 then a list of buttons: back, next, cancel. Optionally a bitmap at the
259 left."""
260 def __init__(self, *args, **kw):
261 """Dialog(database, name, x, y, w, h, attributes, title, first,
262 default, cancel, bitmap=true)"""
263 Dialog.__init__(self, *args)
264 ruler = self.h - 36
265 bmwidth = 152*ruler/328
266 if kw.get("bitmap", True):
267 self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
268 self.line("BottomLine", 0, ruler, self.w, 0)
269
270 def title(self, title):
271 "Set the title text of the dialog at the top."
272 # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
273 # text, in VerdanaBold10
274 self.text("Title", 135, 10, 220, 60, 0x30003,
275 r"{\VerdanaBold10}%s" % title)
276
277 def back(self, title, next, name = "Back", active = 1):
278 """Add a back button with a given title, the tab-next button,
279 its name in the Control table, possibly initially disabled.
280
281 Return the button, so that events can be associated"""
282 if active:
283 flags = 3 # Visible|Enabled
284 else:
285 flags = 1 # Visible
286 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
287
288 def cancel(self, title, next, name = "Cancel", active = 1):
289 """Add a cancel button with a given title, the tab-next button,
290 its name in the Control table, possibly initially disabled.
291
292 Return the button, so that events can be associated"""
293 if active:
294 flags = 3 # Visible|Enabled
295 else:
296 flags = 1 # Visible
297 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
298
299 def next(self, title, next, name = "Next", active = 1):
300 """Add a Next button with a given title, the tab-next button,
301 its name in the Control table, possibly initially disabled.
302
303 Return the button, so that events can be associated"""
304 if active:
305 flags = 3 # Visible|Enabled
306 else:
307 flags = 1 # Visible
308 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
309
310 def xbutton(self, name, title, next, xpos):
311 """Add a button with a given title, the tab-next button,
312 its name in the Control table, giving its x position; the
313 y-position is aligned with the other buttons.
314
315 Return the button, so that events can be associated"""
316 return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
317
318def add_ui(db):
319 x = y = 50
320 w = 370
321 h = 300
322 title = "[ProductName] Setup"
323
324 # see "Dialog Style Bits"
325 modal = 3 # visible | modal
326 modeless = 1 # visible
327 track_disk_space = 32
328
329 add_data(db, 'ActionText', uisample.ActionText)
330 add_data(db, 'UIText', uisample.UIText)
331
332 # Bitmaps
333 if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
334 raise "Run icons.mak in PC directory"
335 add_data(db, "Binary",
Christian Heimes7e28e492008-01-01 13:52:57 +0000336 [("PythonWin", msilib.Binary(r"%s\PCbuild\installer.bmp" % srcdir)), # 152x328 pixels
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000337 ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
338 ])
339 add_data(db, "Icon",
340 [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))])
341
342 # Scripts
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000343 # CheckDir sets TargetExists if TARGETDIR exists.
344 # UpdateEditIDLE sets the REGISTRY.tcl component into
345 # the installed/uninstalled state according to both the
346 # Extensions and TclTk features.
Martin v. Löwiseb68be42004-12-12 15:29:21 +0000347 if os.system("nmake /nologo /c /f msisupport.mak") != 0:
348 raise "'nmake /f msisupport.mak' failed"
349 add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
350 # See "Custom Action Type 1"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000351 if msilib.Win64:
352 CheckDir = "CheckDir"
Martin v. Löwisdf40ce32006-02-16 14:38:30 +0000353 UpdateEditIDLE = "UpdateEditIDLE"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000354 else:
355 CheckDir = "_CheckDir@4"
356 UpdateEditIDLE = "_UpdateEditIDLE@4"
Tim Peters0e9980f2004-09-12 03:49:31 +0000357 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000358 [("CheckDir", 1, "Script", CheckDir)])
Martin v. Löwiseac02e62004-11-18 08:00:33 +0000359 if have_tcl:
360 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000361 [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)])
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000362
363 # UI customization properties
364 add_data(db, "Property",
365 # See "DefaultUIFont Property"
366 [("DefaultUIFont", "DlgFont8"),
367 # See "ErrorDialog Style Bit"
368 ("ErrorDialog", "ErrorDlg"),
369 ("Progress1", "Install"), # modified in maintenance type dlg
370 ("Progress2", "installs"),
371 ("MaintenanceForm_Action", "Repair")])
372
373 # Fonts, see "TextStyle Table"
374 add_data(db, "TextStyle",
375 [("DlgFont8", "Tahoma", 9, None, 0),
376 ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
377 ("VerdanaBold10", "Verdana", 10, None, 1),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000378 ("VerdanaRed9", "Verdana", 9, 255, 0),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000379 ])
380
Martin v. Löwis4cbd05c2006-07-06 07:05:21 +0000381 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 +0000382 # See "CustomAction Table"
383 add_data(db, "CustomAction", [
384 # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
385 # See "Custom Action Type 51",
386 # "Custom Action Execution Scheduling Options"
387 ("InitialTargetDir", 307, "TARGETDIR",
388 "[WindowsVolume]Python%s%s" % (major, minor)),
389 ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"),
390 ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName),
391 # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile
392 # See "Custom Action Type 18"
Martin v. Löwis7b2563b2004-11-02 22:59:56 +0000393 ("CompilePyc", 18, "python.exe", compileargs),
394 ("CompilePyo", 18, "python.exe", "-O "+compileargs),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000395 ])
396
397 # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
398 # Numbers indicate sequence; see sequence.py for how these action integrate
399 add_data(db, "InstallUISequence",
400 [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
401 ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
402 ("InitialTargetDir", 'TARGETDIR=""', 750),
403 # In the user interface, assume all-users installation if privileged.
404 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
405 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
406 ("SelectDirectoryDlg", "Not Installed", 1230),
407 # XXX no support for resume installations yet
408 #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
409 ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
410 ("ProgressDlg", None, 1280)])
411 add_data(db, "AdminUISequence",
412 [("InitialTargetDir", 'TARGETDIR=""', 750),
413 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
414 ])
415
416 # Execute Sequences
417 add_data(db, "InstallExecuteSequence",
418 [("InitialTargetDir", 'TARGETDIR=""', 750),
419 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
420 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000421 ("UpdateEditIDLE", None, 1050),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000422 ("CompilePyc", "COMPILEALL", 6800),
423 ("CompilePyo", "COMPILEALL", 6801),
424 ])
425 add_data(db, "AdminExecuteSequence",
426 [("InitialTargetDir", 'TARGETDIR=""', 750),
427 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
428 ("CompilePyc", "COMPILEALL", 6800),
429 ("CompilePyo", "COMPILEALL", 6801),
430 ])
431
432 #####################################################################
433 # Standard dialogs: FatalError, UserExit, ExitDialog
434 fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
435 "Finish", "Finish", "Finish")
436 fatal.title("[ProductName] Installer ended prematurely")
437 fatal.back("< Back", "Finish", active = 0)
438 fatal.cancel("Cancel", "Back", active = 0)
439 fatal.text("Description1", 135, 70, 220, 80, 0x30003,
440 "[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.")
441 fatal.text("Description2", 135, 155, 220, 20, 0x30003,
442 "Click the Finish button to exit the Installer.")
443 c=fatal.next("Finish", "Cancel", name="Finish")
444 # See "ControlEvent Table". Parameters are the event, the parameter
445 # to the action, and optionally the condition for the event, and the order
446 # of events.
447 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000448
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000449 user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
450 "Finish", "Finish", "Finish")
451 user_exit.title("[ProductName] Installer was interrupted")
452 user_exit.back("< Back", "Finish", active = 0)
453 user_exit.cancel("Cancel", "Back", active = 0)
454 user_exit.text("Description1", 135, 70, 220, 80, 0x30003,
455 "[ProductName] setup was interrupted. Your system has not been modified. "
456 "To install this program at a later time, please run the installation again.")
457 user_exit.text("Description2", 135, 155, 220, 20, 0x30003,
458 "Click the Finish button to exit the Installer.")
459 c = user_exit.next("Finish", "Cancel", name="Finish")
460 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000461
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000462 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
463 "Finish", "Finish", "Finish")
464 exit_dialog.title("Completing the [ProductName] Installer")
465 exit_dialog.back("< Back", "Finish", active = 0)
466 exit_dialog.cancel("Cancel", "Back", active = 0)
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000467 exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003,
468 "Special Windows thanks to:\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000469 " Mark Hammond, without whose years of freely \n"
470 " shared Windows expertise, Python for Windows \n"
471 " would still be Python for DOS.")
Tim Peters66cb0182004-08-26 05:23:19 +0000472
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000473 c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003,
474 "{\\VerdanaRed9}Warning: Python 2.5.x is the last "
475 "Python release for Windows 9x.")
Martin v. Löwisdf511792006-03-28 07:51:51 +0000476 c.condition("Hide", "NOT Version9X")
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000477
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000478 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000479 "Click the Finish button to exit the Installer.")
480 c = exit_dialog.next("Finish", "Cancel", name="Finish")
481 c.event("EndDialog", "Return")
482
483 #####################################################################
484 # Required dialog: FilesInUse, ErrorDlg
485 inuse = PyDialog(db, "FilesInUse",
486 x, y, w, h,
487 19, # KeepModeless|Modal|Visible
488 title,
489 "Retry", "Retry", "Retry", bitmap=False)
490 inuse.text("Title", 15, 6, 200, 15, 0x30003,
491 r"{\DlgFontBold8}Files in Use")
492 inuse.text("Description", 20, 23, 280, 20, 0x30003,
493 "Some files that need to be updated are currently in use.")
494 inuse.text("Text", 20, 55, 330, 50, 3,
495 "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.")
496 inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
497 None, None, None)
498 c=inuse.back("Exit", "Ignore", name="Exit")
499 c.event("EndDialog", "Exit")
500 c=inuse.next("Ignore", "Retry", name="Ignore")
501 c.event("EndDialog", "Ignore")
502 c=inuse.cancel("Retry", "Exit", name="Retry")
503 c.event("EndDialog","Retry")
504
505
506 # See "Error Dialog". See "ICE20" for the required names of the controls.
507 error = Dialog(db, "ErrorDlg",
508 50, 10, 330, 101,
509 65543, # Error|Minimize|Modal|Visible
510 title,
511 "ErrorText", None, None)
512 error.text("ErrorText", 50,9,280,48,3, "")
513 error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
514 error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
515 error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
516 error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
517 error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
518 error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
519 error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
520 error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
521
522 #####################################################################
523 # Global "Query Cancel" dialog
524 cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
525 "No", "No", "No")
Tim Peters66cb0182004-08-26 05:23:19 +0000526 cancel.text("Text", 48, 15, 194, 30, 3,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000527 "Are you sure you want to cancel [ProductName] installation?")
528 cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
529 "py.ico", None, None)
530 c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
531 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000532
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000533 c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
534 c.event("EndDialog", "Return")
535
536 #####################################################################
537 # Global "Wait for costing" dialog
538 costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
539 "Return", "Return", "Return")
540 costing.text("Text", 48, 15, 194, 30, 3,
541 "Please wait while the installer finishes determining your disk space requirements.")
542 costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
543 "py.ico", None, None)
544 c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
545 c.event("EndDialog", "Exit")
546
547 #####################################################################
548 # Preparation dialog: no user input except cancellation
549 prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
550 "Cancel", "Cancel", "Cancel")
551 prep.text("Description", 135, 70, 220, 40, 0x30003,
552 "Please wait while the Installer prepares to guide you through the installation.")
553 prep.title("Welcome to the [ProductName] Installer")
554 c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...")
555 c.mapping("ActionText", "Text")
556 c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None)
557 c.mapping("ActionData", "Text")
558 prep.back("Back", None, active=0)
559 prep.next("Next", None, active=0)
560 c=prep.cancel("Cancel", None)
561 c.event("SpawnDialog", "CancelDlg")
562
563 #####################################################################
564 # Target directory selection
565 seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
566 "Next", "Next", "Cancel")
567 seldlg.title("Select Destination Directory")
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000568 c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003,
569 "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.")
570 c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""')
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000571 seldlg.text("Description", 135, 50, 220, 40, 0x30003,
572 "Please select a directory for the [ProductName] files.")
573
574 seldlg.back("< Back", None, active=0)
575 c = seldlg.next("Next >", "Cancel")
576 c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1)
577 # If the target exists, but we found that we are going to remove old versions, don't bother
578 # confirming that the target directory exists. Strictly speaking, we should determine that
579 # the target directory is indeed the target of the product that we are going to remove, but
580 # I don't know how to do that.
581 c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2)
582 c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3)
583 c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4)
584 c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5)
585
586 c = seldlg.cancel("Cancel", "DirectoryCombo")
587 c.event("SpawnDialog", "CancelDlg")
588
589 seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219,
590 "TARGETDIR", None, "DirectoryList", None)
591 seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR",
592 None, "PathEdit", None)
593 seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None)
594 c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
595 c.event("DirectoryListUp", "0")
596 c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
597 c.event("DirectoryListNew", "0")
598
599 #####################################################################
600 # SelectFeaturesDlg
601 features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space,
602 title, "Tree", "Next", "Cancel")
603 features.title("Customize [ProductName]")
604 features.text("Description", 135, 35, 220, 15, 0x30003,
605 "Select the way you want features to be installed.")
606 features.text("Text", 135,45,220,30, 3,
607 "Click on the icons in the tree below to change the way features will be installed.")
608
609 c=features.back("< Back", "Next")
610 c.event("NewDialog", "SelectDirectoryDlg")
611
612 c=features.next("Next >", "Cancel")
613 c.mapping("SelectionNoItems", "Enabled")
614 c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1)
615 c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2)
616
617 c=features.cancel("Cancel", "Tree")
618 c.event("SpawnDialog", "CancelDlg")
619
Tim Peters66cb0182004-08-26 05:23:19 +0000620 # 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 +0000621 features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty",
622 "Tree of selections", "Back", None)
623
624 #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost")
625 #c.mapping("SelectionNoItems", "Enabled")
626 #c.event("Reset", "0")
Tim Peters66cb0182004-08-26 05:23:19 +0000627
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000628 features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None)
629
630 c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10)
631 c.mapping("SelectionNoItems","Enabled")
632 c.event("SpawnDialog", "DiskCostDlg")
633
634 c=features.xbutton("Advanced", "Advanced", None, 0.30)
635 c.event("SpawnDialog", "AdvancedDlg")
636
637 c=features.text("ItemDescription", 140, 180, 210, 30, 3,
638 "Multiline description of the currently selected item.")
639 c.mapping("SelectionDescription","Text")
Tim Peters66cb0182004-08-26 05:23:19 +0000640
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000641 c=features.text("ItemSize", 140, 210, 210, 45, 3,
642 "The size of the currently selected item.")
643 c.mapping("SelectionSize", "Text")
644
645 #####################################################################
646 # Disk cost
647 cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
648 "OK", "OK", "OK", bitmap=False)
649 cost.text("Title", 15, 6, 200, 15, 0x30003,
650 "{\DlgFontBold8}Disk Space Requirements")
651 cost.text("Description", 20, 20, 280, 20, 0x30003,
652 "The disk space required for the installation of the selected features.")
653 cost.text("Text", 20, 53, 330, 60, 3,
654 "The highlighted volumes (if any) do not have enough disk space "
655 "available for the currently selected features. You can either "
656 "remove some files from the highlighted volumes, or choose to "
657 "install less features onto local drive(s), or select different "
658 "destination drive(s).")
659 cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
660 None, "{120}{70}{70}{70}{70}", None, None)
661 cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
662
663 #####################################################################
664 # WhichUsers Dialog. Only available on NT, and for privileged users.
665 # This must be run before FindRelatedProducts, because that will
666 # take into account whether the previous installation was per-user
667 # or per-machine. We currently don't support going back to this
668 # dialog after "Next" was selected; to support this, we would need to
669 # find how to reset the ALLUSERS property, and how to re-run
670 # FindRelatedProducts.
671 # On Windows9x, the ALLUSERS property is ignored on the command line
672 # and in the Property table, but installer fails according to the documentation
673 # if a dialog attempts to set ALLUSERS.
674 whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
675 "AdminInstall", "Next", "Cancel")
676 whichusers.title("Select whether to install [ProductName] for all users of this computer.")
677 # A radio group with two options: allusers, justme
678 g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3,
679 "WhichUsers", "", "Next")
680 g.add("ALL", 0, 5, 150, 20, "Install for all users")
681 g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
682
Tim Peters66cb0182004-08-26 05:23:19 +0000683 whichusers.back("Back", None, active=0)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000684
685 c = whichusers.next("Next >", "Cancel")
686 c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
687 c.event("EndDialog", "Return", order = 2)
688
689 c = whichusers.cancel("Cancel", "AdminInstall")
690 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000691
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000692 #####################################################################
693 # Advanced Dialog.
694 advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
695 "CompilePyc", "Next", "Cancel")
696 advanced.title("Advanced Options for [ProductName]")
697 # A radio group with two options: allusers, justme
698 advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
699 "COMPILEALL", "Compile .py files to byte code after installation", "Next")
700
701 c = advanced.next("Finish", "Cancel")
702 c.event("EndDialog", "Return")
703
704 c = advanced.cancel("Cancel", "CompilePyc")
705 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000706
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000707 #####################################################################
Tim Peters66cb0182004-08-26 05:23:19 +0000708 # Existing Directory dialog
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000709 dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
710 "No", "No", "No")
711 dlg.text("Title", 10, 20, 180, 40, 3,
712 "[TARGETDIR] exists. Are you sure you want to overwrite existing files?")
713 c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No")
714 c.event("[TargetExists]", "0", order=1)
715 c.event("[TargetExistsOk]", "1", order=2)
716 c.event("EndDialog", "Return", order=3)
717 c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes")
718 c.event("EndDialog", "Return")
719
720 #####################################################################
721 # Installation Progress dialog (modeless)
722 progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
723 "Cancel", "Cancel", "Cancel", bitmap=False)
724 progress.text("Title", 20, 15, 200, 15, 0x30003,
725 "{\DlgFontBold8}[Progress1] [ProductName]")
726 progress.text("Text", 35, 65, 300, 30, 3,
727 "Please wait while the Installer [Progress2] [ProductName]. "
728 "This may take several minutes.")
729 progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
730
731 c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
732 c.mapping("ActionText", "Text")
733
734 #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
735 #c.mapping("ActionData", "Text")
736
737 c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
738 None, "Progress done", None, None)
739 c.mapping("SetProgress", "Progress")
740
741 progress.back("< Back", "Next", active=False)
742 progress.next("Next >", "Cancel", active=False)
743 progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
744
745 # Maintenance type: repair/uninstall
746 maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
747 "Next", "Next", "Cancel")
748 maint.title("Welcome to the [ProductName] Setup Wizard")
749 maint.text("BodyText", 135, 63, 230, 42, 3,
750 "Select whether you want to repair or remove [ProductName].")
751 g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3,
752 "MaintenanceForm_Action", "", "Next")
753 g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
754 g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
755 g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
Tim Peters66cb0182004-08-26 05:23:19 +0000756
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000757 maint.back("< Back", None, active=False)
758 c=maint.next("Finish", "Cancel")
759 # Change installation: Change progress dialog to "Change", then ask
760 # for feature selection
761 c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
762 c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
763
764 # Reinstall: Change progress dialog to "Repair", then invoke reinstall
765 # Also set list of reinstalled features to "ALL"
766 c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
767 c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
Raymond Hettinger72f08012004-11-07 07:08:25 +0000768 c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000769 c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
770
771 # Uninstall: Change progress to "Remove", then invoke uninstall
772 # Also set list of removed features to "ALL"
773 c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
774 c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
775 c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
776 c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
777
Tim Peters66cb0182004-08-26 05:23:19 +0000778 # Close dialog when maintenance action scheduled
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000779 c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
780 c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
Tim Peters66cb0182004-08-26 05:23:19 +0000781
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000782 maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000783
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000784
785# See "Feature Table". The feature level is 1 for all features,
786# and the feature attributes are 0 for the DefaultFeature, and
787# FollowParent for all other features. The numbers are the Display
788# column.
789def add_features(db):
790 # feature attributes:
791 # msidbFeatureAttributesFollowParent == 2
792 # msidbFeatureAttributesDisallowAdvertise == 8
793 # Features that need to be installed with together with the main feature
794 # (i.e. additional Python libraries) need to follow the parent feature.
795 # Features that have no advertisement trigger (e.g. the test suite)
796 # must not support advertisement
797 global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature
798 default_feature = Feature(db, "DefaultFeature", "Python",
799 "Python Interpreter and Libraries",
800 1, directory = "TARGETDIR")
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000801 # We don't support advertisement of extensions
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000802 ext_feature = Feature(db, "Extensions", "Register Extensions",
803 "Make this Python installation the default Python installation", 3,
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000804 parent = default_feature, attributes=2|8)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000805 if have_tcl:
806 tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000807 parent = default_feature, attributes=2)
808 htmlfiles = Feature(db, "Documentation", "Documentation",
809 "Python HTMLHelp File", 7, parent = default_feature)
810 tools = Feature(db, "Tools", "Utility Scripts",
Tim Peters66cb0182004-08-26 05:23:19 +0000811 "Python utility scripts (Tools/", 9,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000812 parent = default_feature, attributes=2)
813 testsuite = Feature(db, "Testsuite", "Test suite",
814 "Python test suite (Lib/test/)", 11,
815 parent = default_feature, attributes=2|8)
Tim Peters66cb0182004-08-26 05:23:19 +0000816
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000817def extract_msvcr71():
818 import _winreg
819 # Find the location of the merge modules
820 k = _winreg.OpenKey(
821 _winreg.HKEY_LOCAL_MACHINE,
822 r"Software\Microsoft\VisualStudio\7.1\Setup\VS")
823 dir = _winreg.QueryValueEx(k, "MSMDir")[0]
824 _winreg.CloseKey(k)
825 files = glob.glob1(dir, "*CRT71*")
Christian Heimes9acba042007-12-04 14:57:30 +0000826 assert len(files) == 1, (dir, files)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000827 file = os.path.join(dir, files[0])
828 # Extract msvcr71.dll
829 m = msilib.MakeMerge2()
830 m.OpenModule(file, 0)
831 m.ExtractFiles(".")
832 m.CloseModule()
833 # Find the version/language of msvcr71.dll
834 installer = msilib.MakeInstaller()
835 return installer.FileVersion("msvcr71.dll", 0), \
836 installer.FileVersion("msvcr71.dll", 1)
837
Christian Heimes9acba042007-12-04 14:57:30 +0000838def extract_msvcr90():
Martin v. Löwis03dc56c2008-02-28 22:20:50 +0000839 # Find the redistributable files
840 dir = os.path.join(os.environ['VS90COMNTOOLS'], r"..\..\VC\redist\x86\Microsoft.VC90.CRT")
Christian Heimes9acba042007-12-04 14:57:30 +0000841
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000842 result = []
Christian Heimes9acba042007-12-04 14:57:30 +0000843 installer = msilib.MakeInstaller()
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000844 # omit msvcm90 and msvcp90, as they aren't really needed
845 files = ["Microsoft.VC90.CRT.manifest", "msvcr90.dll"]
846 for f in files:
847 path = os.path.join(dir, f)
848 kw = {'src':path}
849 if f.endswith('.dll'):
850 kw['version'] = installer.FileVersion(path, 0)
851 kw['language'] = installer.FileVersion(path, 1)
852 result.append((f, kw))
853 return result
Christian Heimes9acba042007-12-04 14:57:30 +0000854
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000855class PyDirectory(Directory):
856 """By default, all components in the Python installer
857 can run from source."""
858 def __init__(self, *args, **kw):
859 if not kw.has_key("componentflags"):
860 kw['componentflags'] = 2 #msidbComponentAttributesOptional
861 Directory.__init__(self, *args, **kw)
862
863# See "File Table", "Component Table", "Directory Table",
864# "FeatureComponents Table"
865def add_files(db):
866 cab = CAB("python")
867 tmpfiles = []
868 # Add all executables, icons, text files into the TARGETDIR component
869 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
870 default_feature.set_current()
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000871 if not msilib.Win64:
Christian Heimes9acba042007-12-04 14:57:30 +0000872 root.add_file("%s/w9xpopen.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000873 root.add_file("README.txt", src="README")
874 root.add_file("NEWS.txt", src="Misc/NEWS")
875 root.add_file("LICENSE.txt", src="LICENSE")
876 root.start_component("python.exe", keyfile="python.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000877 root.add_file("%s/python.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000878 root.start_component("pythonw.exe", keyfile="pythonw.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000879 root.add_file("%s/pythonw.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000880
881 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000882 #dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
883 #install python30.dll into root dir for now
884 dlldir = root
885
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000886 pydll = "python%s%s.dll" % (major, minor)
Christian Heimes9acba042007-12-04 14:57:30 +0000887 pydllsrc = os.path.join(srcdir, PCBUILD, pydll)
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000888 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000889 installer = msilib.MakeInstaller()
890 pyversion = installer.FileVersion(pydllsrc, 0)
891 if not snapshot:
892 # For releases, the Python DLL has the same version as the
893 # installer package.
894 assert pyversion.split(".")[:3] == current_version.split(".")
Christian Heimes9acba042007-12-04 14:57:30 +0000895 dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000896 version=pyversion,
897 language=installer.FileVersion(pydllsrc, 1))
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000898 DLLs = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000899 # XXX determine dependencies
Christian Heimes9acba042007-12-04 14:57:30 +0000900 if MSVCR == "90":
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000901 root.start_component("msvcr90")
902 for file, kw in extract_msvcr90():
903 root.add_file(file, **kw)
904 if file.endswith("manifest"):
905 DLLs.add_file(file, **kw)
Christian Heimes9acba042007-12-04 14:57:30 +0000906 else:
907 version, lang = extract_msvcr71()
908 dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll",
909 uuid=msvcr71_uuid)
910 dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
911 version=version, language=lang)
912 tmpfiles.append("msvcr71.dll")
913
Tim Peters66cb0182004-08-26 05:23:19 +0000914
Martin v. Löwis38325b72006-08-25 00:03:34 +0000915 # Check if _ctypes.pyd exists
Christian Heimes9acba042007-12-04 14:57:30 +0000916 have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
Martin v. Löwis38325b72006-08-25 00:03:34 +0000917 if not have_ctypes:
918 print "WARNING: _ctypes.pyd not found, ctypes will not be included"
919 extensions.remove("_ctypes.pyd")
Tim Peters147f9ae2006-08-25 22:05:39 +0000920
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000921 # Add all .py files in Lib, except lib-tk, test
922 dirs={}
923 pydirs = [(root,"Lib")]
924 while pydirs:
925 parent, dir = pydirs.pop()
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000926 if dir == ".svn" or dir.startswith("plat-"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000927 continue
928 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000929 if not have_tcl:
930 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000931 tcltk.set_current()
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000932 elif dir in ['test', 'tests', 'data', 'output']:
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000933 # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000934 # tests: Lib/distutils
935 # data: Lib/email/test
936 # output: Lib/test
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000937 testsuite.set_current()
Martin v. Löwis38325b72006-08-25 00:03:34 +0000938 elif not have_ctypes and dir == "ctypes":
939 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000940 else:
941 default_feature.set_current()
942 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
943 # Add additional files
944 dirs[dir]=lib
945 lib.glob("*.txt")
946 if dir=='site-packages':
Martin v. Löwis6d60c092004-11-21 10:16:26 +0000947 lib.add_file("README.txt", src="README")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000948 continue
949 files = lib.glob("*.py")
950 files += lib.glob("*.pyw")
951 if files:
952 # Add an entry to the RemoveFile table to remove bytecode files.
953 lib.remove_pyc()
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000954 if dir.endswith('.egg-info'):
955 lib.add_file('entry_points.txt')
956 lib.add_file('PKG-INFO')
957 lib.add_file('top_level.txt')
958 lib.add_file('zip-safe')
959 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000960 if dir=='test' and parent.physical=='Lib':
961 lib.add_file("185test.db")
962 lib.add_file("audiotest.au")
963 lib.add_file("cfgparser.1")
Martin v. Löwisc0fdb182006-09-12 19:49:20 +0000964 lib.add_file("sgml_input.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000965 lib.add_file("test.xml")
966 lib.add_file("test.xml.out")
967 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000968 lib.add_file("test_difflib_expect.html")
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000969 lib.add_file("check_soundcard.vbs")
Thomas Heller3bd33152006-04-04 18:41:13 +0000970 lib.add_file("empty.vbs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000971 lib.glob("*.uue")
Martin v. Löwis0ffdacd2007-11-20 02:46:02 +0000972 lib.glob("*.pem")
Martin v. Löwis6b449f42007-12-03 19:20:02 +0000973 lib.glob("*.pck")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000974 lib.add_file("readme.txt", src="README")
975 if dir=='decimaltestdata':
976 lib.glob("*.decTest")
977 if dir=='output':
978 lib.glob("test_*")
979 if dir=='idlelib':
980 lib.glob("*.def")
981 lib.add_file("idle.bat")
982 if dir=="Icons":
983 lib.glob("*.gif")
984 lib.add_file("idle.icns")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000985 if dir=="command" and parent.physical=="distutils":
Christian Heimes7e28e492008-01-01 13:52:57 +0000986 lib.add_file("wininst-6.0.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000987 lib.add_file("wininst-7.1.exe")
Christian Heimes7e28e492008-01-01 13:52:57 +0000988 lib.add_file("wininst-8.0.exe")
989 lib.add_file("wininst-9.0.exe")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000990 if dir=="setuptools":
991 lib.add_file("cli.exe")
992 lib.add_file("gui.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000993 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000994 # This should contain all non-.svn files listed in subversion
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000995 for f in os.listdir(lib.absolute):
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000996 if f.endswith(".txt") or f==".svn":continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000997 if f.endswith(".au") or f.endswith(".gif"):
998 lib.add_file(f)
999 else:
1000 print "WARNING: New file %s in email/test/data" % f
1001 for f in os.listdir(lib.absolute):
1002 if os.path.isdir(os.path.join(lib.absolute, f)):
1003 pydirs.append((lib, f))
1004 # Add DLLs
1005 default_feature.set_current()
Martin v. Löwisd9759c42008-02-28 19:57:34 +00001006 lib = DLLs
Christian Heimes7e28e492008-01-01 13:52:57 +00001007 lib.add_file("py.ico", src=srcdir+"/PC/py.ico")
Christian Heimese1c6af02008-01-01 13:58:16 +00001008 lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001009 dlls = []
1010 tclfiles = []
1011 for f in extensions:
1012 if f=="_tkinter.pyd":
1013 continue
Christian Heimes9acba042007-12-04 14:57:30 +00001014 if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001015 print "WARNING: Missing extension", f
1016 continue
1017 dlls.append(f)
1018 lib.add_file(f)
Martin v. Löwis88ef6372006-07-06 06:55:58 +00001019 # Add sqlite
1020 if msilib.msi_type=="Intel64;1033":
1021 sqlite_arch = "/ia64"
1022 elif msilib.msi_type=="x64;1033":
1023 sqlite_arch = "/amd64"
1024 else:
1025 sqlite_arch = ""
1026 lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001027 if have_tcl:
Christian Heimes9acba042007-12-04 14:57:30 +00001028 if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001029 print "WARNING: Missing _tkinter.pyd"
1030 else:
1031 lib.start_component("TkDLLs", tcltk)
1032 lib.add_file("_tkinter.pyd")
1033 dlls.append("_tkinter.pyd")
1034 tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
1035 for f in glob.glob1(tcldir, "*.dll"):
1036 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001037 # check whether there are any unknown extensions
Christian Heimes9acba042007-12-04 14:57:30 +00001038 for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001039 if f.endswith("_d.pyd"): continue # debug version
1040 if f in dlls: continue
1041 print "WARNING: Unknown extension", f
Tim Peters66cb0182004-08-26 05:23:19 +00001042
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001043 # Add headers
1044 default_feature.set_current()
1045 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
1046 lib.glob("*.h")
1047 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
1048 # Add import libraries
Christian Heimes9acba042007-12-04 14:57:30 +00001049 lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001050 for f in dlls:
1051 lib.add_file(f.replace('pyd','lib'))
1052 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +00001053 # Add the mingw-format library
1054 if have_mingw:
Tim Peters5a9fb3c2005-01-07 16:01:32 +00001055 lib.add_file('libpython%s%s.a' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001056 if have_tcl:
1057 # Add Tcl/Tk
1058 tcldirs = [(root, '../tcltk/lib', 'tcl')]
1059 tcltk.set_current()
1060 while tcldirs:
1061 parent, phys, dir = tcldirs.pop()
1062 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
1063 if not os.path.exists(lib.absolute):
1064 continue
1065 for f in os.listdir(lib.absolute):
1066 if os.path.isdir(os.path.join(lib.absolute, f)):
1067 tcldirs.append((lib, f, f))
1068 else:
1069 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001070 # Add tools
1071 tools.set_current()
1072 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
1073 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
1074 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1075 lib.glob("*.py")
1076 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1077 lib.remove_pyc()
1078 lib.glob("*.txt")
1079 if f == "pynche":
1080 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1081 x.glob("*.txt")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001082 if os.path.exists(os.path.join(lib.absolute, "README")):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001083 lib.add_file("README.txt", src="README")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001084 if f == 'Scripts':
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001085 if have_tcl:
1086 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1087 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001088 # Add documentation
1089 htmlfiles.set_current()
1090 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
1091 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
Martin v. Löwis8628f752007-09-10 10:21:22 +00001092 lib.add_file("Python%s%s.chm" % (major, minor), src="build/htmlhelp/pydoc.chm")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001093
1094 cab.commit(db)
1095
1096 for f in tmpfiles:
1097 os.unlink(f)
1098
1099# See "Registry Table", "Component Table"
1100def add_registry(db):
1101 # File extensions, associated with the REGISTRY.def component
1102 # IDLE verbs depend on the tcltk feature.
1103 # msidbComponentAttributesRegistryKeyPath = 4
1104 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001105 tcldata = []
1106 if have_tcl:
1107 tcldata = [
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001108 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001109 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001110 add_data(db, "Component",
1111 # msidbComponentAttributesRegistryKeyPath = 4
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001112 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001113 "InstallPath"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001114 ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001115 "Documentation"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001116 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001117 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001118 # See "FeatureComponents Table".
1119 # The association between TclTk and pythonw.exe is necessary to make ICE59
1120 # happy, because the installer otherwise believes that the IDLE and PyDoc
1121 # shortcuts might get installed without pythonw.exe being install. This
1122 # is not true, since installing TclTk will install the default feature, which
1123 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001124 # REGISTRY.tcl is not associated with any feature, as it will be requested
1125 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001126 tcldata = []
1127 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001128 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001129 add_data(db, "FeatureComponents",
1130 [(default_feature.id, "REGISTRY"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001131 (htmlfiles.id, "REGISTRY.doc"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001132 (ext_feature.id, "REGISTRY.def")] +
1133 tcldata
1134 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001135 # Extensions are not advertised. For advertised extensions,
1136 # we would need separate binaries that install along with the
1137 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001138 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1139 ewi = "Edit with IDLE"
1140 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1141 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001142 tcl_verbs = []
1143 if have_tcl:
1144 tcl_verbs=[
1145 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1146 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1147 "REGISTRY.tcl"),
1148 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1149 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1150 "REGISTRY.tcl"),
1151 ]
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001152 add_data(db, "Registry",
1153 [# Extensions
1154 ("py.ext", -1, r"Software\Classes\."+ext, "",
1155 "Python.File", "REGISTRY.def"),
1156 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1157 "Python.NoConFile", "REGISTRY.def"),
1158 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1159 "Python.CompiledFile", "REGISTRY.def"),
1160 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1161 "Python.CompiledFile", "REGISTRY.def"),
1162 # MIME types
1163 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1164 "text/plain", "REGISTRY.def"),
1165 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1166 "text/plain", "REGISTRY.def"),
1167 #Verbs
1168 ("py.open", -1, pat % (testprefix, "", "open"), "",
1169 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1170 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1171 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1172 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1173 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001174 ] + tcl_verbs + [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001175 #Icons
1176 ("py.icon", -1, pat2 % (testprefix, ""), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001177 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001178 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001179 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001180 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001181 r'[DLLs]pyc.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001182 # Descriptions
1183 ("py.txt", -1, pat3 % (testprefix, ""), "",
1184 "Python File", "REGISTRY.def"),
1185 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1186 "Python File (no console)", "REGISTRY.def"),
1187 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1188 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001189 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001190
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001191 # Registry keys
1192 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1193 add_data(db, "Registry",
1194 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1195 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1196 "Python %s" % short_version, "REGISTRY"),
1197 ("PythonPath", -1, prefix+r"\PythonPath", "",
Martin v. Löwisf13337d2004-09-19 18:36:45 +00001198 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001199 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001200 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001201 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1202 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1203 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1204 ])
1205 # Shortcuts, see "Shortcut Table"
1206 add_data(db, "Directory",
1207 [("ProgramMenuFolder", "TARGETDIR", "."),
1208 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1209 add_data(db, "RemoveFile",
1210 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001211 tcltkshortcuts = []
1212 if have_tcl:
1213 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001214 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001215 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 +00001216 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001217 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 +00001218 ]
1219 add_data(db, "Shortcut",
1220 tcltkshortcuts +
1221 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001222 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1223 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001224 # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an
1225 # icon first.
1226 #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1227 # htmlfiles.id, None, None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001228 ## Non-advertised shortcuts: must be associated with a registry component
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001229 ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
1230 "[#Python%s%s.chm]" % (major,minor), None,
1231 None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001232 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1233 SystemFolderName+"msiexec", "/x%s" % product_code,
1234 None, None, None, None, None, None),
1235 ])
1236 db.Commit()
1237
1238db = build_database()
1239try:
1240 add_features(db)
1241 add_ui(db)
1242 add_files(db)
1243 add_registry(db)
1244 remove_old_versions(db)
1245 db.Commit()
1246finally:
1247 del db