blob: 5d966938e438db82f764a72898141221cb761b3d [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":
905 version, lang = extract_msvcr90()
906 dlldir.start_component("msvcr90", flags=8, keyfile="msvcr90.dll",
907 uuid=msvcr90_uuid)
908 dlldir.add_file("msvcr90.dll", src=os.path.abspath("msvcr90.dll"),
909 version=version, language=lang)
910 tmpfiles.append("msvcr90.dll")
911 else:
912 version, lang = extract_msvcr71()
913 dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll",
914 uuid=msvcr71_uuid)
915 dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
916 version=version, language=lang)
917 tmpfiles.append("msvcr71.dll")
918
Tim Peters66cb0182004-08-26 05:23:19 +0000919
Martin v. Löwis38325b72006-08-25 00:03:34 +0000920 # Check if _ctypes.pyd exists
Christian Heimes9acba042007-12-04 14:57:30 +0000921 have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
Martin v. Löwis38325b72006-08-25 00:03:34 +0000922 if not have_ctypes:
923 print "WARNING: _ctypes.pyd not found, ctypes will not be included"
924 extensions.remove("_ctypes.pyd")
Tim Peters147f9ae2006-08-25 22:05:39 +0000925
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000926 # Add all .py files in Lib, except lib-tk, test
927 dirs={}
928 pydirs = [(root,"Lib")]
929 while pydirs:
930 parent, dir = pydirs.pop()
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000931 if dir == ".svn" or dir.startswith("plat-"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000932 continue
933 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000934 if not have_tcl:
935 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000936 tcltk.set_current()
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000937 elif dir in ['test', 'tests', 'data', 'output']:
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000938 # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000939 # tests: Lib/distutils
940 # data: Lib/email/test
941 # output: Lib/test
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000942 testsuite.set_current()
Martin v. Löwis38325b72006-08-25 00:03:34 +0000943 elif not have_ctypes and dir == "ctypes":
944 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000945 else:
946 default_feature.set_current()
947 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
948 # Add additional files
949 dirs[dir]=lib
950 lib.glob("*.txt")
951 if dir=='site-packages':
Martin v. Löwis6d60c092004-11-21 10:16:26 +0000952 lib.add_file("README.txt", src="README")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000953 continue
954 files = lib.glob("*.py")
955 files += lib.glob("*.pyw")
956 if files:
957 # Add an entry to the RemoveFile table to remove bytecode files.
958 lib.remove_pyc()
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000959 if dir.endswith('.egg-info'):
960 lib.add_file('entry_points.txt')
961 lib.add_file('PKG-INFO')
962 lib.add_file('top_level.txt')
963 lib.add_file('zip-safe')
964 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000965 if dir=='test' and parent.physical=='Lib':
966 lib.add_file("185test.db")
967 lib.add_file("audiotest.au")
968 lib.add_file("cfgparser.1")
Martin v. Löwisc0fdb182006-09-12 19:49:20 +0000969 lib.add_file("sgml_input.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000970 lib.add_file("test.xml")
971 lib.add_file("test.xml.out")
972 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000973 lib.add_file("test_difflib_expect.html")
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000974 lib.add_file("check_soundcard.vbs")
Thomas Heller3bd33152006-04-04 18:41:13 +0000975 lib.add_file("empty.vbs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000976 lib.glob("*.uue")
Martin v. Löwis0ffdacd2007-11-20 02:46:02 +0000977 lib.glob("*.pem")
Martin v. Löwis6b449f42007-12-03 19:20:02 +0000978 lib.glob("*.pck")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000979 lib.add_file("readme.txt", src="README")
980 if dir=='decimaltestdata':
981 lib.glob("*.decTest")
982 if dir=='output':
983 lib.glob("test_*")
984 if dir=='idlelib':
985 lib.glob("*.def")
986 lib.add_file("idle.bat")
987 if dir=="Icons":
988 lib.glob("*.gif")
989 lib.add_file("idle.icns")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000990 if dir=="command" and parent.physical=="distutils":
Christian Heimes7e28e492008-01-01 13:52:57 +0000991 lib.add_file("wininst-6.0.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000992 lib.add_file("wininst-7.1.exe")
Christian Heimes7e28e492008-01-01 13:52:57 +0000993 lib.add_file("wininst-8.0.exe")
994 lib.add_file("wininst-9.0.exe")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000995 if dir=="setuptools":
996 lib.add_file("cli.exe")
997 lib.add_file("gui.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000998 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000999 # This should contain all non-.svn files listed in subversion
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001000 for f in os.listdir(lib.absolute):
Martin v. Löwis9ca9f562006-01-03 06:29:53 +00001001 if f.endswith(".txt") or f==".svn":continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001002 if f.endswith(".au") or f.endswith(".gif"):
1003 lib.add_file(f)
1004 else:
1005 print "WARNING: New file %s in email/test/data" % f
1006 for f in os.listdir(lib.absolute):
1007 if os.path.isdir(os.path.join(lib.absolute, f)):
1008 pydirs.append((lib, f))
1009 # Add DLLs
1010 default_feature.set_current()
Christian Heimes9acba042007-12-04 14:57:30 +00001011 lib = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
Christian Heimes7e28e492008-01-01 13:52:57 +00001012 lib.add_file("py.ico", src=srcdir+"/PC/py.ico")
Christian Heimese1c6af02008-01-01 13:58:16 +00001013 lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001014 dlls = []
1015 tclfiles = []
1016 for f in extensions:
1017 if f=="_tkinter.pyd":
1018 continue
Christian Heimes9acba042007-12-04 14:57:30 +00001019 if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001020 print "WARNING: Missing extension", f
1021 continue
1022 dlls.append(f)
1023 lib.add_file(f)
Martin v. Löwis88ef6372006-07-06 06:55:58 +00001024 # Add sqlite
1025 if msilib.msi_type=="Intel64;1033":
1026 sqlite_arch = "/ia64"
1027 elif msilib.msi_type=="x64;1033":
1028 sqlite_arch = "/amd64"
1029 else:
1030 sqlite_arch = ""
1031 lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001032 if have_tcl:
Christian Heimes9acba042007-12-04 14:57:30 +00001033 if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001034 print "WARNING: Missing _tkinter.pyd"
1035 else:
1036 lib.start_component("TkDLLs", tcltk)
1037 lib.add_file("_tkinter.pyd")
1038 dlls.append("_tkinter.pyd")
1039 tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
1040 for f in glob.glob1(tcldir, "*.dll"):
1041 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001042 # check whether there are any unknown extensions
Christian Heimes9acba042007-12-04 14:57:30 +00001043 for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001044 if f.endswith("_d.pyd"): continue # debug version
1045 if f in dlls: continue
1046 print "WARNING: Unknown extension", f
Tim Peters66cb0182004-08-26 05:23:19 +00001047
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001048 # Add headers
1049 default_feature.set_current()
1050 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
1051 lib.glob("*.h")
1052 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
1053 # Add import libraries
Christian Heimes9acba042007-12-04 14:57:30 +00001054 lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001055 for f in dlls:
1056 lib.add_file(f.replace('pyd','lib'))
1057 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +00001058 # Add the mingw-format library
1059 if have_mingw:
Tim Peters5a9fb3c2005-01-07 16:01:32 +00001060 lib.add_file('libpython%s%s.a' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001061 if have_tcl:
1062 # Add Tcl/Tk
1063 tcldirs = [(root, '../tcltk/lib', 'tcl')]
1064 tcltk.set_current()
1065 while tcldirs:
1066 parent, phys, dir = tcldirs.pop()
1067 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
1068 if not os.path.exists(lib.absolute):
1069 continue
1070 for f in os.listdir(lib.absolute):
1071 if os.path.isdir(os.path.join(lib.absolute, f)):
1072 tcldirs.append((lib, f, f))
1073 else:
1074 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001075 # Add tools
1076 tools.set_current()
1077 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
1078 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
1079 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1080 lib.glob("*.py")
1081 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1082 lib.remove_pyc()
1083 lib.glob("*.txt")
1084 if f == "pynche":
1085 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1086 x.glob("*.txt")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001087 if os.path.exists(os.path.join(lib.absolute, "README")):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001088 lib.add_file("README.txt", src="README")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001089 if f == 'Scripts':
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001090 if have_tcl:
1091 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1092 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001093 # Add documentation
1094 htmlfiles.set_current()
1095 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
1096 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
Martin v. Löwis8628f752007-09-10 10:21:22 +00001097 lib.add_file("Python%s%s.chm" % (major, minor), src="build/htmlhelp/pydoc.chm")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001098
1099 cab.commit(db)
1100
1101 for f in tmpfiles:
1102 os.unlink(f)
1103
1104# See "Registry Table", "Component Table"
1105def add_registry(db):
1106 # File extensions, associated with the REGISTRY.def component
1107 # IDLE verbs depend on the tcltk feature.
1108 # msidbComponentAttributesRegistryKeyPath = 4
1109 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001110 tcldata = []
1111 if have_tcl:
1112 tcldata = [
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001113 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001114 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001115 add_data(db, "Component",
1116 # msidbComponentAttributesRegistryKeyPath = 4
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001117 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001118 "InstallPath"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001119 ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001120 "Documentation"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001121 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001122 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001123 # See "FeatureComponents Table".
1124 # The association between TclTk and pythonw.exe is necessary to make ICE59
1125 # happy, because the installer otherwise believes that the IDLE and PyDoc
1126 # shortcuts might get installed without pythonw.exe being install. This
1127 # is not true, since installing TclTk will install the default feature, which
1128 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001129 # REGISTRY.tcl is not associated with any feature, as it will be requested
1130 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001131 tcldata = []
1132 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001133 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001134 add_data(db, "FeatureComponents",
1135 [(default_feature.id, "REGISTRY"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001136 (htmlfiles.id, "REGISTRY.doc"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001137 (ext_feature.id, "REGISTRY.def")] +
1138 tcldata
1139 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001140 # Extensions are not advertised. For advertised extensions,
1141 # we would need separate binaries that install along with the
1142 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001143 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1144 ewi = "Edit with IDLE"
1145 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1146 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001147 tcl_verbs = []
1148 if have_tcl:
1149 tcl_verbs=[
1150 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1151 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1152 "REGISTRY.tcl"),
1153 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1154 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1155 "REGISTRY.tcl"),
1156 ]
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001157 add_data(db, "Registry",
1158 [# Extensions
1159 ("py.ext", -1, r"Software\Classes\."+ext, "",
1160 "Python.File", "REGISTRY.def"),
1161 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1162 "Python.NoConFile", "REGISTRY.def"),
1163 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1164 "Python.CompiledFile", "REGISTRY.def"),
1165 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1166 "Python.CompiledFile", "REGISTRY.def"),
1167 # MIME types
1168 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1169 "text/plain", "REGISTRY.def"),
1170 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1171 "text/plain", "REGISTRY.def"),
1172 #Verbs
1173 ("py.open", -1, pat % (testprefix, "", "open"), "",
1174 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1175 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1176 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1177 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1178 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001179 ] + tcl_verbs + [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001180 #Icons
1181 ("py.icon", -1, pat2 % (testprefix, ""), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001182 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001183 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001184 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001185 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001186 r'[DLLs]pyc.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001187 # Descriptions
1188 ("py.txt", -1, pat3 % (testprefix, ""), "",
1189 "Python File", "REGISTRY.def"),
1190 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1191 "Python File (no console)", "REGISTRY.def"),
1192 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1193 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001194 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001195
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001196 # Registry keys
1197 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1198 add_data(db, "Registry",
1199 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1200 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1201 "Python %s" % short_version, "REGISTRY"),
1202 ("PythonPath", -1, prefix+r"\PythonPath", "",
Martin v. Löwisf13337d2004-09-19 18:36:45 +00001203 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001204 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001205 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001206 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1207 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1208 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1209 ])
1210 # Shortcuts, see "Shortcut Table"
1211 add_data(db, "Directory",
1212 [("ProgramMenuFolder", "TARGETDIR", "."),
1213 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1214 add_data(db, "RemoveFile",
1215 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001216 tcltkshortcuts = []
1217 if have_tcl:
1218 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001219 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001220 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 +00001221 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001222 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 +00001223 ]
1224 add_data(db, "Shortcut",
1225 tcltkshortcuts +
1226 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001227 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1228 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001229 # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an
1230 # icon first.
1231 #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1232 # htmlfiles.id, None, None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001233 ## Non-advertised shortcuts: must be associated with a registry component
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001234 ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
1235 "[#Python%s%s.chm]" % (major,minor), None,
1236 None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001237 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1238 SystemFolderName+"msiexec", "/x%s" % product_code,
1239 None, None, None, None, None, None),
1240 ])
1241 db.Commit()
1242
1243db = build_database()
1244try:
1245 add_features(db)
1246 add_ui(db)
1247 add_files(db)
1248 add_registry(db)
1249 remove_old_versions(db)
1250 db.Commit()
1251finally:
1252 del db