blob: b48604cbb8c503605cec9da7608f19631da2bb91 [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 Heimes81ca7c72007-11-18 18:18:41 +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
Thomas Wouters49fd7fa2006-04-21 10:40:58 +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
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000027# Where is sqlite3.dll located, relative to srcdir?
28sqlite_dir = "../sqlite-source-3.3.4"
Christian Heimes81ca7c72007-11-18 18:18:41 +000029# path to PCbuild directory
Christian Heimesfaf2f632008-01-06 16:59:19 +000030PCBUILD="PCbuild"
Christian Heimes81ca7c72007-11-18 18:18:41 +000031# msvcrt version
Christian Heimesfaf2f632008-01-06 16:59:19 +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',
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000095 '_ctypes_test.pyd',
Thomas Wouters00ee7ba2006-08-21 19:07:27 +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 Heimesd0764e22007-12-04 15:00:33 +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öwis4c6c7ca2007-08-30 15:23:04 +0000110 "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}",
Guido van Rossumaf554a02007-08-16 23:48:43 +0000111 "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}",
Martin v. Löwis4c6c7ca2007-08-30 15:23:04 +0000112 "30":"{6953bc3b-6768-4291-8410-7914ce6e2ca8}",
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000113 } [major+minor]
Tim Peterseba28be2005-03-28 01:08:02 +0000114
Alexandre Vassalotti6461e102008-05-15 22:09:29 +0000115# Compute the name that Sphinx gives to the docfile
116docfile = ""
117if level < 0xf:
118 docfile = '%x%s' % (level, serial)
119docfile = 'python%s%s%s.chm' % (major, minor, docfile)
120
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000121# Build the mingw import library, libpythonXY.a
122# This requires 'nm' and 'dlltool' executables on your PATH
123def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
124 warning = "WARNING: %s - libpythonXX.a not built"
125 nm = find_executable('nm')
126 dlltool = find_executable('dlltool')
127
128 if not nm or not dlltool:
Collin Winter6afaeb72007-08-03 17:06:41 +0000129 print(warning % "nm and/or dlltool were not found")
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000130 return False
131
132 nm_command = '%s -Cs %s' % (nm, lib_file)
133 dlltool_command = "%s --dllname %s --def %s --output-lib %s" % \
134 (dlltool, dll_file, def_file, mingw_lib)
135 export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match
136
137 f = open(def_file,'w')
Martin v. Löwis4c6c7ca2007-08-30 15:23:04 +0000138 f.write("LIBRARY %s\n" % dll_file)
139 f.write("EXPORTS\n")
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000140
141 nm_pipe = os.popen(nm_command)
142 for line in nm_pipe.readlines():
143 m = export_match(line)
144 if m:
Martin v. Löwis4c6c7ca2007-08-30 15:23:04 +0000145 f.write(m.group(1)+"\n")
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000146 f.close()
147 exit = nm_pipe.close()
148
149 if exit:
Collin Winter6afaeb72007-08-03 17:06:41 +0000150 print(warning % "nm did not run successfully")
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000151 return False
152
153 if os.system(dlltool_command) != 0:
Collin Winter6afaeb72007-08-03 17:06:41 +0000154 print(warning % "dlltool did not run successfully")
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000155 return False
156
157 return True
158
159# Target files (.def and .a) go in PCBuild directory
Christian Heimes81ca7c72007-11-18 18:18:41 +0000160lib_file = os.path.join(srcdir, PCBUILD, "python%s%s.lib" % (major, minor))
161def_file = os.path.join(srcdir, PCBUILD, "python%s%s.def" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000162dll_file = "python%s%s.dll" % (major, minor)
Christian Heimes81ca7c72007-11-18 18:18:41 +0000163mingw_lib = os.path.join(srcdir, PCBUILD, "libpython%s%s.a" % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000164
165have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
166
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000167# Determine the target architechture
Christian Heimes81ca7c72007-11-18 18:18:41 +0000168dll_path = os.path.join(srcdir, PCBUILD, dll_file)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000169msilib.set_arch_from_file(dll_path)
170if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
Collin Wintera817e582007-08-22 23:05:06 +0000171 raise SystemError("msisupport.dll for incorrect architecture")
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000172
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000173if testpackage:
174 ext = 'px'
175 testprefix = 'x'
176else:
177 ext = 'py'
178 testprefix = ''
179
180if msilib.Win64:
Martin v. Löwis47cc2a02007-08-30 18:27:06 +0000181 SystemFolderName = "[System64Folder]"
Martin v. Löwis283e35f2007-08-31 09:59:29 +0000182 registry_component = 4|256
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000183else:
184 SystemFolderName = "[SystemFolder]"
Martin v. Löwis283e35f2007-08-31 09:59:29 +0000185 registry_component = 4
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000186
187msilib.reset()
188
189# condition in which to install pythonxy.dll in system32:
190# a) it is Windows 9x or
191# b) it is NT, the user is privileged, and has chosen per-machine installation
192sys32cond = "(Windows9x or (Privileged and ALLUSERS))"
193
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000194def build_database():
195 """Generate an empty database, with just the schema and the
196 Summary information stream."""
197 if snapshot:
198 uc = upgrade_code_snapshot
199 else:
200 uc = upgrade_code
201 # schema represents the installer 2.0 database schema.
202 # sequence is the set of standard sequences
203 # (ui/execute, admin/advt/install)
Martin v. Löwis856bf9a2006-02-14 20:42:55 +0000204 db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000205 schema, ProductName="Python "+full_current_version,
206 ProductCode=product_code,
207 ProductVersion=current_version,
Martin v. Löwis39afe1e2007-09-01 06:36:49 +0000208 Manufacturer=u"Python Software Foundation")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000209 # The default sequencing of the RemoveExistingProducts action causes
210 # removal of files that got just installed. Place it after
211 # InstallInitialize, so we first uninstall everything, but still roll
212 # back in case the installation is interrupted
213 msilib.change_sequence(sequence.InstallExecuteSequence,
214 "RemoveExistingProducts", 1510)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000215 msilib.add_tables(db, sequence)
216 # We cannot set ALLUSERS in the property table, as this cannot be
217 # reset if the user choses a per-user installation. Instead, we
218 # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages
219 # this property, and when the execution starts, ALLUSERS is set
220 # accordingly.
221 add_data(db, "Property", [("UpgradeCode", uc),
222 ("WhichUsers", "ALL"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000223 ("ProductLine", "Python%s%s" % (major, minor)),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000224 ])
225 db.Commit()
226 return db
227
228def remove_old_versions(db):
229 "Fill the upgrade table."
230 start = "%s.%s.0" % (major, minor)
231 # This requests that feature selection states of an older
232 # installation should be forwarded into this one. Upgrading
233 # requires that both the old and the new installation are
234 # either both per-machine or per-user.
235 migrate_features = 1
236 # See "Upgrade Table". We remove releases with the same major and
237 # minor version. For an snapshot, we remove all earlier snapshots. For
238 # a release, we remove all snapshots, and all earlier releases.
239 if snapshot:
240 add_data(db, "Upgrade",
Tim Peters66cb0182004-08-26 05:23:19 +0000241 [(upgrade_code_snapshot, start,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000242 current_version,
243 None, # Ignore language
Tim Peters66cb0182004-08-26 05:23:19 +0000244 migrate_features,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000245 None, # Migrate ALL features
246 "REMOVEOLDSNAPSHOT")])
247 props = "REMOVEOLDSNAPSHOT"
248 else:
249 add_data(db, "Upgrade",
250 [(upgrade_code, start, current_version,
251 None, migrate_features, None, "REMOVEOLDVERSION"),
252 (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1),
253 None, migrate_features, None, "REMOVEOLDSNAPSHOT")])
254 props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION"
255 # Installer collects the product codes of the earlier releases in
256 # these properties. In order to allow modification of the properties,
257 # they must be declared as secure. See "SecureCustomProperties Property"
258 add_data(db, "Property", [("SecureCustomProperties", props)])
259
260class PyDialog(Dialog):
261 """Dialog class with a fixed layout: controls at the top, then a ruler,
262 then a list of buttons: back, next, cancel. Optionally a bitmap at the
263 left."""
264 def __init__(self, *args, **kw):
265 """Dialog(database, name, x, y, w, h, attributes, title, first,
266 default, cancel, bitmap=true)"""
267 Dialog.__init__(self, *args)
268 ruler = self.h - 36
269 bmwidth = 152*ruler/328
270 if kw.get("bitmap", True):
271 self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
272 self.line("BottomLine", 0, ruler, self.w, 0)
273
274 def title(self, title):
275 "Set the title text of the dialog at the top."
276 # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
277 # text, in VerdanaBold10
278 self.text("Title", 135, 10, 220, 60, 0x30003,
279 r"{\VerdanaBold10}%s" % title)
280
281 def back(self, title, next, name = "Back", active = 1):
282 """Add a back button with a given title, the tab-next button,
283 its name in the Control table, possibly initially disabled.
284
285 Return the button, so that events can be associated"""
286 if active:
287 flags = 3 # Visible|Enabled
288 else:
289 flags = 1 # Visible
290 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
291
292 def cancel(self, title, next, name = "Cancel", active = 1):
293 """Add a cancel button with a given title, the tab-next button,
294 its name in the Control table, possibly initially disabled.
295
296 Return the button, so that events can be associated"""
297 if active:
298 flags = 3 # Visible|Enabled
299 else:
300 flags = 1 # Visible
301 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
302
303 def next(self, title, next, name = "Next", active = 1):
304 """Add a Next button with a given title, the tab-next button,
305 its name in the Control table, possibly initially disabled.
306
307 Return the button, so that events can be associated"""
308 if active:
309 flags = 3 # Visible|Enabled
310 else:
311 flags = 1 # Visible
312 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
313
314 def xbutton(self, name, title, next, xpos):
315 """Add a button with a given title, the tab-next button,
316 its name in the Control table, giving its x position; the
317 y-position is aligned with the other buttons.
318
319 Return the button, so that events can be associated"""
320 return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
321
322def add_ui(db):
323 x = y = 50
324 w = 370
325 h = 300
326 title = "[ProductName] Setup"
327
328 # see "Dialog Style Bits"
329 modal = 3 # visible | modal
330 modeless = 1 # visible
331 track_disk_space = 32
332
333 add_data(db, 'ActionText', uisample.ActionText)
334 add_data(db, 'UIText', uisample.UIText)
335
336 # Bitmaps
337 if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
338 raise "Run icons.mak in PC directory"
339 add_data(db, "Binary",
Christian Heimesd9a4d1d2008-01-01 14:42:15 +0000340 [("PythonWin", msilib.Binary(r"%s\PCbuild\installer.bmp" % srcdir)), # 152x328 pixels
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000341 ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
342 ])
343 add_data(db, "Icon",
344 [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))])
345
346 # Scripts
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000347 # CheckDir sets TargetExists if TARGETDIR exists.
348 # UpdateEditIDLE sets the REGISTRY.tcl component into
349 # the installed/uninstalled state according to both the
350 # Extensions and TclTk features.
Martin v. Löwiseb68be42004-12-12 15:29:21 +0000351 if os.system("nmake /nologo /c /f msisupport.mak") != 0:
352 raise "'nmake /f msisupport.mak' failed"
353 add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
354 # See "Custom Action Type 1"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000355 if msilib.Win64:
356 CheckDir = "CheckDir"
Martin v. Löwisdf40ce32006-02-16 14:38:30 +0000357 UpdateEditIDLE = "UpdateEditIDLE"
Martin v. Löwis3390d332005-03-14 17:20:13 +0000358 else:
359 CheckDir = "_CheckDir@4"
360 UpdateEditIDLE = "_UpdateEditIDLE@4"
Tim Peters0e9980f2004-09-12 03:49:31 +0000361 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000362 [("CheckDir", 1, "Script", CheckDir)])
Martin v. Löwiseac02e62004-11-18 08:00:33 +0000363 if have_tcl:
364 add_data(db, "CustomAction",
Martin v. Löwis3390d332005-03-14 17:20:13 +0000365 [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)])
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000366
367 # UI customization properties
368 add_data(db, "Property",
369 # See "DefaultUIFont Property"
370 [("DefaultUIFont", "DlgFont8"),
371 # See "ErrorDialog Style Bit"
372 ("ErrorDialog", "ErrorDlg"),
373 ("Progress1", "Install"), # modified in maintenance type dlg
374 ("Progress2", "installs"),
375 ("MaintenanceForm_Action", "Repair")])
376
377 # Fonts, see "TextStyle Table"
378 add_data(db, "TextStyle",
379 [("DlgFont8", "Tahoma", 9, None, 0),
380 ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
381 ("VerdanaBold10", "Verdana", 10, None, 1),
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000382 ("VerdanaRed9", "Verdana", 9, 255, 0),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000383 ])
384
Martin v. Löwis37475a82008-04-08 17:17:46 +0000385 compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x bad_coding|badsyntax|site-packages|py2_ "[TARGETDIR]Lib"'
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000386 # See "CustomAction Table"
387 add_data(db, "CustomAction", [
388 # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
389 # See "Custom Action Type 51",
390 # "Custom Action Execution Scheduling Options"
391 ("InitialTargetDir", 307, "TARGETDIR",
392 "[WindowsVolume]Python%s%s" % (major, minor)),
393 ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"),
394 ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName),
395 # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile
396 # See "Custom Action Type 18"
Martin v. Löwis7b2563b2004-11-02 22:59:56 +0000397 ("CompilePyc", 18, "python.exe", compileargs),
398 ("CompilePyo", 18, "python.exe", "-O "+compileargs),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000399 ])
400
401 # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
402 # Numbers indicate sequence; see sequence.py for how these action integrate
403 add_data(db, "InstallUISequence",
404 [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
405 ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
406 ("InitialTargetDir", 'TARGETDIR=""', 750),
407 # In the user interface, assume all-users installation if privileged.
408 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
409 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
410 ("SelectDirectoryDlg", "Not Installed", 1230),
411 # XXX no support for resume installations yet
412 #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
413 ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
414 ("ProgressDlg", None, 1280)])
415 add_data(db, "AdminUISequence",
416 [("InitialTargetDir", 'TARGETDIR=""', 750),
417 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
418 ])
419
420 # Execute Sequences
421 add_data(db, "InstallExecuteSequence",
422 [("InitialTargetDir", 'TARGETDIR=""', 750),
423 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
424 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000425 ("UpdateEditIDLE", None, 1050),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000426 ("CompilePyc", "COMPILEALL", 6800),
427 ("CompilePyo", "COMPILEALL", 6801),
428 ])
429 add_data(db, "AdminExecuteSequence",
430 [("InitialTargetDir", 'TARGETDIR=""', 750),
431 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
432 ("CompilePyc", "COMPILEALL", 6800),
433 ("CompilePyo", "COMPILEALL", 6801),
434 ])
435
436 #####################################################################
437 # Standard dialogs: FatalError, UserExit, ExitDialog
438 fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
439 "Finish", "Finish", "Finish")
440 fatal.title("[ProductName] Installer ended prematurely")
441 fatal.back("< Back", "Finish", active = 0)
442 fatal.cancel("Cancel", "Back", active = 0)
443 fatal.text("Description1", 135, 70, 220, 80, 0x30003,
444 "[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.")
445 fatal.text("Description2", 135, 155, 220, 20, 0x30003,
446 "Click the Finish button to exit the Installer.")
447 c=fatal.next("Finish", "Cancel", name="Finish")
448 # See "ControlEvent Table". Parameters are the event, the parameter
449 # to the action, and optionally the condition for the event, and the order
450 # of events.
451 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000452
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000453 user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
454 "Finish", "Finish", "Finish")
455 user_exit.title("[ProductName] Installer was interrupted")
456 user_exit.back("< Back", "Finish", active = 0)
457 user_exit.cancel("Cancel", "Back", active = 0)
458 user_exit.text("Description1", 135, 70, 220, 80, 0x30003,
459 "[ProductName] setup was interrupted. Your system has not been modified. "
460 "To install this program at a later time, please run the installation again.")
461 user_exit.text("Description2", 135, 155, 220, 20, 0x30003,
462 "Click the Finish button to exit the Installer.")
463 c = user_exit.next("Finish", "Cancel", name="Finish")
464 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000465
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000466 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
467 "Finish", "Finish", "Finish")
468 exit_dialog.title("Completing the [ProductName] Installer")
469 exit_dialog.back("< Back", "Finish", active = 0)
470 exit_dialog.cancel("Cancel", "Back", active = 0)
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000471 exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003,
472 "Special Windows thanks to:\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000473 " Mark Hammond, without whose years of freely \n"
474 " shared Windows expertise, Python for Windows \n"
475 " would still be Python for DOS.")
Tim Peters66cb0182004-08-26 05:23:19 +0000476
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000477 c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003,
478 "{\\VerdanaRed9}Warning: Python 2.5.x is the last "
479 "Python release for Windows 9x.")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000480 c.condition("Hide", "NOT Version9X")
Martin v. Löwis8c7c56e2006-03-05 14:04:26 +0000481
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000482 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000483 "Click the Finish button to exit the Installer.")
484 c = exit_dialog.next("Finish", "Cancel", name="Finish")
485 c.event("EndDialog", "Return")
486
487 #####################################################################
488 # Required dialog: FilesInUse, ErrorDlg
489 inuse = PyDialog(db, "FilesInUse",
490 x, y, w, h,
491 19, # KeepModeless|Modal|Visible
492 title,
493 "Retry", "Retry", "Retry", bitmap=False)
494 inuse.text("Title", 15, 6, 200, 15, 0x30003,
495 r"{\DlgFontBold8}Files in Use")
496 inuse.text("Description", 20, 23, 280, 20, 0x30003,
497 "Some files that need to be updated are currently in use.")
498 inuse.text("Text", 20, 55, 330, 50, 3,
499 "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.")
500 inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
501 None, None, None)
502 c=inuse.back("Exit", "Ignore", name="Exit")
503 c.event("EndDialog", "Exit")
504 c=inuse.next("Ignore", "Retry", name="Ignore")
505 c.event("EndDialog", "Ignore")
506 c=inuse.cancel("Retry", "Exit", name="Retry")
507 c.event("EndDialog","Retry")
508
509
510 # See "Error Dialog". See "ICE20" for the required names of the controls.
511 error = Dialog(db, "ErrorDlg",
512 50, 10, 330, 101,
513 65543, # Error|Minimize|Modal|Visible
514 title,
515 "ErrorText", None, None)
516 error.text("ErrorText", 50,9,280,48,3, "")
517 error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
518 error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
519 error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
520 error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
521 error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
522 error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
523 error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
524 error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
525
526 #####################################################################
527 # Global "Query Cancel" dialog
528 cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
529 "No", "No", "No")
Tim Peters66cb0182004-08-26 05:23:19 +0000530 cancel.text("Text", 48, 15, 194, 30, 3,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000531 "Are you sure you want to cancel [ProductName] installation?")
532 cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
533 "py.ico", None, None)
534 c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
535 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000536
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000537 c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
538 c.event("EndDialog", "Return")
539
540 #####################################################################
541 # Global "Wait for costing" dialog
542 costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
543 "Return", "Return", "Return")
544 costing.text("Text", 48, 15, 194, 30, 3,
545 "Please wait while the installer finishes determining your disk space requirements.")
546 costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
547 "py.ico", None, None)
548 c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
549 c.event("EndDialog", "Exit")
550
551 #####################################################################
552 # Preparation dialog: no user input except cancellation
553 prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
554 "Cancel", "Cancel", "Cancel")
555 prep.text("Description", 135, 70, 220, 40, 0x30003,
556 "Please wait while the Installer prepares to guide you through the installation.")
557 prep.title("Welcome to the [ProductName] Installer")
558 c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...")
559 c.mapping("ActionText", "Text")
560 c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None)
561 c.mapping("ActionData", "Text")
562 prep.back("Back", None, active=0)
563 prep.next("Next", None, active=0)
564 c=prep.cancel("Cancel", None)
565 c.event("SpawnDialog", "CancelDlg")
566
567 #####################################################################
568 # Target directory selection
569 seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
570 "Next", "Next", "Cancel")
571 seldlg.title("Select Destination Directory")
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000572 c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003,
573 "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.")
574 c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""')
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000575 seldlg.text("Description", 135, 50, 220, 40, 0x30003,
576 "Please select a directory for the [ProductName] files.")
577
578 seldlg.back("< Back", None, active=0)
579 c = seldlg.next("Next >", "Cancel")
580 c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1)
581 # If the target exists, but we found that we are going to remove old versions, don't bother
582 # confirming that the target directory exists. Strictly speaking, we should determine that
583 # the target directory is indeed the target of the product that we are going to remove, but
584 # I don't know how to do that.
585 c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2)
586 c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3)
587 c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4)
588 c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5)
589
590 c = seldlg.cancel("Cancel", "DirectoryCombo")
591 c.event("SpawnDialog", "CancelDlg")
592
593 seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219,
594 "TARGETDIR", None, "DirectoryList", None)
595 seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR",
596 None, "PathEdit", None)
597 seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None)
598 c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
599 c.event("DirectoryListUp", "0")
600 c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
601 c.event("DirectoryListNew", "0")
602
603 #####################################################################
604 # SelectFeaturesDlg
605 features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space,
606 title, "Tree", "Next", "Cancel")
607 features.title("Customize [ProductName]")
608 features.text("Description", 135, 35, 220, 15, 0x30003,
609 "Select the way you want features to be installed.")
610 features.text("Text", 135,45,220,30, 3,
611 "Click on the icons in the tree below to change the way features will be installed.")
612
613 c=features.back("< Back", "Next")
614 c.event("NewDialog", "SelectDirectoryDlg")
615
616 c=features.next("Next >", "Cancel")
617 c.mapping("SelectionNoItems", "Enabled")
618 c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1)
619 c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2)
620
621 c=features.cancel("Cancel", "Tree")
622 c.event("SpawnDialog", "CancelDlg")
623
Tim Peters66cb0182004-08-26 05:23:19 +0000624 # 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 +0000625 features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty",
626 "Tree of selections", "Back", None)
627
628 #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost")
629 #c.mapping("SelectionNoItems", "Enabled")
630 #c.event("Reset", "0")
Tim Peters66cb0182004-08-26 05:23:19 +0000631
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000632 features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None)
633
634 c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10)
635 c.mapping("SelectionNoItems","Enabled")
636 c.event("SpawnDialog", "DiskCostDlg")
637
638 c=features.xbutton("Advanced", "Advanced", None, 0.30)
639 c.event("SpawnDialog", "AdvancedDlg")
640
641 c=features.text("ItemDescription", 140, 180, 210, 30, 3,
642 "Multiline description of the currently selected item.")
643 c.mapping("SelectionDescription","Text")
Tim Peters66cb0182004-08-26 05:23:19 +0000644
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000645 c=features.text("ItemSize", 140, 210, 210, 45, 3,
646 "The size of the currently selected item.")
647 c.mapping("SelectionSize", "Text")
648
649 #####################################################################
650 # Disk cost
651 cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
652 "OK", "OK", "OK", bitmap=False)
653 cost.text("Title", 15, 6, 200, 15, 0x30003,
654 "{\DlgFontBold8}Disk Space Requirements")
655 cost.text("Description", 20, 20, 280, 20, 0x30003,
656 "The disk space required for the installation of the selected features.")
657 cost.text("Text", 20, 53, 330, 60, 3,
658 "The highlighted volumes (if any) do not have enough disk space "
659 "available for the currently selected features. You can either "
660 "remove some files from the highlighted volumes, or choose to "
661 "install less features onto local drive(s), or select different "
662 "destination drive(s).")
663 cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
664 None, "{120}{70}{70}{70}{70}", None, None)
665 cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
666
667 #####################################################################
668 # WhichUsers Dialog. Only available on NT, and for privileged users.
669 # This must be run before FindRelatedProducts, because that will
670 # take into account whether the previous installation was per-user
671 # or per-machine. We currently don't support going back to this
672 # dialog after "Next" was selected; to support this, we would need to
673 # find how to reset the ALLUSERS property, and how to re-run
674 # FindRelatedProducts.
675 # On Windows9x, the ALLUSERS property is ignored on the command line
676 # and in the Property table, but installer fails according to the documentation
677 # if a dialog attempts to set ALLUSERS.
678 whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
679 "AdminInstall", "Next", "Cancel")
680 whichusers.title("Select whether to install [ProductName] for all users of this computer.")
681 # A radio group with two options: allusers, justme
682 g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3,
683 "WhichUsers", "", "Next")
684 g.add("ALL", 0, 5, 150, 20, "Install for all users")
685 g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
686
Tim Peters66cb0182004-08-26 05:23:19 +0000687 whichusers.back("Back", None, active=0)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000688
689 c = whichusers.next("Next >", "Cancel")
690 c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
691 c.event("EndDialog", "Return", order = 2)
692
693 c = whichusers.cancel("Cancel", "AdminInstall")
694 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000695
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000696 #####################################################################
697 # Advanced Dialog.
698 advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
699 "CompilePyc", "Next", "Cancel")
700 advanced.title("Advanced Options for [ProductName]")
701 # A radio group with two options: allusers, justme
702 advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
703 "COMPILEALL", "Compile .py files to byte code after installation", "Next")
704
705 c = advanced.next("Finish", "Cancel")
706 c.event("EndDialog", "Return")
707
708 c = advanced.cancel("Cancel", "CompilePyc")
709 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000710
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000711 #####################################################################
Tim Peters66cb0182004-08-26 05:23:19 +0000712 # Existing Directory dialog
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000713 dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
714 "No", "No", "No")
715 dlg.text("Title", 10, 20, 180, 40, 3,
716 "[TARGETDIR] exists. Are you sure you want to overwrite existing files?")
717 c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No")
718 c.event("[TargetExists]", "0", order=1)
719 c.event("[TargetExistsOk]", "1", order=2)
720 c.event("EndDialog", "Return", order=3)
721 c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes")
722 c.event("EndDialog", "Return")
723
724 #####################################################################
725 # Installation Progress dialog (modeless)
726 progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
727 "Cancel", "Cancel", "Cancel", bitmap=False)
728 progress.text("Title", 20, 15, 200, 15, 0x30003,
729 "{\DlgFontBold8}[Progress1] [ProductName]")
730 progress.text("Text", 35, 65, 300, 30, 3,
731 "Please wait while the Installer [Progress2] [ProductName]. "
732 "This may take several minutes.")
733 progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
734
735 c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
736 c.mapping("ActionText", "Text")
737
738 #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
739 #c.mapping("ActionData", "Text")
740
741 c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
742 None, "Progress done", None, None)
743 c.mapping("SetProgress", "Progress")
744
745 progress.back("< Back", "Next", active=False)
746 progress.next("Next >", "Cancel", active=False)
747 progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
748
749 # Maintenance type: repair/uninstall
750 maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
751 "Next", "Next", "Cancel")
752 maint.title("Welcome to the [ProductName] Setup Wizard")
753 maint.text("BodyText", 135, 63, 230, 42, 3,
754 "Select whether you want to repair or remove [ProductName].")
755 g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3,
756 "MaintenanceForm_Action", "", "Next")
757 g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
758 g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
759 g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
Tim Peters66cb0182004-08-26 05:23:19 +0000760
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000761 maint.back("< Back", None, active=False)
762 c=maint.next("Finish", "Cancel")
763 # Change installation: Change progress dialog to "Change", then ask
764 # for feature selection
765 c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
766 c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
767
768 # Reinstall: Change progress dialog to "Repair", then invoke reinstall
769 # Also set list of reinstalled features to "ALL"
770 c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
771 c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
Raymond Hettinger72f08012004-11-07 07:08:25 +0000772 c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000773 c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
774
775 # Uninstall: Change progress to "Remove", then invoke uninstall
776 # Also set list of removed features to "ALL"
777 c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
778 c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
779 c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
780 c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
781
Tim Peters66cb0182004-08-26 05:23:19 +0000782 # Close dialog when maintenance action scheduled
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000783 c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
784 c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
Tim Peters66cb0182004-08-26 05:23:19 +0000785
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000786 maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000787
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000788
789# See "Feature Table". The feature level is 1 for all features,
790# and the feature attributes are 0 for the DefaultFeature, and
791# FollowParent for all other features. The numbers are the Display
792# column.
793def add_features(db):
794 # feature attributes:
795 # msidbFeatureAttributesFollowParent == 2
796 # msidbFeatureAttributesDisallowAdvertise == 8
797 # Features that need to be installed with together with the main feature
798 # (i.e. additional Python libraries) need to follow the parent feature.
799 # Features that have no advertisement trigger (e.g. the test suite)
800 # must not support advertisement
Martin v. Löwis21c80f22008-04-07 21:14:19 +0000801 global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature, private_crt
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000802 default_feature = Feature(db, "DefaultFeature", "Python",
803 "Python Interpreter and Libraries",
804 1, directory = "TARGETDIR")
Martin v. Löwis2a241ca2008-04-05 18:58:09 +0000805 shared_crt = Feature(db, "SharedCRT", "MSVCRT", "C Run-Time (system-wide)", 0,
806 level=0)
807 private_crt = Feature(db, "PrivateCRT", "MSVCRT", "C Run-Time (private)", 0,
808 level=0)
809 add_data(db, "Condition", [("SharedCRT", 1, sys32cond),
810 ("PrivateCRT", 1, "not "+sys32cond)])
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000811 # We don't support advertisement of extensions
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000812 ext_feature = Feature(db, "Extensions", "Register Extensions",
813 "Make this Python installation the default Python installation", 3,
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000814 parent = default_feature, attributes=2|8)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000815 if have_tcl:
816 tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000817 parent = default_feature, attributes=2)
818 htmlfiles = Feature(db, "Documentation", "Documentation",
819 "Python HTMLHelp File", 7, parent = default_feature)
820 tools = Feature(db, "Tools", "Utility Scripts",
Tim Peters66cb0182004-08-26 05:23:19 +0000821 "Python utility scripts (Tools/", 9,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000822 parent = default_feature, attributes=2)
823 testsuite = Feature(db, "Testsuite", "Test suite",
824 "Python test suite (Lib/test/)", 11,
825 parent = default_feature, attributes=2|8)
Tim Peters66cb0182004-08-26 05:23:19 +0000826
Christian Heimes81ca7c72007-11-18 18:18:41 +0000827def extract_msvcr90():
Martin v. Löwisee7498e2008-02-28 23:01:33 +0000828 # Find the redistributable files
829 dir = os.path.join(os.environ['VS90COMNTOOLS'], r"..\..\VC\redist\x86\Microsoft.VC90.CRT")
Christian Heimes81ca7c72007-11-18 18:18:41 +0000830
Christian Heimese1feb2e2008-02-28 20:52:40 +0000831 result = []
Christian Heimes81ca7c72007-11-18 18:18:41 +0000832 installer = msilib.MakeInstaller()
Christian Heimese1feb2e2008-02-28 20:52:40 +0000833 # omit msvcm90 and msvcp90, as they aren't really needed
834 files = ["Microsoft.VC90.CRT.manifest", "msvcr90.dll"]
835 for f in files:
836 path = os.path.join(dir, f)
837 kw = {'src':path}
838 if f.endswith('.dll'):
839 kw['version'] = installer.FileVersion(path, 0)
840 kw['language'] = installer.FileVersion(path, 1)
841 result.append((f, kw))
842 return result
Christian Heimes81ca7c72007-11-18 18:18:41 +0000843
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000844class PyDirectory(Directory):
845 """By default, all components in the Python installer
846 can run from source."""
847 def __init__(self, *args, **kw):
848 if not kw.has_key("componentflags"):
849 kw['componentflags'] = 2 #msidbComponentAttributesOptional
850 Directory.__init__(self, *args, **kw)
851
852# See "File Table", "Component Table", "Directory Table",
853# "FeatureComponents Table"
854def add_files(db):
855 cab = CAB("python")
856 tmpfiles = []
857 # Add all executables, icons, text files into the TARGETDIR component
858 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
859 default_feature.set_current()
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000860 if not msilib.Win64:
Christian Heimes81ca7c72007-11-18 18:18:41 +0000861 root.add_file("%s/w9xpopen.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000862 root.add_file("README.txt", src="README")
863 root.add_file("NEWS.txt", src="Misc/NEWS")
864 root.add_file("LICENSE.txt", src="LICENSE")
865 root.start_component("python.exe", keyfile="python.exe")
Christian Heimes81ca7c72007-11-18 18:18:41 +0000866 root.add_file("%s/python.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000867 root.start_component("pythonw.exe", keyfile="pythonw.exe")
Christian Heimes81ca7c72007-11-18 18:18:41 +0000868 root.add_file("%s/pythonw.exe" % PCBUILD)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000869
870 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
Christian Heimese1feb2e2008-02-28 20:52:40 +0000871 #dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
872 #install python30.dll into root dir for now
873 dlldir = root
874
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000875 pydll = "python%s%s.dll" % (major, minor)
Christian Heimes81ca7c72007-11-18 18:18:41 +0000876 pydllsrc = os.path.join(srcdir, PCBUILD, pydll)
Martin v. Löwis141f41a2005-03-15 00:39:40 +0000877 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000878 installer = msilib.MakeInstaller()
879 pyversion = installer.FileVersion(pydllsrc, 0)
880 if not snapshot:
881 # For releases, the Python DLL has the same version as the
882 # installer package.
883 assert pyversion.split(".")[:3] == current_version.split(".")
Christian Heimes81ca7c72007-11-18 18:18:41 +0000884 dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000885 version=pyversion,
886 language=installer.FileVersion(pydllsrc, 1))
Christian Heimese1feb2e2008-02-28 20:52:40 +0000887 DLLs = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
Christian Heimes81ca7c72007-11-18 18:18:41 +0000888
Martin v. Löwis21c80f22008-04-07 21:14:19 +0000889 # msvcr90.dll: Need to place the DLL and the manifest into the root directory,
890 # plus another copy of the manifest in the DLLs directory, with the manifest
891 # pointing to the root directory
892 root.start_component("msvcr90", feature=private_crt)
893 # Results are ID,keyword pairs
894 manifest, crtdll = extract_msvcr90()
895 root.add_file(manifest[0], **manifest[1])
896 root.add_file(crtdll[0], **crtdll[1])
897 # Copy the manifest
898 manifest_dlls = manifest[0]+".root"
899 open(manifest_dlls, "w").write(open(manifest[1]['src']).read().replace("msvcr","../msvcr"))
900 DLLs.start_component("msvcr90_dlls", feature=private_crt)
901 DLLs.add_file(manifest[0], src=os.path.abspath(manifest_dlls))
902
903 # Now start the main component for the DLLs directory;
904 # no regular files have been added to the directory yet.
905 DLLs.start_component()
Tim Peters66cb0182004-08-26 05:23:19 +0000906
Thomas Wouters89f507f2006-12-13 04:49:30 +0000907 # Check if _ctypes.pyd exists
Christian Heimes81ca7c72007-11-18 18:18:41 +0000908 have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
Thomas Wouters89f507f2006-12-13 04:49:30 +0000909 if not have_ctypes:
Collin Winter6afaeb72007-08-03 17:06:41 +0000910 print("WARNING: _ctypes.pyd not found, ctypes will not be included")
Thomas Wouters89f507f2006-12-13 04:49:30 +0000911 extensions.remove("_ctypes.pyd")
912
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000913 # Add all .py files in Lib, except lib-tk, test
914 dirs={}
915 pydirs = [(root,"Lib")]
916 while pydirs:
917 parent, dir = pydirs.pop()
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000918 if dir == ".svn" or dir.startswith("plat-"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000919 continue
920 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000921 if not have_tcl:
922 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000923 tcltk.set_current()
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000924 elif dir in ['test', 'tests', 'data', 'output']:
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000925 # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000926 # tests: Lib/distutils
927 # data: Lib/email/test
928 # output: Lib/test
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000929 testsuite.set_current()
Thomas Wouters89f507f2006-12-13 04:49:30 +0000930 elif not have_ctypes and dir == "ctypes":
931 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000932 else:
933 default_feature.set_current()
934 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
935 # Add additional files
936 dirs[dir]=lib
937 lib.glob("*.txt")
938 if dir=='site-packages':
Martin v. Löwis6d60c092004-11-21 10:16:26 +0000939 lib.add_file("README.txt", src="README")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000940 continue
941 files = lib.glob("*.py")
942 files += lib.glob("*.pyw")
943 if files:
944 # Add an entry to the RemoveFile table to remove bytecode files.
945 lib.remove_pyc()
Thomas Wouters3fc2ca32006-04-21 11:28:17 +0000946 if dir.endswith('.egg-info'):
947 lib.add_file('entry_points.txt')
948 lib.add_file('PKG-INFO')
949 lib.add_file('top_level.txt')
950 lib.add_file('zip-safe')
951 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000952 if dir=='test' and parent.physical=='Lib':
953 lib.add_file("185test.db")
954 lib.add_file("audiotest.au")
955 lib.add_file("cfgparser.1")
Thomas Wouters89f507f2006-12-13 04:49:30 +0000956 lib.add_file("sgml_input.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000957 lib.add_file("test.xml")
958 lib.add_file("test.xml.out")
959 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000960 lib.add_file("test_difflib_expect.html")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000961 lib.add_file("check_soundcard.vbs")
962 lib.add_file("empty.vbs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000963 lib.glob("*.uue")
Christian Heimes5d14c2b2007-11-20 23:38:09 +0000964 lib.glob("*.pem")
Christian Heimescbf3b5c2007-12-03 21:02:03 +0000965 lib.glob("*.pck")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000966 lib.add_file("readme.txt", src="README")
967 if dir=='decimaltestdata':
968 lib.glob("*.decTest")
969 if dir=='output':
970 lib.glob("test_*")
971 if dir=='idlelib':
972 lib.glob("*.def")
973 lib.add_file("idle.bat")
974 if dir=="Icons":
975 lib.glob("*.gif")
976 lib.add_file("idle.icns")
Thomas Wouters3fc2ca32006-04-21 11:28:17 +0000977 if dir=="command" and parent.physical=="distutils":
Martin v. Löwis5680d0c2008-04-10 03:06:53 +0000978 lib.glob("wininst*.exe")
Thomas Wouters3fc2ca32006-04-21 11:28:17 +0000979 if dir=="setuptools":
980 lib.add_file("cli.exe")
981 lib.add_file("gui.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000982 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000983 # This should contain all non-.svn files listed in subversion
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000984 for f in os.listdir(lib.absolute):
Martin v. Löwis9ca9f562006-01-03 06:29:53 +0000985 if f.endswith(".txt") or f==".svn":continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000986 if f.endswith(".au") or f.endswith(".gif"):
987 lib.add_file(f)
988 else:
Collin Winter6afaeb72007-08-03 17:06:41 +0000989 print("WARNING: New file %s in email/test/data" % f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000990 for f in os.listdir(lib.absolute):
991 if os.path.isdir(os.path.join(lib.absolute, f)):
992 pydirs.append((lib, f))
993 # Add DLLs
994 default_feature.set_current()
Christian Heimese1feb2e2008-02-28 20:52:40 +0000995 lib = DLLs
Christian Heimesd9a4d1d2008-01-01 14:42:15 +0000996 lib.add_file("py.ico", src=srcdir+"/PC/py.ico")
997 lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000998 dlls = []
999 tclfiles = []
1000 for f in extensions:
1001 if f=="_tkinter.pyd":
1002 continue
Christian Heimes81ca7c72007-11-18 18:18:41 +00001003 if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
Collin Winter6afaeb72007-08-03 17:06:41 +00001004 print("WARNING: Missing extension", f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001005 continue
1006 dlls.append(f)
1007 lib.add_file(f)
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001008 # Add sqlite
1009 if msilib.msi_type=="Intel64;1033":
1010 sqlite_arch = "/ia64"
1011 elif msilib.msi_type=="x64;1033":
1012 sqlite_arch = "/amd64"
Martin v. Löwis20c892d2008-02-29 21:03:38 +00001013 tclsuffix = "64"
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001014 else:
1015 sqlite_arch = ""
Martin v. Löwis20c892d2008-02-29 21:03:38 +00001016 tclsuffix = ""
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001017 lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001018 if have_tcl:
Christian Heimes81ca7c72007-11-18 18:18:41 +00001019 if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
Collin Winter6afaeb72007-08-03 17:06:41 +00001020 print("WARNING: Missing _tkinter.pyd")
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001021 else:
1022 lib.start_component("TkDLLs", tcltk)
1023 lib.add_file("_tkinter.pyd")
1024 dlls.append("_tkinter.pyd")
Martin v. Löwis20c892d2008-02-29 21:03:38 +00001025 tcldir = os.path.normpath(srcdir+("/../tcltk%s/bin" % tclsuffix))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001026 for f in glob.glob1(tcldir, "*.dll"):
1027 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001028 # check whether there are any unknown extensions
Christian Heimes81ca7c72007-11-18 18:18:41 +00001029 for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001030 if f.endswith("_d.pyd"): continue # debug version
1031 if f in dlls: continue
Collin Winter6afaeb72007-08-03 17:06:41 +00001032 print("WARNING: Unknown extension", f)
Tim Peters66cb0182004-08-26 05:23:19 +00001033
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001034 # Add headers
1035 default_feature.set_current()
1036 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
1037 lib.glob("*.h")
1038 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
1039 # Add import libraries
Christian Heimes81ca7c72007-11-18 18:18:41 +00001040 lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001041 for f in dlls:
1042 lib.add_file(f.replace('pyd','lib'))
1043 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +00001044 # Add the mingw-format library
1045 if have_mingw:
Tim Peters5a9fb3c2005-01-07 16:01:32 +00001046 lib.add_file('libpython%s%s.a' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001047 if have_tcl:
1048 # Add Tcl/Tk
Martin v. Löwis20c892d2008-02-29 21:03:38 +00001049 tcldirs = [(root, '../tcltk%s/lib' % tclsuffix, 'tcl')]
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001050 tcltk.set_current()
1051 while tcldirs:
1052 parent, phys, dir = tcldirs.pop()
1053 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
1054 if not os.path.exists(lib.absolute):
1055 continue
1056 for f in os.listdir(lib.absolute):
1057 if os.path.isdir(os.path.join(lib.absolute, f)):
1058 tcldirs.append((lib, f, f))
1059 else:
1060 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001061 # Add tools
1062 tools.set_current()
1063 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
Martin v. Löwisf8bba8e2008-03-24 00:52:58 +00001064 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001065 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1066 lib.glob("*.py")
1067 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1068 lib.remove_pyc()
1069 lib.glob("*.txt")
1070 if f == "pynche":
1071 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1072 x.glob("*.txt")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001073 if os.path.exists(os.path.join(lib.absolute, "README")):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001074 lib.add_file("README.txt", src="README")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001075 if f == 'Scripts':
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001076 if have_tcl:
1077 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1078 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001079 # Add documentation
1080 htmlfiles.set_current()
1081 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
Alexandre Vassalotti6461e102008-05-15 22:09:29 +00001082 lib.start_component("documentation", keyfile=docfile)
1083 lib.add_file(docfile, src="build/htmlhelp/"+docfile)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001084
1085 cab.commit(db)
1086
1087 for f in tmpfiles:
1088 os.unlink(f)
1089
1090# See "Registry Table", "Component Table"
1091def add_registry(db):
1092 # File extensions, associated with the REGISTRY.def component
1093 # IDLE verbs depend on the tcltk feature.
1094 # msidbComponentAttributesRegistryKeyPath = 4
1095 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001096 tcldata = []
1097 if have_tcl:
1098 tcldata = [
Martin v. Löwis283e35f2007-08-31 09:59:29 +00001099 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001100 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001101 add_data(db, "Component",
1102 # msidbComponentAttributesRegistryKeyPath = 4
Martin v. Löwis283e35f2007-08-31 09:59:29 +00001103 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001104 "InstallPath"),
Martin v. Löwis283e35f2007-08-31 09:59:29 +00001105 ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001106 "Documentation"),
Martin v. Löwis283e35f2007-08-31 09:59:29 +00001107 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001108 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001109 # See "FeatureComponents Table".
1110 # The association between TclTk and pythonw.exe is necessary to make ICE59
1111 # happy, because the installer otherwise believes that the IDLE and PyDoc
1112 # shortcuts might get installed without pythonw.exe being install. This
1113 # is not true, since installing TclTk will install the default feature, which
1114 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001115 # REGISTRY.tcl is not associated with any feature, as it will be requested
1116 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001117 tcldata = []
1118 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001119 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001120 add_data(db, "FeatureComponents",
1121 [(default_feature.id, "REGISTRY"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001122 (htmlfiles.id, "REGISTRY.doc"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001123 (ext_feature.id, "REGISTRY.def")] +
1124 tcldata
1125 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001126 # Extensions are not advertised. For advertised extensions,
1127 # we would need separate binaries that install along with the
1128 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001129 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1130 ewi = "Edit with IDLE"
1131 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1132 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001133 tcl_verbs = []
1134 if have_tcl:
1135 tcl_verbs=[
1136 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1137 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1138 "REGISTRY.tcl"),
1139 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1140 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1141 "REGISTRY.tcl"),
1142 ]
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001143 add_data(db, "Registry",
1144 [# Extensions
1145 ("py.ext", -1, r"Software\Classes\."+ext, "",
1146 "Python.File", "REGISTRY.def"),
1147 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1148 "Python.NoConFile", "REGISTRY.def"),
1149 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1150 "Python.CompiledFile", "REGISTRY.def"),
1151 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1152 "Python.CompiledFile", "REGISTRY.def"),
1153 # MIME types
1154 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1155 "text/plain", "REGISTRY.def"),
1156 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1157 "text/plain", "REGISTRY.def"),
1158 #Verbs
1159 ("py.open", -1, pat % (testprefix, "", "open"), "",
1160 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1161 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1162 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1163 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1164 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001165 ] + tcl_verbs + [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001166 #Icons
1167 ("py.icon", -1, pat2 % (testprefix, ""), "",
Thomas Wouters477c8d52006-05-27 19:21:47 +00001168 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001169 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
Thomas Wouters477c8d52006-05-27 19:21:47 +00001170 r'[DLLs]py.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001171 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
Thomas Wouters477c8d52006-05-27 19:21:47 +00001172 r'[DLLs]pyc.ico', "REGISTRY.def"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001173 # Descriptions
1174 ("py.txt", -1, pat3 % (testprefix, ""), "",
1175 "Python File", "REGISTRY.def"),
1176 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1177 "Python File (no console)", "REGISTRY.def"),
1178 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1179 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001180 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001181
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001182 # Registry keys
1183 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1184 add_data(db, "Registry",
1185 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1186 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1187 "Python %s" % short_version, "REGISTRY"),
1188 ("PythonPath", -1, prefix+r"\PythonPath", "",
Martin v. Löwisf13337d2004-09-19 18:36:45 +00001189 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001190 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
Alexandre Vassalotti6461e102008-05-15 22:09:29 +00001191 "[TARGETDIR]Doc\\"+docfile , "REGISTRY.doc"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001192 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1193 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1194 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1195 ])
1196 # Shortcuts, see "Shortcut Table"
1197 add_data(db, "Directory",
1198 [("ProgramMenuFolder", "TARGETDIR", "."),
1199 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1200 add_data(db, "RemoveFile",
1201 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001202 tcltkshortcuts = []
1203 if have_tcl:
1204 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001205 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001206 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 +00001207 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001208 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 +00001209 ]
1210 add_data(db, "Shortcut",
1211 tcltkshortcuts +
1212 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001213 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1214 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001215 # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an
1216 # icon first.
1217 #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1218 # htmlfiles.id, None, None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001219 ## Non-advertised shortcuts: must be associated with a registry component
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001220 ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
Alexandre Vassalotti6461e102008-05-15 22:09:29 +00001221 "[#%s]" % docfile, None,
Martin v. Löwis141f41a2005-03-15 00:39:40 +00001222 None, None, None, None, None, None),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001223 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1224 SystemFolderName+"msiexec", "/x%s" % product_code,
1225 None, None, None, None, None, None),
1226 ])
1227 db.Commit()
1228
1229db = build_database()
1230try:
1231 add_features(db)
1232 add_ui(db)
1233 add_files(db)
1234 add_registry(db)
1235 remove_old_versions(db)
1236 db.Commit()
1237finally:
1238 del db