blob: 88e8b7c36d2131efc977f9177be0fb2772bf4ab2 [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():
839 import _winreg
840 # Find the location of the merge modules
841 k = _winreg.OpenKey(
842 _winreg.HKEY_LOCAL_MACHINE,
843 r"Software\Microsoft\VisualStudio\9.0\Setup\VS")
844 prod_dir = _winreg.QueryValueEx(k, "ProductDir")[0]
845 _winreg.CloseKey(k)
846
847 # Copy msvcr90*
848 dir = os.path.join(prod_dir, r'VC\redist\x86\Microsoft.VC90.CRT')
849 files = glob.glob1(dir, "*CRT*.dll") + glob.glob1(dir, "*VCR*.dll")
850 for file in files:
851 shutil.copy(os.path.join(dir, file), '.')
852
853 dir = os.path.join(prod_dir, r'VC\redist\Debug_NonRedist\x86\Microsoft.VC90.DebugCRT')
854 files = glob.glob1(dir, "*CRT*.dll") + glob.glob1(dir, "*VCR*.dll")
855 for file in files:
856 shutil.copy(os.path.join(dir, file), '.')
857
858 # Find the version/language of msvcr90.dll
859 installer = msilib.MakeInstaller()
860 return installer.FileVersion("msvcr90.dll", 0), \
861 installer.FileVersion("msvcr90.dll", 1)
862
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000863class PyDirectory(Directory):
864 """By default, all components in the Python installer
865 can run from source."""
866 def __init__(self, *args, **kw):
867 if not kw.has_key("componentflags"):
868 kw['componentflags'] = 2 #msidbComponentAttributesOptional
869 Directory.__init__(self, *args, **kw)
870
871# See "File Table", "Component Table", "Directory Table",
872# "FeatureComponents Table"
873def add_files(db):
874 cab = CAB("python")
875 tmpfiles = []
876 # Add all executables, icons, text files into the TARGETDIR component
877 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
878 default_feature.set_current()
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000879 if not msilib.Win64:
Christian Heimes9acba042007-12-04 14:57:30 +0000880 root.add_file("%s/w9xpopen.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000881 root.add_file("README.txt", src="README")
882 root.add_file("NEWS.txt", src="Misc/NEWS")
883 root.add_file("LICENSE.txt", src="LICENSE")
884 root.start_component("python.exe", keyfile="python.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000885 root.add_file("%s/python.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000886 root.start_component("pythonw.exe", keyfile="pythonw.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000887 root.add_file("%s/pythonw.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000888
889 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
890 dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
891 pydll = "python%s%s.dll" % (major, minor)
Christian Heimes9acba042007-12-04 14:57:30 +0000892 pydllsrc = os.path.join(srcdir, PCBUILD, pydll)
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000893 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000894 installer = msilib.MakeInstaller()
895 pyversion = installer.FileVersion(pydllsrc, 0)
896 if not snapshot:
897 # For releases, the Python DLL has the same version as the
898 # installer package.
899 assert pyversion.split(".")[:3] == current_version.split(".")
Christian Heimes9acba042007-12-04 14:57:30 +0000900 dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000901 version=pyversion,
902 language=installer.FileVersion(pydllsrc, 1))
903 # XXX determine dependencies
Christian Heimes9acba042007-12-04 14:57:30 +0000904 if MSVCR == "90":
Martin v. Löwis94da1d62008-01-06 11:13:16 +0000905 # XXX don't package the CRT for the moment;
906 # this should probably use the merge module in the long run.
907 pass
908 #version, lang = extract_msvcr90()
909 #dlldir.start_component("msvcr90", flags=8, keyfile="msvcr90.dll",
910 # uuid=msvcr90_uuid)
911 #dlldir.add_file("msvcr90.dll", src=os.path.abspath("msvcr90.dll"),
912 # version=version, language=lang)
913 #tmpfiles.append("msvcr90.dll")
Christian Heimes9acba042007-12-04 14:57:30 +0000914 else:
915 version, lang = extract_msvcr71()
916 dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll",
917 uuid=msvcr71_uuid)
918 dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
919 version=version, language=lang)
920 tmpfiles.append("msvcr71.dll")
921
Tim Peters66cb0182004-08-26 05:23:19 +0000922
Martin v. Löwis38325b72006-08-25 00:03:34 +0000923 # Check if _ctypes.pyd exists
Christian Heimes9acba042007-12-04 14:57:30 +0000924 have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
Martin v. Löwis38325b72006-08-25 00:03:34 +0000925 if not have_ctypes:
926 print "WARNING: _ctypes.pyd not found, ctypes will not be included"
927 extensions.remove("_ctypes.pyd")
Tim Peters147f9ae2006-08-25 22:05:39 +0000928
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000929 # Add all .py files in Lib, except lib-tk, test
930 dirs={}
931 pydirs = [(root,"Lib")]
932 while pydirs:
933 parent, dir = pydirs.pop()
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000934 if dir == ".svn" or dir.startswith("plat-"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000935 continue
936 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000937 if not have_tcl:
938 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000939 tcltk.set_current()
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000940 elif dir in ['test', 'tests', 'data', 'output']:
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000941 # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000942 # tests: Lib/distutils
943 # data: Lib/email/test
944 # output: Lib/test
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000945 testsuite.set_current()
Martin v. Löwis38325b72006-08-25 00:03:34 +0000946 elif not have_ctypes and dir == "ctypes":
947 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000948 else:
949 default_feature.set_current()
950 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
951 # Add additional files
952 dirs[dir]=lib
953 lib.glob("*.txt")
954 if dir=='site-packages':
Martin v. Löwis6d60c092004-11-21 10:16:26 +0000955 lib.add_file("README.txt", src="README")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000956 continue
957 files = lib.glob("*.py")
958 files += lib.glob("*.pyw")
959 if files:
960 # Add an entry to the RemoveFile table to remove bytecode files.
961 lib.remove_pyc()
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000962 if dir.endswith('.egg-info'):
963 lib.add_file('entry_points.txt')
964 lib.add_file('PKG-INFO')
965 lib.add_file('top_level.txt')
966 lib.add_file('zip-safe')
967 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000968 if dir=='test' and parent.physical=='Lib':
969 lib.add_file("185test.db")
970 lib.add_file("audiotest.au")
971 lib.add_file("cfgparser.1")
Martin v. Löwisc0fdb182006-09-12 19:49:20 +0000972 lib.add_file("sgml_input.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000973 lib.add_file("test.xml")
974 lib.add_file("test.xml.out")
975 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000976 lib.add_file("test_difflib_expect.html")
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000977 lib.add_file("check_soundcard.vbs")
Thomas Heller3bd33152006-04-04 18:41:13 +0000978 lib.add_file("empty.vbs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000979 lib.glob("*.uue")
Martin v. Löwis0ffdacd2007-11-20 02:46:02 +0000980 lib.glob("*.pem")
Martin v. Löwis6b449f42007-12-03 19:20:02 +0000981 lib.glob("*.pck")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000982 lib.add_file("readme.txt", src="README")
983 if dir=='decimaltestdata':
984 lib.glob("*.decTest")
985 if dir=='output':
986 lib.glob("test_*")
987 if dir=='idlelib':
988 lib.glob("*.def")
989 lib.add_file("idle.bat")
990 if dir=="Icons":
991 lib.glob("*.gif")
992 lib.add_file("idle.icns")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000993 if dir=="command" and parent.physical=="distutils":
Christian Heimes7e28e492008-01-01 13:52:57 +0000994 lib.add_file("wininst-6.0.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000995 lib.add_file("wininst-7.1.exe")
Christian Heimes7e28e492008-01-01 13:52:57 +0000996 lib.add_file("wininst-8.0.exe")
997 lib.add_file("wininst-9.0.exe")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000998 if dir=="setuptools":
999 lib.add_file("cli.exe")
1000 lib.add_file("gui.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001001 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
Martin v. Löwis9ca9f562006-01-03 06:29:53 +00001002 # This should contain all non-.svn files listed in subversion
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001003 for f in os.listdir(lib.absolute):
Martin v. Löwis9ca9f562006-01-03 06:29:53 +00001004 if f.endswith(".txt") or f==".svn":continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001005 if f.endswith(".au") or f.endswith(".gif"):
1006 lib.add_file(f)
1007 else:
1008 print "WARNING: New file %s in email/test/data" % f
1009 for f in os.listdir(lib.absolute):
1010 if os.path.isdir(os.path.join(lib.absolute, f)):
1011 pydirs.append((lib, f))
1012 # Add DLLs
1013 default_feature.set_current()
Christian Heimes9acba042007-12-04 14:57:30 +00001014 lib = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
Christian Heimes7e28e492008-01-01 13:52:57 +00001015 lib.add_file("py.ico", src=srcdir+"/PC/py.ico")
Christian Heimese1c6af02008-01-01 13:58:16 +00001016 lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001017 dlls = []
1018 tclfiles = []
1019 for f in extensions:
1020 if f=="_tkinter.pyd":
1021 continue
Christian Heimes9acba042007-12-04 14:57:30 +00001022 if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001023 print "WARNING: Missing extension", f
1024 continue
1025 dlls.append(f)
1026 lib.add_file(f)
Martin v. Löwis88ef6372006-07-06 06:55:58 +00001027 # Add sqlite
1028 if msilib.msi_type=="Intel64;1033":
1029 sqlite_arch = "/ia64"
1030 elif msilib.msi_type=="x64;1033":
1031 sqlite_arch = "/amd64"
1032 else:
1033 sqlite_arch = ""
1034 lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001035 if have_tcl:
Christian Heimes9acba042007-12-04 14:57:30 +00001036 if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001037 print "WARNING: Missing _tkinter.pyd"
1038 else:
1039 lib.start_component("TkDLLs", tcltk)
1040 lib.add_file("_tkinter.pyd")
1041 dlls.append("_tkinter.pyd")
1042 tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
1043 for f in glob.glob1(tcldir, "*.dll"):
1044 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001045 # check whether there are any unknown extensions
Christian Heimes9acba042007-12-04 14:57:30 +00001046 for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001047 if f.endswith("_d.pyd"): continue # debug version
1048 if f in dlls: continue
1049 print "WARNING: Unknown extension", f
Tim Peters66cb0182004-08-26 05:23:19 +00001050
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001051 # Add headers
1052 default_feature.set_current()
1053 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
1054 lib.glob("*.h")
1055 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
1056 # Add import libraries
Christian Heimes9acba042007-12-04 14:57:30 +00001057 lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001058 for f in dlls:
1059 lib.add_file(f.replace('pyd','lib'))
1060 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +00001061 # Add the mingw-format library
1062 if have_mingw:
Tim Peters5a9fb3c2005-01-07 16:01:32 +00001063 lib.add_file('libpython%s%s.a' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001064 if have_tcl:
1065 # Add Tcl/Tk
1066 tcldirs = [(root, '../tcltk/lib', 'tcl')]
1067 tcltk.set_current()
1068 while tcldirs:
1069 parent, phys, dir = tcldirs.pop()
1070 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
1071 if not os.path.exists(lib.absolute):
1072 continue
1073 for f in os.listdir(lib.absolute):
1074 if os.path.isdir(os.path.join(lib.absolute, f)):
1075 tcldirs.append((lib, f, f))
1076 else:
1077 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001078 # Add tools
1079 tools.set_current()
1080 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
1081 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
1082 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1083 lib.glob("*.py")
1084 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1085 lib.remove_pyc()
1086 lib.glob("*.txt")
1087 if f == "pynche":
1088 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1089 x.glob("*.txt")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001090 if os.path.exists(os.path.join(lib.absolute, "README")):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001091 lib.add_file("README.txt", src="README")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001092 if f == 'Scripts':
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001093 if have_tcl:
1094 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1095 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001096 # Add documentation
1097 htmlfiles.set_current()
1098 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
1099 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
Martin v. Löwis8628f752007-09-10 10:21:22 +00001100 lib.add_file("Python%s%s.chm" % (major, minor), src="build/htmlhelp/pydoc.chm")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001101
1102 cab.commit(db)
1103
1104 for f in tmpfiles:
1105 os.unlink(f)
1106
1107# See "Registry Table", "Component Table"
1108def add_registry(db):
1109 # File extensions, associated with the REGISTRY.def component
1110 # IDLE verbs depend on the tcltk feature.
1111 # msidbComponentAttributesRegistryKeyPath = 4
1112 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001113 tcldata = []
1114 if have_tcl:
1115 tcldata = [
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001116 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001117 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001118 add_data(db, "Component",
1119 # msidbComponentAttributesRegistryKeyPath = 4
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001120 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001121 "InstallPath"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001122 ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001123 "Documentation"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001124 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001125 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001126 # See "FeatureComponents Table".
1127 # The association between TclTk and pythonw.exe is necessary to make ICE59
1128 # happy, because the installer otherwise believes that the IDLE and PyDoc
1129 # shortcuts might get installed without pythonw.exe being install. This
1130 # is not true, since installing TclTk will install the default feature, which
1131 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001132 # REGISTRY.tcl is not associated with any feature, as it will be requested
1133 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001134 tcldata = []
1135 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001136 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001137 add_data(db, "FeatureComponents",
1138 [(default_feature.id, "REGISTRY"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001139 (htmlfiles.id, "REGISTRY.doc"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001140 (ext_feature.id, "REGISTRY.def")] +
1141 tcldata
1142 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001143 # Extensions are not advertised. For advertised extensions,
1144 # we would need separate binaries that install along with the
1145 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001146 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1147 ewi = "Edit with IDLE"
1148 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1149 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001150 tcl_verbs = []
1151 if have_tcl:
1152 tcl_verbs=[
1153 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1154 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1155 "REGISTRY.tcl"),
1156 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1157 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1158 "REGISTRY.tcl"),
1159 ]
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001160 add_data(db, "Registry",
1161 [# Extensions
1162 ("py.ext", -1, r"Software\Classes\."+ext, "",
1163 "Python.File", "REGISTRY.def"),
1164 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1165 "Python.NoConFile", "REGISTRY.def"),
1166 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1167 "Python.CompiledFile", "REGISTRY.def"),
1168 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1169 "Python.CompiledFile", "REGISTRY.def"),
1170 # MIME types
1171 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1172 "text/plain", "REGISTRY.def"),
1173 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1174 "text/plain", "REGISTRY.def"),
1175 #Verbs
1176 ("py.open", -1, pat % (testprefix, "", "open"), "",
1177 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1178 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1179 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1180 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1181 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001182 ] + tcl_verbs + [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001183 #Icons
1184 ("py.icon", -1, pat2 % (testprefix, ""), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001185 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001186 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001187 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001188 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001189 r'[DLLs]pyc.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001190 # Descriptions
1191 ("py.txt", -1, pat3 % (testprefix, ""), "",
1192 "Python File", "REGISTRY.def"),
1193 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1194 "Python File (no console)", "REGISTRY.def"),
1195 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1196 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001197 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001198
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001199 # Registry keys
1200 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1201 add_data(db, "Registry",
1202 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1203 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1204 "Python %s" % short_version, "REGISTRY"),
1205 ("PythonPath", -1, prefix+r"\PythonPath", "",
Martin v. Löwisf13337d2004-09-19 18:36:45 +00001206 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001207 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001208 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001209 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1210 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1211 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1212 ])
1213 # Shortcuts, see "Shortcut Table"
1214 add_data(db, "Directory",
1215 [("ProgramMenuFolder", "TARGETDIR", "."),
1216 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1217 add_data(db, "RemoveFile",
1218 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001219 tcltkshortcuts = []
1220 if have_tcl:
1221 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001222 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001223 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 +00001224 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001225 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 +00001226 ]
1227 add_data(db, "Shortcut",
1228 tcltkshortcuts +
1229 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001230 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1231 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001232 # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an
1233 # icon first.
1234 #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1235 # htmlfiles.id, None, None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001236 ## Non-advertised shortcuts: must be associated with a registry component
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001237 ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
1238 "[#Python%s%s.chm]" % (major,minor), None,
1239 None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001240 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1241 SystemFolderName+"msiexec", "/x%s" % product_code,
1242 None, None, None, None, None, None),
1243 ])
1244 db.Commit()
1245
1246db = build_database()
1247try:
1248 add_features(db)
1249 add_ui(db)
1250 add_files(db)
1251 add_registry(db)
1252 remove_old_versions(db)
1253 db.Commit()
1254finally:
1255 del db