blob: cee7000e8f3e7edcc8d148c0354dd3c4e8c03202 [file] [log] [blame]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001# Python MSI Generator
2# (C) 2003 Martin v. Loewis
3# See "FOO" in comments refers to MSDN sections with the title FOO.
Christian Heimes9acba042007-12-04 14:57:30 +00004import msilib, schema, sequence, os, glob, time, re, shutil
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00005from msilib import Feature, CAB, Directory, Dialog, Binary, add_data
6import uisample
7from win32com.client import constants
Martin v. Löwis9fda9312004-12-22 13:41:49 +00008from distutils.spawn import find_executable
Martin v. Löwis1d278fc2006-03-28 18:30:05 +00009from uuids import product_codes
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000010
11# Settings can be overridden in config.py below
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000012# 0 for official python.org releases
13# 1 for intermediate releases by anybody, with
14# a new product code for every package.
15snapshot = 1
16# 1 means that file extension is px, not py,
17# and binaries start with x
18testpackage = 0
19# Location of build tree
20srcdir = os.path.abspath("../..")
21# Text to be displayed as the version in dialogs etc.
22# goes into file name and ProductCode. Defaults to
23# current_version.day for Snapshot, current_version otherwise
24full_current_version = None
Martin v. Löwise0f780d2004-09-01 14:51:06 +000025# Is Tcl available at all?
26have_tcl = True
Martin v. Löwis1a494bd2006-04-04 07:10:59 +000027# Where is sqlite3.dll located, relative to srcdir?
28sqlite_dir = "../sqlite-source-3.3.4"
Christian Heimes9acba042007-12-04 14:57:30 +000029# path to PCbuild directory
Martin v. Löwise7a434e2008-01-06 11:03:43 +000030PCBUILD="PCbuild"
Christian Heimes9acba042007-12-04 14:57:30 +000031# msvcrt version
Martin v. Löwise7a434e2008-01-06 11:03:43 +000032MSVCR = "90"
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000033
34try:
35 from config import *
36except ImportError:
37 pass
38
39# Extract current version from Include/patchlevel.h
40lines = open(srcdir + "/Include/patchlevel.h").readlines()
41major = minor = micro = level = serial = None
42levels = {
43 'PY_RELEASE_LEVEL_ALPHA':0xA,
44 'PY_RELEASE_LEVEL_BETA': 0xB,
45 'PY_RELEASE_LEVEL_GAMMA':0xC,
46 'PY_RELEASE_LEVEL_FINAL':0xF
47 }
48for l in lines:
49 if not l.startswith("#define"):
50 continue
51 l = l.split()
52 if len(l) != 3:
53 continue
54 _, name, value = l
55 if name == 'PY_MAJOR_VERSION': major = value
56 if name == 'PY_MINOR_VERSION': minor = value
57 if name == 'PY_MICRO_VERSION': micro = value
58 if name == 'PY_RELEASE_LEVEL': level = levels[value]
59 if name == 'PY_RELEASE_SERIAL': serial = value
60
61short_version = major+"."+minor
62# See PC/make_versioninfo.c
63FIELD3 = 1000*int(micro) + 10*level + int(serial)
64current_version = "%s.%d" % (short_version, FIELD3)
65
66# This should never change. The UpgradeCode of this package can be
67# used in the Upgrade table of future packages to make the future
68# package replace this one. See "UpgradeCode Property".
69upgrade_code_snapshot='{92A24481-3ECB-40FC-8836-04B7966EC0D5}'
70upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}'
71
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000072if snapshot:
73 current_version = "%s.%s.%s" % (major, minor, int(time.time()/3600/24))
74 product_code = msilib.gen_uuid()
75else:
76 product_code = product_codes[current_version]
77
78if full_current_version is None:
79 full_current_version = current_version
80
81extensions = [
82 'bz2.pyd',
83 'pyexpat.pyd',
84 'select.pyd',
85 'unicodedata.pyd',
86 'winsound.pyd',
Trent Micke97e5a72005-12-15 22:08:46 +000087 '_elementtree.pyd',
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000088 '_bsddb.pyd',
89 '_socket.pyd',
90 '_ssl.pyd',
91 '_testcapi.pyd',
92 '_tkinter.pyd',
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +000093 '_msi.pyd',
Martin v. Löwisa09655e2006-03-10 15:36:28 +000094 '_ctypes.pyd',
Martin v. Löwis1a494bd2006-04-04 07:10:59 +000095 '_ctypes_test.pyd',
Martin v. Löwisa09fd6e2006-08-16 12:55:10 +000096 '_sqlite3.pyd',
97 '_hashlib.pyd'
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000098]
99
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000100# Well-known component UUIDs
101# These are needed for SharedDLLs reference counter; if
102# a different UUID was used for each incarnation of, say,
103# python24.dll, an upgrade would set the reference counter
104# from 1 to 2 (due to what I consider a bug in MSI)
105# Using the same UUID is fine since these files are versioned,
106# so Installer will always keep the newest version.
Christian Heimes9acba042007-12-04 14:57:30 +0000107# NOTE: All uuids are self generated.
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000108pythondll_uuid = {
109 "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}",
Martin v. Löwis5409c8d2007-08-30 18:15:22 +0000110 "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}",
Martin v. Löwisbe7abbb2007-08-14 05:01:50 +0000111 "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}",
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000112 } [major+minor]
Tim Peterseba28be2005-03-28 01:08:02 +0000113
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000114# Build the mingw import library, libpythonXY.a
115# This requires 'nm' and 'dlltool' executables on your PATH
116def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
117 warning = "WARNING: %s - libpythonXX.a not built"
118 nm = find_executable('nm')
119 dlltool = find_executable('dlltool')
120
121 if not nm or not dlltool:
122 print warning % "nm and/or dlltool were not found"
123 return False
124
125 nm_command = '%s -Cs %s' % (nm, lib_file)
126 dlltool_command = "%s --dllname %s --def %s --output-lib %s" % \
127 (dlltool, dll_file, def_file, mingw_lib)
128 export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match
129
130 f = open(def_file,'w')
131 print >>f, "LIBRARY %s" % dll_file
132 print >>f, "EXPORTS"
133
134 nm_pipe = os.popen(nm_command)
135 for line in nm_pipe.readlines():
136 m = export_match(line)
137 if m:
138 print >>f, m.group(1)
139 f.close()
140 exit = nm_pipe.close()
141
142 if exit:
143 print warning % "nm did not run successfully"
144 return False
145
146 if os.system(dlltool_command) != 0:
147 print warning % "dlltool did not run successfully"
148 return False
149
150 return True
151
152# Target files (.def and .a) go in PCBuild directory
Christian Heimes9acba042007-12-04 14:57:30 +0000153lib_file = os.path.join(srcdir, PCBUILD, "python%s%s.lib" % (major, minor))
154def_file = os.path.join(srcdir, PCBUILD, "python%s%s.def" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000155dll_file = "python%s%s.dll" % (major, minor)
Christian Heimes9acba042007-12-04 14:57:30 +0000156mingw_lib = os.path.join(srcdir, PCBUILD, "libpython%s%s.a" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000157
158have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
159
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000160# Determine the target architechture
Christian Heimes9acba042007-12-04 14:57:30 +0000161dll_path = os.path.join(srcdir, PCBUILD, dll_file)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000162msilib.set_arch_from_file(dll_path)
163if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
164 raise SystemError, "msisupport.dll for incorrect architecture"
165
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000166if testpackage:
167 ext = 'px'
168 testprefix = 'x'
169else:
170 ext = 'py'
171 testprefix = ''
172
173if msilib.Win64:
Martin v. Löwis75c23bd2007-08-30 18:25:47 +0000174 SystemFolderName = "[System64Folder]"
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +0000175 registry_component = 4|256
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000176else:
177 SystemFolderName = "[SystemFolder]"
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +0000178 registry_component = 4
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000179
180msilib.reset()
181
182# condition in which to install pythonxy.dll in system32:
183# a) it is Windows 9x or
184# b) it is NT, the user is privileged, and has chosen per-machine installation
185sys32cond = "(Windows9x or (Privileged and ALLUSERS))"
186
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000187def build_database():
188 """Generate an empty database, with just the schema and the
189 Summary information stream."""
190 if snapshot:
191 uc = upgrade_code_snapshot
192 else:
193 uc = upgrade_code
194 # schema represents the installer 2.0 database schema.
195 # sequence is the set of standard sequences
196 # (ui/execute, admin/advt/install)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000197 db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000198 schema, ProductName="Python "+full_current_version,
199 ProductCode=product_code,
200 ProductVersion=current_version,
Martin v. Löwis8bc77e42007-09-01 06:36:03 +0000201 Manufacturer=u"Python Software Foundation")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000202 # The default sequencing of the RemoveExistingProducts action causes
203 # removal of files that got just installed. Place it after
204 # InstallInitialize, so we first uninstall everything, but still roll
205 # back in case the installation is interrupted
206 msilib.change_sequence(sequence.InstallExecuteSequence,
207 "RemoveExistingProducts", 1510)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000208 msilib.add_tables(db, sequence)
209 # We cannot set ALLUSERS in the property table, as this cannot be
210 # reset if the user choses a per-user installation. Instead, we
211 # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages
212 # this property, and when the execution starts, ALLUSERS is set
213 # accordingly.
214 add_data(db, "Property", [("UpgradeCode", uc),
215 ("WhichUsers", "ALL"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000216 ("ProductLine", "Python%s%s" % (major, minor)),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000217 ])
218 db.Commit()
219 return db
220
221def remove_old_versions(db):
222 "Fill the upgrade table."
223 start = "%s.%s.0" % (major, minor)
224 # This requests that feature selection states of an older
225 # installation should be forwarded into this one. Upgrading
226 # requires that both the old and the new installation are
227 # either both per-machine or per-user.
228 migrate_features = 1
229 # See "Upgrade Table". We remove releases with the same major and
230 # minor version. For an snapshot, we remove all earlier snapshots. For
231 # a release, we remove all snapshots, and all earlier releases.
232 if snapshot:
233 add_data(db, "Upgrade",
Tim Peters66cb0182004-08-26 05:23:19 +0000234 [(upgrade_code_snapshot, start,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000235 current_version,
236 None, # Ignore language
Tim Peters66cb0182004-08-26 05:23:19 +0000237 migrate_features,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000238 None, # Migrate ALL features
239 "REMOVEOLDSNAPSHOT")])
240 props = "REMOVEOLDSNAPSHOT"
241 else:
242 add_data(db, "Upgrade",
243 [(upgrade_code, start, current_version,
244 None, migrate_features, None, "REMOVEOLDVERSION"),
245 (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1),
246 None, migrate_features, None, "REMOVEOLDSNAPSHOT")])
247 props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION"
248 # Installer collects the product codes of the earlier releases in
249 # these properties. In order to allow modification of the properties,
250 # they must be declared as secure. See "SecureCustomProperties Property"
251 add_data(db, "Property", [("SecureCustomProperties", props)])
252
253class PyDialog(Dialog):
254 """Dialog class with a fixed layout: controls at the top, then a ruler,
255 then a list of buttons: back, next, cancel. Optionally a bitmap at the
256 left."""
257 def __init__(self, *args, **kw):
258 """Dialog(database, name, x, y, w, h, attributes, title, first,
259 default, cancel, bitmap=true)"""
260 Dialog.__init__(self, *args)
261 ruler = self.h - 36
262 bmwidth = 152*ruler/328
263 if kw.get("bitmap", True):
264 self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
265 self.line("BottomLine", 0, ruler, self.w, 0)
266
267 def title(self, title):
268 "Set the title text of the dialog at the top."
269 # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
270 # text, in VerdanaBold10
271 self.text("Title", 135, 10, 220, 60, 0x30003,
272 r"{\VerdanaBold10}%s" % title)
273
274 def back(self, title, next, name = "Back", active = 1):
275 """Add a back button with a given title, the tab-next button,
276 its name in the Control table, possibly initially disabled.
277
278 Return the button, so that events can be associated"""
279 if active:
280 flags = 3 # Visible|Enabled
281 else:
282 flags = 1 # Visible
283 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
284
285 def cancel(self, title, next, name = "Cancel", active = 1):
286 """Add a cancel button with a given title, the tab-next button,
287 its name in the Control table, possibly initially disabled.
288
289 Return the button, so that events can be associated"""
290 if active:
291 flags = 3 # Visible|Enabled
292 else:
293 flags = 1 # Visible
294 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
295
296 def next(self, title, next, name = "Next", active = 1):
297 """Add a Next button with a given title, the tab-next button,
298 its name in the Control table, possibly initially disabled.
299
300 Return the button, so that events can be associated"""
301 if active:
302 flags = 3 # Visible|Enabled
303 else:
304 flags = 1 # Visible
305 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
306
307 def xbutton(self, name, title, next, xpos):
308 """Add a button with a given title, the tab-next button,
309 its name in the Control table, giving its x position; the
310 y-position is aligned with the other buttons.
311
312 Return the button, so that events can be associated"""
313 return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
314
315def add_ui(db):
316 x = y = 50
317 w = 370
318 h = 300
319 title = "[ProductName] Setup"
320
321 # see "Dialog Style Bits"
322 modal = 3 # visible | modal
323 modeless = 1 # visible
324 track_disk_space = 32
325
326 add_data(db, 'ActionText', uisample.ActionText)
327 add_data(db, 'UIText', uisample.UIText)
328
329 # Bitmaps
330 if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
331 raise "Run icons.mak in PC directory"
332 add_data(db, "Binary",
Christian Heimes7e28e492008-01-01 13:52:57 +0000333 [("PythonWin", msilib.Binary(r"%s\PCbuild\installer.bmp" % srcdir)), # 152x328 pixels
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000334 ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
335 ])
336 add_data(db, "Icon",
337 [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))])
338
339 # Scripts
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000340 # CheckDir sets TargetExists if TARGETDIR exists.
341 # UpdateEditIDLE sets the REGISTRY.tcl component into
342 # the installed/uninstalled state according to both the
343 # Extensions and TclTk features.
Martin v. Löwiseb68be42004-12-12 15:29:21 +0000344 if os.system("nmake /nologo /c /f msisupport.mak") != 0:
345 raise "'nmake /f msisupport.mak' failed"
346 add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
347 # See "Custom Action Type 1"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000348 if msilib.Win64:
349 CheckDir = "CheckDir"
Martin v. Löwisdf40ce32006-02-16 14:38:30 +0000350 UpdateEditIDLE = "UpdateEditIDLE"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000351 else:
352 CheckDir = "_CheckDir@4"
353 UpdateEditIDLE = "_UpdateEditIDLE@4"
Tim Peters0e9980f2004-09-12 03:49:31 +0000354 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000355 [("CheckDir", 1, "Script", CheckDir)])
Martin v. Löwiseac02e62004-11-18 08:00:33 +0000356 if have_tcl:
357 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000358 [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)])
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000359
360 # UI customization properties
361 add_data(db, "Property",
362 # See "DefaultUIFont Property"
363 [("DefaultUIFont", "DlgFont8"),
364 # See "ErrorDialog Style Bit"
365 ("ErrorDialog", "ErrorDlg"),
366 ("Progress1", "Install"), # modified in maintenance type dlg
367 ("Progress2", "installs"),
368 ("MaintenanceForm_Action", "Repair")])
369
370 # Fonts, see "TextStyle Table"
371 add_data(db, "TextStyle",
372 [("DlgFont8", "Tahoma", 9, None, 0),
373 ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
374 ("VerdanaBold10", "Verdana", 10, None, 1),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000375 ("VerdanaRed9", "Verdana", 9, 255, 0),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000376 ])
377
Martin v. Löwis775e10d2008-04-08 16:48:35 +0000378 compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x bad_coding|badsyntax|site-packages|py3_ "[TARGETDIR]Lib"'
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000379 # See "CustomAction Table"
380 add_data(db, "CustomAction", [
381 # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
382 # See "Custom Action Type 51",
383 # "Custom Action Execution Scheduling Options"
384 ("InitialTargetDir", 307, "TARGETDIR",
385 "[WindowsVolume]Python%s%s" % (major, minor)),
386 ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"),
387 ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName),
388 # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile
389 # See "Custom Action Type 18"
Martin v. Löwis7b2563b2004-11-02 22:59:56 +0000390 ("CompilePyc", 18, "python.exe", compileargs),
391 ("CompilePyo", 18, "python.exe", "-O "+compileargs),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000392 ])
393
394 # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
395 # Numbers indicate sequence; see sequence.py for how these action integrate
396 add_data(db, "InstallUISequence",
397 [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
398 ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
399 ("InitialTargetDir", 'TARGETDIR=""', 750),
400 # In the user interface, assume all-users installation if privileged.
401 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
402 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
403 ("SelectDirectoryDlg", "Not Installed", 1230),
404 # XXX no support for resume installations yet
405 #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
406 ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
407 ("ProgressDlg", None, 1280)])
408 add_data(db, "AdminUISequence",
409 [("InitialTargetDir", 'TARGETDIR=""', 750),
410 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
411 ])
412
413 # Execute Sequences
414 add_data(db, "InstallExecuteSequence",
415 [("InitialTargetDir", 'TARGETDIR=""', 750),
416 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
417 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000418 ("UpdateEditIDLE", None, 1050),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000419 ("CompilePyc", "COMPILEALL", 6800),
420 ("CompilePyo", "COMPILEALL", 6801),
421 ])
422 add_data(db, "AdminExecuteSequence",
423 [("InitialTargetDir", 'TARGETDIR=""', 750),
424 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
425 ("CompilePyc", "COMPILEALL", 6800),
426 ("CompilePyo", "COMPILEALL", 6801),
427 ])
428
429 #####################################################################
430 # Standard dialogs: FatalError, UserExit, ExitDialog
431 fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
432 "Finish", "Finish", "Finish")
433 fatal.title("[ProductName] Installer ended prematurely")
434 fatal.back("< Back", "Finish", active = 0)
435 fatal.cancel("Cancel", "Back", active = 0)
436 fatal.text("Description1", 135, 70, 220, 80, 0x30003,
437 "[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.")
438 fatal.text("Description2", 135, 155, 220, 20, 0x30003,
439 "Click the Finish button to exit the Installer.")
440 c=fatal.next("Finish", "Cancel", name="Finish")
441 # See "ControlEvent Table". Parameters are the event, the parameter
442 # to the action, and optionally the condition for the event, and the order
443 # of events.
444 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000445
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000446 user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
447 "Finish", "Finish", "Finish")
448 user_exit.title("[ProductName] Installer was interrupted")
449 user_exit.back("< Back", "Finish", active = 0)
450 user_exit.cancel("Cancel", "Back", active = 0)
451 user_exit.text("Description1", 135, 70, 220, 80, 0x30003,
452 "[ProductName] setup was interrupted. Your system has not been modified. "
453 "To install this program at a later time, please run the installation again.")
454 user_exit.text("Description2", 135, 155, 220, 20, 0x30003,
455 "Click the Finish button to exit the Installer.")
456 c = user_exit.next("Finish", "Cancel", name="Finish")
457 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000458
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000459 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
460 "Finish", "Finish", "Finish")
461 exit_dialog.title("Completing the [ProductName] Installer")
462 exit_dialog.back("< Back", "Finish", active = 0)
463 exit_dialog.cancel("Cancel", "Back", active = 0)
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000464 exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003,
465 "Special Windows thanks to:\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000466 " Mark Hammond, without whose years of freely \n"
467 " shared Windows expertise, Python for Windows \n"
468 " would still be Python for DOS.")
Tim Peters66cb0182004-08-26 05:23:19 +0000469
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000470 c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003,
471 "{\\VerdanaRed9}Warning: Python 2.5.x is the last "
472 "Python release for Windows 9x.")
Martin v. Löwisdf511792006-03-28 07:51:51 +0000473 c.condition("Hide", "NOT Version9X")
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000474
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000475 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000476 "Click the Finish button to exit the Installer.")
477 c = exit_dialog.next("Finish", "Cancel", name="Finish")
478 c.event("EndDialog", "Return")
479
480 #####################################################################
481 # Required dialog: FilesInUse, ErrorDlg
482 inuse = PyDialog(db, "FilesInUse",
483 x, y, w, h,
484 19, # KeepModeless|Modal|Visible
485 title,
486 "Retry", "Retry", "Retry", bitmap=False)
487 inuse.text("Title", 15, 6, 200, 15, 0x30003,
488 r"{\DlgFontBold8}Files in Use")
489 inuse.text("Description", 20, 23, 280, 20, 0x30003,
490 "Some files that need to be updated are currently in use.")
491 inuse.text("Text", 20, 55, 330, 50, 3,
492 "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.")
493 inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
494 None, None, None)
495 c=inuse.back("Exit", "Ignore", name="Exit")
496 c.event("EndDialog", "Exit")
497 c=inuse.next("Ignore", "Retry", name="Ignore")
498 c.event("EndDialog", "Ignore")
499 c=inuse.cancel("Retry", "Exit", name="Retry")
500 c.event("EndDialog","Retry")
501
502
503 # See "Error Dialog". See "ICE20" for the required names of the controls.
504 error = Dialog(db, "ErrorDlg",
505 50, 10, 330, 101,
506 65543, # Error|Minimize|Modal|Visible
507 title,
508 "ErrorText", None, None)
509 error.text("ErrorText", 50,9,280,48,3, "")
510 error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
511 error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
512 error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
513 error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
514 error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
515 error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
516 error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
517 error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
518
519 #####################################################################
520 # Global "Query Cancel" dialog
521 cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
522 "No", "No", "No")
Tim Peters66cb0182004-08-26 05:23:19 +0000523 cancel.text("Text", 48, 15, 194, 30, 3,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000524 "Are you sure you want to cancel [ProductName] installation?")
525 cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
526 "py.ico", None, None)
527 c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
528 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000529
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000530 c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
531 c.event("EndDialog", "Return")
532
533 #####################################################################
534 # Global "Wait for costing" dialog
535 costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
536 "Return", "Return", "Return")
537 costing.text("Text", 48, 15, 194, 30, 3,
538 "Please wait while the installer finishes determining your disk space requirements.")
539 costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
540 "py.ico", None, None)
541 c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
542 c.event("EndDialog", "Exit")
543
544 #####################################################################
545 # Preparation dialog: no user input except cancellation
546 prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
547 "Cancel", "Cancel", "Cancel")
548 prep.text("Description", 135, 70, 220, 40, 0x30003,
549 "Please wait while the Installer prepares to guide you through the installation.")
550 prep.title("Welcome to the [ProductName] Installer")
551 c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...")
552 c.mapping("ActionText", "Text")
553 c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None)
554 c.mapping("ActionData", "Text")
555 prep.back("Back", None, active=0)
556 prep.next("Next", None, active=0)
557 c=prep.cancel("Cancel", None)
558 c.event("SpawnDialog", "CancelDlg")
559
560 #####################################################################
561 # Target directory selection
562 seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
563 "Next", "Next", "Cancel")
564 seldlg.title("Select Destination Directory")
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000565 c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003,
566 "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.")
567 c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""')
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000568 seldlg.text("Description", 135, 50, 220, 40, 0x30003,
569 "Please select a directory for the [ProductName] files.")
570
571 seldlg.back("< Back", None, active=0)
572 c = seldlg.next("Next >", "Cancel")
573 c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1)
574 # If the target exists, but we found that we are going to remove old versions, don't bother
575 # confirming that the target directory exists. Strictly speaking, we should determine that
576 # the target directory is indeed the target of the product that we are going to remove, but
577 # I don't know how to do that.
578 c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2)
579 c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3)
580 c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4)
581 c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5)
582
583 c = seldlg.cancel("Cancel", "DirectoryCombo")
584 c.event("SpawnDialog", "CancelDlg")
585
586 seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219,
587 "TARGETDIR", None, "DirectoryList", None)
588 seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR",
589 None, "PathEdit", None)
590 seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None)
591 c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
592 c.event("DirectoryListUp", "0")
593 c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
594 c.event("DirectoryListNew", "0")
595
596 #####################################################################
597 # SelectFeaturesDlg
598 features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space,
599 title, "Tree", "Next", "Cancel")
600 features.title("Customize [ProductName]")
601 features.text("Description", 135, 35, 220, 15, 0x30003,
602 "Select the way you want features to be installed.")
603 features.text("Text", 135,45,220,30, 3,
604 "Click on the icons in the tree below to change the way features will be installed.")
605
606 c=features.back("< Back", "Next")
607 c.event("NewDialog", "SelectDirectoryDlg")
608
609 c=features.next("Next >", "Cancel")
610 c.mapping("SelectionNoItems", "Enabled")
611 c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1)
612 c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2)
613
614 c=features.cancel("Cancel", "Tree")
615 c.event("SpawnDialog", "CancelDlg")
616
Tim Peters66cb0182004-08-26 05:23:19 +0000617 # 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 +0000618 features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty",
619 "Tree of selections", "Back", None)
620
621 #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost")
622 #c.mapping("SelectionNoItems", "Enabled")
623 #c.event("Reset", "0")
Tim Peters66cb0182004-08-26 05:23:19 +0000624
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000625 features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None)
626
627 c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10)
628 c.mapping("SelectionNoItems","Enabled")
629 c.event("SpawnDialog", "DiskCostDlg")
630
631 c=features.xbutton("Advanced", "Advanced", None, 0.30)
632 c.event("SpawnDialog", "AdvancedDlg")
633
634 c=features.text("ItemDescription", 140, 180, 210, 30, 3,
635 "Multiline description of the currently selected item.")
636 c.mapping("SelectionDescription","Text")
Tim Peters66cb0182004-08-26 05:23:19 +0000637
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000638 c=features.text("ItemSize", 140, 210, 210, 45, 3,
639 "The size of the currently selected item.")
640 c.mapping("SelectionSize", "Text")
641
642 #####################################################################
643 # Disk cost
644 cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
645 "OK", "OK", "OK", bitmap=False)
646 cost.text("Title", 15, 6, 200, 15, 0x30003,
647 "{\DlgFontBold8}Disk Space Requirements")
648 cost.text("Description", 20, 20, 280, 20, 0x30003,
649 "The disk space required for the installation of the selected features.")
650 cost.text("Text", 20, 53, 330, 60, 3,
651 "The highlighted volumes (if any) do not have enough disk space "
652 "available for the currently selected features. You can either "
653 "remove some files from the highlighted volumes, or choose to "
654 "install less features onto local drive(s), or select different "
655 "destination drive(s).")
656 cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
657 None, "{120}{70}{70}{70}{70}", None, None)
658 cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
659
660 #####################################################################
661 # WhichUsers Dialog. Only available on NT, and for privileged users.
662 # This must be run before FindRelatedProducts, because that will
663 # take into account whether the previous installation was per-user
664 # or per-machine. We currently don't support going back to this
665 # dialog after "Next" was selected; to support this, we would need to
666 # find how to reset the ALLUSERS property, and how to re-run
667 # FindRelatedProducts.
668 # On Windows9x, the ALLUSERS property is ignored on the command line
669 # and in the Property table, but installer fails according to the documentation
670 # if a dialog attempts to set ALLUSERS.
671 whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
672 "AdminInstall", "Next", "Cancel")
673 whichusers.title("Select whether to install [ProductName] for all users of this computer.")
674 # A radio group with two options: allusers, justme
675 g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3,
676 "WhichUsers", "", "Next")
677 g.add("ALL", 0, 5, 150, 20, "Install for all users")
678 g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
679
Tim Peters66cb0182004-08-26 05:23:19 +0000680 whichusers.back("Back", None, active=0)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000681
682 c = whichusers.next("Next >", "Cancel")
683 c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
684 c.event("EndDialog", "Return", order = 2)
685
686 c = whichusers.cancel("Cancel", "AdminInstall")
687 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000688
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000689 #####################################################################
690 # Advanced Dialog.
691 advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
692 "CompilePyc", "Next", "Cancel")
693 advanced.title("Advanced Options for [ProductName]")
694 # A radio group with two options: allusers, justme
695 advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
696 "COMPILEALL", "Compile .py files to byte code after installation", "Next")
697
698 c = advanced.next("Finish", "Cancel")
699 c.event("EndDialog", "Return")
700
701 c = advanced.cancel("Cancel", "CompilePyc")
702 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000703
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000704 #####################################################################
Tim Peters66cb0182004-08-26 05:23:19 +0000705 # Existing Directory dialog
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000706 dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
707 "No", "No", "No")
708 dlg.text("Title", 10, 20, 180, 40, 3,
709 "[TARGETDIR] exists. Are you sure you want to overwrite existing files?")
710 c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No")
711 c.event("[TargetExists]", "0", order=1)
712 c.event("[TargetExistsOk]", "1", order=2)
713 c.event("EndDialog", "Return", order=3)
714 c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes")
715 c.event("EndDialog", "Return")
716
717 #####################################################################
718 # Installation Progress dialog (modeless)
719 progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
720 "Cancel", "Cancel", "Cancel", bitmap=False)
721 progress.text("Title", 20, 15, 200, 15, 0x30003,
722 "{\DlgFontBold8}[Progress1] [ProductName]")
723 progress.text("Text", 35, 65, 300, 30, 3,
724 "Please wait while the Installer [Progress2] [ProductName]. "
725 "This may take several minutes.")
726 progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
727
728 c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
729 c.mapping("ActionText", "Text")
730
731 #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
732 #c.mapping("ActionData", "Text")
733
734 c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
735 None, "Progress done", None, None)
736 c.mapping("SetProgress", "Progress")
737
738 progress.back("< Back", "Next", active=False)
739 progress.next("Next >", "Cancel", active=False)
740 progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
741
742 # Maintenance type: repair/uninstall
743 maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
744 "Next", "Next", "Cancel")
745 maint.title("Welcome to the [ProductName] Setup Wizard")
746 maint.text("BodyText", 135, 63, 230, 42, 3,
747 "Select whether you want to repair or remove [ProductName].")
748 g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3,
749 "MaintenanceForm_Action", "", "Next")
750 g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
751 g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
752 g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
Tim Peters66cb0182004-08-26 05:23:19 +0000753
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000754 maint.back("< Back", None, active=False)
755 c=maint.next("Finish", "Cancel")
756 # Change installation: Change progress dialog to "Change", then ask
757 # for feature selection
758 c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
759 c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
760
761 # Reinstall: Change progress dialog to "Repair", then invoke reinstall
762 # Also set list of reinstalled features to "ALL"
763 c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
764 c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
Raymond Hettinger72f08012004-11-07 07:08:25 +0000765 c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000766 c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
767
768 # Uninstall: Change progress to "Remove", then invoke uninstall
769 # Also set list of removed features to "ALL"
770 c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
771 c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
772 c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
773 c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
774
Tim Peters66cb0182004-08-26 05:23:19 +0000775 # Close dialog when maintenance action scheduled
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000776 c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
777 c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
Tim Peters66cb0182004-08-26 05:23:19 +0000778
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000779 maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000780
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000781
782# See "Feature Table". The feature level is 1 for all features,
783# and the feature attributes are 0 for the DefaultFeature, and
784# FollowParent for all other features. The numbers are the Display
785# column.
786def add_features(db):
787 # feature attributes:
788 # msidbFeatureAttributesFollowParent == 2
789 # msidbFeatureAttributesDisallowAdvertise == 8
790 # Features that need to be installed with together with the main feature
791 # (i.e. additional Python libraries) need to follow the parent feature.
792 # Features that have no advertisement trigger (e.g. the test suite)
793 # must not support advertisement
Martin v. Löwise411f892008-04-07 14:54:16 +0000794 global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature, private_crt
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000795 default_feature = Feature(db, "DefaultFeature", "Python",
796 "Python Interpreter and Libraries",
797 1, directory = "TARGETDIR")
Martin v. Löwis4dc34152008-04-05 15:48:36 +0000798 shared_crt = Feature(db, "SharedCRT", "MSVCRT", "C Run-Time (system-wide)", 0,
799 level=0)
800 private_crt = Feature(db, "PrivateCRT", "MSVCRT", "C Run-Time (private)", 0,
801 level=0)
802 add_data(db, "Condition", [("SharedCRT", 1, sys32cond),
803 ("PrivateCRT", 1, "not "+sys32cond)])
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000804 # We don't support advertisement of extensions
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000805 ext_feature = Feature(db, "Extensions", "Register Extensions",
806 "Make this Python installation the default Python installation", 3,
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000807 parent = default_feature, attributes=2|8)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000808 if have_tcl:
809 tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000810 parent = default_feature, attributes=2)
811 htmlfiles = Feature(db, "Documentation", "Documentation",
812 "Python HTMLHelp File", 7, parent = default_feature)
813 tools = Feature(db, "Tools", "Utility Scripts",
Tim Peters66cb0182004-08-26 05:23:19 +0000814 "Python utility scripts (Tools/", 9,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000815 parent = default_feature, attributes=2)
816 testsuite = Feature(db, "Testsuite", "Test suite",
817 "Python test suite (Lib/test/)", 11,
818 parent = default_feature, attributes=2|8)
Tim Peters66cb0182004-08-26 05:23:19 +0000819
Christian Heimes9acba042007-12-04 14:57:30 +0000820def extract_msvcr90():
Martin v. Löwis03dc56c2008-02-28 22:20:50 +0000821 # Find the redistributable files
822 dir = os.path.join(os.environ['VS90COMNTOOLS'], r"..\..\VC\redist\x86\Microsoft.VC90.CRT")
Christian Heimes9acba042007-12-04 14:57:30 +0000823
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000824 result = []
Christian Heimes9acba042007-12-04 14:57:30 +0000825 installer = msilib.MakeInstaller()
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000826 # omit msvcm90 and msvcp90, as they aren't really needed
827 files = ["Microsoft.VC90.CRT.manifest", "msvcr90.dll"]
828 for f in files:
829 path = os.path.join(dir, f)
830 kw = {'src':path}
831 if f.endswith('.dll'):
832 kw['version'] = installer.FileVersion(path, 0)
833 kw['language'] = installer.FileVersion(path, 1)
834 result.append((f, kw))
835 return result
Christian Heimes9acba042007-12-04 14:57:30 +0000836
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000837class PyDirectory(Directory):
838 """By default, all components in the Python installer
839 can run from source."""
840 def __init__(self, *args, **kw):
841 if not kw.has_key("componentflags"):
842 kw['componentflags'] = 2 #msidbComponentAttributesOptional
843 Directory.__init__(self, *args, **kw)
844
845# See "File Table", "Component Table", "Directory Table",
846# "FeatureComponents Table"
847def add_files(db):
848 cab = CAB("python")
849 tmpfiles = []
850 # Add all executables, icons, text files into the TARGETDIR component
851 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
852 default_feature.set_current()
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000853 if not msilib.Win64:
Christian Heimes9acba042007-12-04 14:57:30 +0000854 root.add_file("%s/w9xpopen.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000855 root.add_file("README.txt", src="README")
856 root.add_file("NEWS.txt", src="Misc/NEWS")
857 root.add_file("LICENSE.txt", src="LICENSE")
858 root.start_component("python.exe", keyfile="python.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000859 root.add_file("%s/python.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000860 root.start_component("pythonw.exe", keyfile="pythonw.exe")
Christian Heimes9acba042007-12-04 14:57:30 +0000861 root.add_file("%s/pythonw.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000862
863 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000864 #dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
865 #install python30.dll into root dir for now
866 dlldir = root
867
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000868 pydll = "python%s%s.dll" % (major, minor)
Christian Heimes9acba042007-12-04 14:57:30 +0000869 pydllsrc = os.path.join(srcdir, PCBUILD, pydll)
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000870 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000871 installer = msilib.MakeInstaller()
872 pyversion = installer.FileVersion(pydllsrc, 0)
873 if not snapshot:
874 # For releases, the Python DLL has the same version as the
875 # installer package.
876 assert pyversion.split(".")[:3] == current_version.split(".")
Christian Heimes9acba042007-12-04 14:57:30 +0000877 dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000878 version=pyversion,
879 language=installer.FileVersion(pydllsrc, 1))
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000880 DLLs = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
Martin v. Löwis1e72fec2008-04-07 16:34:04 +0000881
882 # msvcr90.dll: Need to place the DLL and the manifest into the root directory,
883 # plus another copy of the manifest in the DLLs directory, with the manifest
884 # pointing to the root directory
Martin v. Löwis46a8be72008-04-07 14:55:53 +0000885 root.start_component("msvcr90", feature=private_crt)
Martin v. Löwis1e72fec2008-04-07 16:34:04 +0000886 # Results are ID,keyword pairs
887 manifest, crtdll = extract_msvcr90()
888 root.add_file(manifest[0], **manifest[1])
889 root.add_file(crtdll[0], **crtdll[1])
890 # Copy the manifest
891 manifest_dlls = manifest[0]+".root"
892 open(manifest_dlls, "w").write(open(manifest[1]['src']).read().replace("msvcr","../msvcr"))
893 DLLs.start_component("msvcr90_dlls", feature=private_crt)
894 DLLs.add_file(manifest[0], src=os.path.abspath(manifest_dlls))
895
896 # Now start the main component for the DLLs directory;
897 # no regular files have been added to the directory yet.
898 DLLs.start_component()
Tim Peters66cb0182004-08-26 05:23:19 +0000899
Martin v. Löwis38325b72006-08-25 00:03:34 +0000900 # Check if _ctypes.pyd exists
Christian Heimes9acba042007-12-04 14:57:30 +0000901 have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
Martin v. Löwis38325b72006-08-25 00:03:34 +0000902 if not have_ctypes:
903 print "WARNING: _ctypes.pyd not found, ctypes will not be included"
904 extensions.remove("_ctypes.pyd")
Tim Peters147f9ae2006-08-25 22:05:39 +0000905
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000906 # Add all .py files in Lib, except lib-tk, test
907 dirs={}
908 pydirs = [(root,"Lib")]
909 while pydirs:
910 parent, dir = pydirs.pop()
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000911 if dir == ".svn" or dir.startswith("plat-"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000912 continue
913 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000914 if not have_tcl:
915 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000916 tcltk.set_current()
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000917 elif dir in ['test', 'tests', 'data', 'output']:
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000918 # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000919 # tests: Lib/distutils
920 # data: Lib/email/test
921 # output: Lib/test
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000922 testsuite.set_current()
Martin v. Löwis38325b72006-08-25 00:03:34 +0000923 elif not have_ctypes and dir == "ctypes":
924 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000925 else:
926 default_feature.set_current()
927 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
928 # Add additional files
929 dirs[dir]=lib
930 lib.glob("*.txt")
931 if dir=='site-packages':
Martin v. Löwis6d60c092004-11-21 10:16:26 +0000932 lib.add_file("README.txt", src="README")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000933 continue
934 files = lib.glob("*.py")
935 files += lib.glob("*.pyw")
936 if files:
937 # Add an entry to the RemoveFile table to remove bytecode files.
938 lib.remove_pyc()
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000939 if dir.endswith('.egg-info'):
940 lib.add_file('entry_points.txt')
941 lib.add_file('PKG-INFO')
942 lib.add_file('top_level.txt')
943 lib.add_file('zip-safe')
944 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000945 if dir=='test' and parent.physical=='Lib':
946 lib.add_file("185test.db")
947 lib.add_file("audiotest.au")
948 lib.add_file("cfgparser.1")
Martin v. Löwisc0fdb182006-09-12 19:49:20 +0000949 lib.add_file("sgml_input.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000950 lib.add_file("test.xml")
951 lib.add_file("test.xml.out")
952 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000953 lib.add_file("test_difflib_expect.html")
Martin v. Löwis59c3acc2006-04-03 12:07:46 +0000954 lib.add_file("check_soundcard.vbs")
Thomas Heller3bd33152006-04-04 18:41:13 +0000955 lib.add_file("empty.vbs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000956 lib.glob("*.uue")
Martin v. Löwis0ffdacd2007-11-20 02:46:02 +0000957 lib.glob("*.pem")
Martin v. Löwis6b449f42007-12-03 19:20:02 +0000958 lib.glob("*.pck")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000959 lib.add_file("readme.txt", src="README")
960 if dir=='decimaltestdata':
961 lib.glob("*.decTest")
962 if dir=='output':
963 lib.glob("test_*")
964 if dir=='idlelib':
965 lib.glob("*.def")
966 lib.add_file("idle.bat")
967 if dir=="Icons":
968 lib.glob("*.gif")
969 lib.add_file("idle.icns")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000970 if dir=="command" and parent.physical=="distutils":
Martin v. Löwis023b9f92008-04-09 18:56:20 +0000971 lib.glob("wininst*.exe")
Martin v. Löwis64ed0432006-04-21 10:00:46 +0000972 if dir=="setuptools":
973 lib.add_file("cli.exe")
974 lib.add_file("gui.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000975 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000976 # This should contain all non-.svn files listed in subversion
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000977 for f in os.listdir(lib.absolute):
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000978 if f.endswith(".txt") or f==".svn":continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000979 if f.endswith(".au") or f.endswith(".gif"):
980 lib.add_file(f)
981 else:
982 print "WARNING: New file %s in email/test/data" % f
983 for f in os.listdir(lib.absolute):
984 if os.path.isdir(os.path.join(lib.absolute, f)):
985 pydirs.append((lib, f))
986 # Add DLLs
987 default_feature.set_current()
Martin v. Löwisd9759c42008-02-28 19:57:34 +0000988 lib = DLLs
Christian Heimes7e28e492008-01-01 13:52:57 +0000989 lib.add_file("py.ico", src=srcdir+"/PC/py.ico")
Christian Heimese1c6af02008-01-01 13:58:16 +0000990 lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000991 dlls = []
992 tclfiles = []
993 for f in extensions:
994 if f=="_tkinter.pyd":
995 continue
Christian Heimes9acba042007-12-04 14:57:30 +0000996 if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000997 print "WARNING: Missing extension", f
998 continue
999 dlls.append(f)
1000 lib.add_file(f)
Martin v. Löwis88ef6372006-07-06 06:55:58 +00001001 # Add sqlite
1002 if msilib.msi_type=="Intel64;1033":
1003 sqlite_arch = "/ia64"
1004 elif msilib.msi_type=="x64;1033":
1005 sqlite_arch = "/amd64"
Martin v. Löwis0e795e72008-02-29 20:54:44 +00001006 tclsuffix = "64"
Martin v. Löwis88ef6372006-07-06 06:55:58 +00001007 else:
1008 sqlite_arch = ""
Martin v. Löwis0e795e72008-02-29 20:54:44 +00001009 tclsuffix = ""
Martin v. Löwis88ef6372006-07-06 06:55:58 +00001010 lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001011 if have_tcl:
Christian Heimes9acba042007-12-04 14:57:30 +00001012 if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001013 print "WARNING: Missing _tkinter.pyd"
1014 else:
1015 lib.start_component("TkDLLs", tcltk)
1016 lib.add_file("_tkinter.pyd")
1017 dlls.append("_tkinter.pyd")
Martin v. Löwis0e795e72008-02-29 20:54:44 +00001018 tcldir = os.path.normpath(srcdir+("/../tcltk%s/bin" % tclsuffix))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001019 for f in glob.glob1(tcldir, "*.dll"):
1020 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001021 # check whether there are any unknown extensions
Christian Heimes9acba042007-12-04 14:57:30 +00001022 for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001023 if f.endswith("_d.pyd"): continue # debug version
1024 if f in dlls: continue
1025 print "WARNING: Unknown extension", f
Tim Peters66cb0182004-08-26 05:23:19 +00001026
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001027 # Add headers
1028 default_feature.set_current()
1029 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
1030 lib.glob("*.h")
1031 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
1032 # Add import libraries
Christian Heimes9acba042007-12-04 14:57:30 +00001033 lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001034 for f in dlls:
1035 lib.add_file(f.replace('pyd','lib'))
1036 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +00001037 # Add the mingw-format library
1038 if have_mingw:
Tim Peters5a9fb3c2005-01-07 16:01:32 +00001039 lib.add_file('libpython%s%s.a' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001040 if have_tcl:
1041 # Add Tcl/Tk
Martin v. Löwis0e795e72008-02-29 20:54:44 +00001042 tcldirs = [(root, '../tcltk%s/lib' % tclsuffix, 'tcl')]
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001043 tcltk.set_current()
1044 while tcldirs:
1045 parent, phys, dir = tcldirs.pop()
1046 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
1047 if not os.path.exists(lib.absolute):
1048 continue
1049 for f in os.listdir(lib.absolute):
1050 if os.path.isdir(os.path.join(lib.absolute, f)):
1051 tcldirs.append((lib, f, f))
1052 else:
1053 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001054 # Add tools
1055 tools.set_current()
1056 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
1057 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
1058 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1059 lib.glob("*.py")
1060 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1061 lib.remove_pyc()
1062 lib.glob("*.txt")
1063 if f == "pynche":
1064 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1065 x.glob("*.txt")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001066 if os.path.exists(os.path.join(lib.absolute, "README")):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001067 lib.add_file("README.txt", src="README")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001068 if f == 'Scripts':
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001069 if have_tcl:
1070 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1071 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001072 # Add documentation
1073 htmlfiles.set_current()
1074 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
1075 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
Martin v. Löwis8628f752007-09-10 10:21:22 +00001076 lib.add_file("Python%s%s.chm" % (major, minor), src="build/htmlhelp/pydoc.chm")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001077
1078 cab.commit(db)
1079
1080 for f in tmpfiles:
1081 os.unlink(f)
1082
1083# See "Registry Table", "Component Table"
1084def add_registry(db):
1085 # File extensions, associated with the REGISTRY.def component
1086 # IDLE verbs depend on the tcltk feature.
1087 # msidbComponentAttributesRegistryKeyPath = 4
1088 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001089 tcldata = []
1090 if have_tcl:
1091 tcldata = [
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001092 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001093 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001094 add_data(db, "Component",
1095 # msidbComponentAttributesRegistryKeyPath = 4
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001096 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001097 "InstallPath"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001098 ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001099 "Documentation"),
Martin v. Löwis1ab4a1f2007-08-31 10:01:07 +00001100 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001101 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001102 # See "FeatureComponents Table".
1103 # The association between TclTk and pythonw.exe is necessary to make ICE59
1104 # happy, because the installer otherwise believes that the IDLE and PyDoc
1105 # shortcuts might get installed without pythonw.exe being install. This
1106 # is not true, since installing TclTk will install the default feature, which
1107 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001108 # REGISTRY.tcl is not associated with any feature, as it will be requested
1109 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001110 tcldata = []
1111 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001112 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001113 add_data(db, "FeatureComponents",
1114 [(default_feature.id, "REGISTRY"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001115 (htmlfiles.id, "REGISTRY.doc"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001116 (ext_feature.id, "REGISTRY.def")] +
1117 tcldata
1118 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001119 # Extensions are not advertised. For advertised extensions,
1120 # we would need separate binaries that install along with the
1121 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001122 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1123 ewi = "Edit with IDLE"
1124 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1125 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001126 tcl_verbs = []
1127 if have_tcl:
1128 tcl_verbs=[
1129 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1130 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1131 "REGISTRY.tcl"),
1132 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1133 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1134 "REGISTRY.tcl"),
1135 ]
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001136 add_data(db, "Registry",
1137 [# Extensions
1138 ("py.ext", -1, r"Software\Classes\."+ext, "",
1139 "Python.File", "REGISTRY.def"),
1140 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1141 "Python.NoConFile", "REGISTRY.def"),
1142 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1143 "Python.CompiledFile", "REGISTRY.def"),
1144 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1145 "Python.CompiledFile", "REGISTRY.def"),
1146 # MIME types
1147 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1148 "text/plain", "REGISTRY.def"),
1149 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1150 "text/plain", "REGISTRY.def"),
1151 #Verbs
1152 ("py.open", -1, pat % (testprefix, "", "open"), "",
1153 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1154 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1155 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1156 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1157 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001158 ] + tcl_verbs + [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001159 #Icons
1160 ("py.icon", -1, pat2 % (testprefix, ""), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001161 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001162 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001163 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001164 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
Martin v. Löwis1319bb12006-05-12 13:57:36 +00001165 r'[DLLs]pyc.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001166 # Descriptions
1167 ("py.txt", -1, pat3 % (testprefix, ""), "",
1168 "Python File", "REGISTRY.def"),
1169 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1170 "Python File (no console)", "REGISTRY.def"),
1171 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1172 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001173 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001174
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001175 # Registry keys
1176 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1177 add_data(db, "Registry",
1178 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1179 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1180 "Python %s" % short_version, "REGISTRY"),
1181 ("PythonPath", -1, prefix+r"\PythonPath", "",
Martin v. Löwisf13337d2004-09-19 18:36:45 +00001182 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001183 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001184 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001185 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1186 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1187 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1188 ])
1189 # Shortcuts, see "Shortcut Table"
1190 add_data(db, "Directory",
1191 [("ProgramMenuFolder", "TARGETDIR", "."),
1192 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1193 add_data(db, "RemoveFile",
1194 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001195 tcltkshortcuts = []
1196 if have_tcl:
1197 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001198 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001199 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 +00001200 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001201 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 +00001202 ]
1203 add_data(db, "Shortcut",
1204 tcltkshortcuts +
1205 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001206 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1207 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001208 # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an
1209 # icon first.
1210 #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1211 # htmlfiles.id, None, None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001212 ## Non-advertised shortcuts: must be associated with a registry component
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001213 ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
1214 "[#Python%s%s.chm]" % (major,minor), None,
1215 None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001216 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1217 SystemFolderName+"msiexec", "/x%s" % product_code,
1218 None, None, None, None, None, None),
1219 ])
1220 db.Commit()
1221
1222db = build_database()
1223try:
1224 add_features(db)
1225 add_ui(db)
1226 add_files(db)
1227 add_registry(db)
1228 remove_old_versions(db)
1229 db.Commit()
1230finally:
1231 del db