blob: dbb7ecba04fe17857fa1271943bca153cb1b0f96 [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.
Martin v. Löwis9fda9312004-12-22 13:41:49 +00004import msilib, schema, sequence, os, glob, time, re
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öwis8ffe9ab2004-08-22 13:34:34 +00009
10# Settings can be overridden in config.py below
11# 1 for Itanium build
12msilib.Win64 = 0
13# 0 for official python.org releases
14# 1 for intermediate releases by anybody, with
15# a new product code for every package.
16snapshot = 1
17# 1 means that file extension is px, not py,
18# and binaries start with x
19testpackage = 0
20# Location of build tree
21srcdir = os.path.abspath("../..")
22# Text to be displayed as the version in dialogs etc.
23# goes into file name and ProductCode. Defaults to
24# current_version.day for Snapshot, current_version otherwise
25full_current_version = None
Martin v. Löwise0f780d2004-09-01 14:51:06 +000026# Is Tcl available at all?
27have_tcl = True
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000028
29try:
30 from config import *
31except ImportError:
32 pass
33
34# Extract current version from Include/patchlevel.h
35lines = open(srcdir + "/Include/patchlevel.h").readlines()
36major = minor = micro = level = serial = None
37levels = {
38 'PY_RELEASE_LEVEL_ALPHA':0xA,
39 'PY_RELEASE_LEVEL_BETA': 0xB,
40 'PY_RELEASE_LEVEL_GAMMA':0xC,
41 'PY_RELEASE_LEVEL_FINAL':0xF
42 }
43for l in lines:
44 if not l.startswith("#define"):
45 continue
46 l = l.split()
47 if len(l) != 3:
48 continue
49 _, name, value = l
50 if name == 'PY_MAJOR_VERSION': major = value
51 if name == 'PY_MINOR_VERSION': minor = value
52 if name == 'PY_MICRO_VERSION': micro = value
53 if name == 'PY_RELEASE_LEVEL': level = levels[value]
54 if name == 'PY_RELEASE_SERIAL': serial = value
55
56short_version = major+"."+minor
57# See PC/make_versioninfo.c
58FIELD3 = 1000*int(micro) + 10*level + int(serial)
59current_version = "%s.%d" % (short_version, FIELD3)
60
61# This should never change. The UpgradeCode of this package can be
62# used in the Upgrade table of future packages to make the future
63# package replace this one. See "UpgradeCode Property".
64upgrade_code_snapshot='{92A24481-3ECB-40FC-8836-04B7966EC0D5}'
65upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}'
66
67# This should be extended for each Python release.
68# The product code must change whenever the name of the MSI file
69# changes, and when new component codes are issued for existing
70# components. See "Changing the Product Code". As we change the
71# component codes with every build, we need a new product code
72# each time. For intermediate (snapshot) releases, they are automatically
73# generated. For official releases, we record the product codes,
74# so people can refer to them.
75product_codes = {
76 '2.4.101': '{0e9b4d8e-6cda-446e-a208-7b92f3ddffa0}', # 2.4a1, released as a snapshot
77 '2.4.102': '{1b998745-4901-4edb-bc52-213689e1b922}', # 2.4a2
78 '2.4.103': '{33fc8bd2-1e8f-4add-a40a-ade2728d5942}', # 2.4a3
79 '2.4.111': '{51a7e2a8-2025-4ef0-86ff-e6aab742d1fa}', # 2.4b1
80 '2.4.112': '{4a5e7c1d-c659-4fe3-b8c9-7c65bd9c95a5}', # 2.4b2
81 '2.4.121': '{75508821-a8e9-40a8-95bd-dbe6033ddbea}', # 2.4c1
82 '2.4.122': '{83a9118b-4bdd-473b-afc3-bcb142feca9e}', # 2.4c2
83 '2.4.150': '{82d9302e-f209-4805-b548-52087047483a}', # 2.4.0
84}
85
86if snapshot:
87 current_version = "%s.%s.%s" % (major, minor, int(time.time()/3600/24))
88 product_code = msilib.gen_uuid()
89else:
90 product_code = product_codes[current_version]
91
92if full_current_version is None:
93 full_current_version = current_version
94
95extensions = [
96 'bz2.pyd',
97 'pyexpat.pyd',
98 'select.pyd',
99 'unicodedata.pyd',
100 'winsound.pyd',
101 'zlib.pyd',
102 '_bsddb.pyd',
103 '_socket.pyd',
104 '_ssl.pyd',
105 '_testcapi.pyd',
106 '_tkinter.pyd',
107]
108
109if major+minor <= "23":
110 extensions.extend([
111 '_csv.pyd',
112 '_sre.pyd',
113 '_symtable.pyd',
114 '_winreg.pyd',
115 'datetime.pyd'
116 'mmap.pyd',
Tim Peters66cb0182004-08-26 05:23:19 +0000117 'parser.pyd',
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000118 ])
119
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000120# Build the mingw import library, libpythonXY.a
121# This requires 'nm' and 'dlltool' executables on your PATH
122def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
123 warning = "WARNING: %s - libpythonXX.a not built"
124 nm = find_executable('nm')
125 dlltool = find_executable('dlltool')
126
127 if not nm or not dlltool:
128 print warning % "nm and/or dlltool were not found"
129 return False
130
131 nm_command = '%s -Cs %s' % (nm, lib_file)
132 dlltool_command = "%s --dllname %s --def %s --output-lib %s" % \
133 (dlltool, dll_file, def_file, mingw_lib)
134 export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match
135
136 f = open(def_file,'w')
137 print >>f, "LIBRARY %s" % dll_file
138 print >>f, "EXPORTS"
139
140 nm_pipe = os.popen(nm_command)
141 for line in nm_pipe.readlines():
142 m = export_match(line)
143 if m:
144 print >>f, m.group(1)
145 f.close()
146 exit = nm_pipe.close()
147
148 if exit:
149 print warning % "nm did not run successfully"
150 return False
151
152 if os.system(dlltool_command) != 0:
153 print warning % "dlltool did not run successfully"
154 return False
155
156 return True
157
158# Target files (.def and .a) go in PCBuild directory
159lib_file = os.path.join(srcdir, "PCBuild", "python%s%s.lib" % (major, minor))
160def_file = os.path.join(srcdir, "PCBuild", "python%s%s.def" % (major, minor))
161dll_file = "python%s%s.dll" % (major, minor)
162mingw_lib = os.path.join(srcdir, "PCBuild", "libpython%s%s.a" % (major, minor))
163
164have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
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:
174 SystemFolderName = "[SystemFolder64]"
175else:
176 SystemFolderName = "[SystemFolder]"
177
178msilib.reset()
179
180# condition in which to install pythonxy.dll in system32:
181# a) it is Windows 9x or
182# b) it is NT, the user is privileged, and has chosen per-machine installation
183sys32cond = "(Windows9x or (Privileged and ALLUSERS))"
184
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000185def build_database():
186 """Generate an empty database, with just the schema and the
187 Summary information stream."""
188 if snapshot:
189 uc = upgrade_code_snapshot
190 else:
191 uc = upgrade_code
192 # schema represents the installer 2.0 database schema.
193 # sequence is the set of standard sequences
194 # (ui/execute, admin/advt/install)
195 if msilib.Win64:
196 w64 = ".ia64"
197 else:
198 w64 = ""
Tim Peters66cb0182004-08-26 05:23:19 +0000199 db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000200 schema, ProductName="Python "+full_current_version,
201 ProductCode=product_code,
202 ProductVersion=current_version,
203 Manufacturer=u"Martin v. L\xf6wis")
204 # The default sequencing of the RemoveExistingProducts action causes
205 # removal of files that got just installed. Place it after
206 # InstallInitialize, so we first uninstall everything, but still roll
207 # back in case the installation is interrupted
208 msilib.change_sequence(sequence.InstallExecuteSequence,
209 "RemoveExistingProducts", 1510)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000210 msilib.add_tables(db, sequence)
211 # We cannot set ALLUSERS in the property table, as this cannot be
212 # reset if the user choses a per-user installation. Instead, we
213 # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages
214 # this property, and when the execution starts, ALLUSERS is set
215 # accordingly.
216 add_data(db, "Property", [("UpgradeCode", uc),
217 ("WhichUsers", "ALL"),
218 ])
219 db.Commit()
220 return db
221
222def remove_old_versions(db):
223 "Fill the upgrade table."
224 start = "%s.%s.0" % (major, minor)
225 # This requests that feature selection states of an older
226 # installation should be forwarded into this one. Upgrading
227 # requires that both the old and the new installation are
228 # either both per-machine or per-user.
229 migrate_features = 1
230 # See "Upgrade Table". We remove releases with the same major and
231 # minor version. For an snapshot, we remove all earlier snapshots. For
232 # a release, we remove all snapshots, and all earlier releases.
233 if snapshot:
234 add_data(db, "Upgrade",
Tim Peters66cb0182004-08-26 05:23:19 +0000235 [(upgrade_code_snapshot, start,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000236 current_version,
237 None, # Ignore language
Tim Peters66cb0182004-08-26 05:23:19 +0000238 migrate_features,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000239 None, # Migrate ALL features
240 "REMOVEOLDSNAPSHOT")])
241 props = "REMOVEOLDSNAPSHOT"
242 else:
243 add_data(db, "Upgrade",
244 [(upgrade_code, start, current_version,
245 None, migrate_features, None, "REMOVEOLDVERSION"),
246 (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1),
247 None, migrate_features, None, "REMOVEOLDSNAPSHOT")])
248 props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION"
249 # Installer collects the product codes of the earlier releases in
250 # these properties. In order to allow modification of the properties,
251 # they must be declared as secure. See "SecureCustomProperties Property"
252 add_data(db, "Property", [("SecureCustomProperties", props)])
253
254class PyDialog(Dialog):
255 """Dialog class with a fixed layout: controls at the top, then a ruler,
256 then a list of buttons: back, next, cancel. Optionally a bitmap at the
257 left."""
258 def __init__(self, *args, **kw):
259 """Dialog(database, name, x, y, w, h, attributes, title, first,
260 default, cancel, bitmap=true)"""
261 Dialog.__init__(self, *args)
262 ruler = self.h - 36
263 bmwidth = 152*ruler/328
264 if kw.get("bitmap", True):
265 self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
266 self.line("BottomLine", 0, ruler, self.w, 0)
267
268 def title(self, title):
269 "Set the title text of the dialog at the top."
270 # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
271 # text, in VerdanaBold10
272 self.text("Title", 135, 10, 220, 60, 0x30003,
273 r"{\VerdanaBold10}%s" % title)
274
275 def back(self, title, next, name = "Back", active = 1):
276 """Add a back button with a given title, the tab-next button,
277 its name in the Control table, possibly initially disabled.
278
279 Return the button, so that events can be associated"""
280 if active:
281 flags = 3 # Visible|Enabled
282 else:
283 flags = 1 # Visible
284 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
285
286 def cancel(self, title, next, name = "Cancel", active = 1):
287 """Add a cancel button with a given title, the tab-next button,
288 its name in the Control table, possibly initially disabled.
289
290 Return the button, so that events can be associated"""
291 if active:
292 flags = 3 # Visible|Enabled
293 else:
294 flags = 1 # Visible
295 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
296
297 def next(self, title, next, name = "Next", active = 1):
298 """Add a Next button with a given title, the tab-next button,
299 its name in the Control table, possibly initially disabled.
300
301 Return the button, so that events can be associated"""
302 if active:
303 flags = 3 # Visible|Enabled
304 else:
305 flags = 1 # Visible
306 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
307
308 def xbutton(self, name, title, next, xpos):
309 """Add a button with a given title, the tab-next button,
310 its name in the Control table, giving its x position; the
311 y-position is aligned with the other buttons.
312
313 Return the button, so that events can be associated"""
314 return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
315
316def add_ui(db):
317 x = y = 50
318 w = 370
319 h = 300
320 title = "[ProductName] Setup"
321
322 # see "Dialog Style Bits"
323 modal = 3 # visible | modal
324 modeless = 1 # visible
325 track_disk_space = 32
326
327 add_data(db, 'ActionText', uisample.ActionText)
328 add_data(db, 'UIText', uisample.UIText)
329
330 # Bitmaps
331 if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
332 raise "Run icons.mak in PC directory"
333 add_data(db, "Binary",
334 [("PythonWin", msilib.Binary(srcdir+r"\PCbuild\installer.bmp")), # 152x328 pixels
335 ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
336 ])
337 add_data(db, "Icon",
338 [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))])
339
340 # Scripts
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000341 # CheckDir sets TargetExists if TARGETDIR exists.
342 # UpdateEditIDLE sets the REGISTRY.tcl component into
343 # the installed/uninstalled state according to both the
344 # Extensions and TclTk features.
Martin v. Löwiseb68be42004-12-12 15:29:21 +0000345 if os.system("nmake /nologo /c /f msisupport.mak") != 0:
346 raise "'nmake /f msisupport.mak' failed"
347 add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
348 # See "Custom Action Type 1"
Tim Peters0e9980f2004-09-12 03:49:31 +0000349 add_data(db, "CustomAction",
Martin v. Löwiseb68be42004-12-12 15:29:21 +0000350 [("CheckDir", 1, "Script", "_CheckDir@4")])
Martin v. Löwiseac02e62004-11-18 08:00:33 +0000351 if have_tcl:
352 add_data(db, "CustomAction",
Martin v. Löwiseb68be42004-12-12 15:29:21 +0000353 [("UpdateEditIDLE", 1, "Script", "_UpdateEditIDLE@4")])
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000354
355 # UI customization properties
356 add_data(db, "Property",
357 # See "DefaultUIFont Property"
358 [("DefaultUIFont", "DlgFont8"),
359 # See "ErrorDialog Style Bit"
360 ("ErrorDialog", "ErrorDlg"),
361 ("Progress1", "Install"), # modified in maintenance type dlg
362 ("Progress2", "installs"),
363 ("MaintenanceForm_Action", "Repair")])
364
365 # Fonts, see "TextStyle Table"
366 add_data(db, "TextStyle",
367 [("DlgFont8", "Tahoma", 9, None, 0),
368 ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
369 ("VerdanaBold10", "Verdana", 10, None, 1),
370 ])
371
Martin v. Löwis7b2563b2004-11-02 22:59:56 +0000372 compileargs = r"-Wi [TARGETDIR]Lib\compileall.py -f -x badsyntax [TARGETDIR]Lib"
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000373 # See "CustomAction Table"
374 add_data(db, "CustomAction", [
375 # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
376 # See "Custom Action Type 51",
377 # "Custom Action Execution Scheduling Options"
378 ("InitialTargetDir", 307, "TARGETDIR",
379 "[WindowsVolume]Python%s%s" % (major, minor)),
380 ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"),
381 ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName),
382 # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile
383 # See "Custom Action Type 18"
Martin v. Löwis7b2563b2004-11-02 22:59:56 +0000384 ("CompilePyc", 18, "python.exe", compileargs),
385 ("CompilePyo", 18, "python.exe", "-O "+compileargs),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000386 ])
387
388 # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
389 # Numbers indicate sequence; see sequence.py for how these action integrate
390 add_data(db, "InstallUISequence",
391 [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
392 ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
393 ("InitialTargetDir", 'TARGETDIR=""', 750),
394 # In the user interface, assume all-users installation if privileged.
395 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
396 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
397 ("SelectDirectoryDlg", "Not Installed", 1230),
398 # XXX no support for resume installations yet
399 #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
400 ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
401 ("ProgressDlg", None, 1280)])
402 add_data(db, "AdminUISequence",
403 [("InitialTargetDir", 'TARGETDIR=""', 750),
404 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
405 ])
406
407 # Execute Sequences
408 add_data(db, "InstallExecuteSequence",
409 [("InitialTargetDir", 'TARGETDIR=""', 750),
410 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
411 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000412 ("UpdateEditIDLE", None, 1050),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000413 ("CompilePyc", "COMPILEALL", 6800),
414 ("CompilePyo", "COMPILEALL", 6801),
415 ])
416 add_data(db, "AdminExecuteSequence",
417 [("InitialTargetDir", 'TARGETDIR=""', 750),
418 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
419 ("CompilePyc", "COMPILEALL", 6800),
420 ("CompilePyo", "COMPILEALL", 6801),
421 ])
422
423 #####################################################################
424 # Standard dialogs: FatalError, UserExit, ExitDialog
425 fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
426 "Finish", "Finish", "Finish")
427 fatal.title("[ProductName] Installer ended prematurely")
428 fatal.back("< Back", "Finish", active = 0)
429 fatal.cancel("Cancel", "Back", active = 0)
430 fatal.text("Description1", 135, 70, 220, 80, 0x30003,
431 "[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.")
432 fatal.text("Description2", 135, 155, 220, 20, 0x30003,
433 "Click the Finish button to exit the Installer.")
434 c=fatal.next("Finish", "Cancel", name="Finish")
435 # See "ControlEvent Table". Parameters are the event, the parameter
436 # to the action, and optionally the condition for the event, and the order
437 # of events.
438 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000439
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000440 user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
441 "Finish", "Finish", "Finish")
442 user_exit.title("[ProductName] Installer was interrupted")
443 user_exit.back("< Back", "Finish", active = 0)
444 user_exit.cancel("Cancel", "Back", active = 0)
445 user_exit.text("Description1", 135, 70, 220, 80, 0x30003,
446 "[ProductName] setup was interrupted. Your system has not been modified. "
447 "To install this program at a later time, please run the installation again.")
448 user_exit.text("Description2", 135, 155, 220, 20, 0x30003,
449 "Click the Finish button to exit the Installer.")
450 c = user_exit.next("Finish", "Cancel", name="Finish")
451 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000452
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000453 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
454 "Finish", "Finish", "Finish")
455 exit_dialog.title("Completing the [ProductName] Installer")
456 exit_dialog.back("< Back", "Finish", active = 0)
457 exit_dialog.cancel("Cancel", "Back", active = 0)
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000458 exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003,
459 "Special Windows thanks to:\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000460 " LettError, Erik van Blokland, for the \n"
461 " Python for Windows graphic.\n"
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000462 " http://www.letterror.com/\n"
463 "\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000464 " Mark Hammond, without whose years of freely \n"
465 " shared Windows expertise, Python for Windows \n"
466 " would still be Python for DOS.")
Tim Peters66cb0182004-08-26 05:23:19 +0000467
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000468 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000469 "Click the Finish button to exit the Installer.")
470 c = exit_dialog.next("Finish", "Cancel", name="Finish")
471 c.event("EndDialog", "Return")
472
473 #####################################################################
474 # Required dialog: FilesInUse, ErrorDlg
475 inuse = PyDialog(db, "FilesInUse",
476 x, y, w, h,
477 19, # KeepModeless|Modal|Visible
478 title,
479 "Retry", "Retry", "Retry", bitmap=False)
480 inuse.text("Title", 15, 6, 200, 15, 0x30003,
481 r"{\DlgFontBold8}Files in Use")
482 inuse.text("Description", 20, 23, 280, 20, 0x30003,
483 "Some files that need to be updated are currently in use.")
484 inuse.text("Text", 20, 55, 330, 50, 3,
485 "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.")
486 inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
487 None, None, None)
488 c=inuse.back("Exit", "Ignore", name="Exit")
489 c.event("EndDialog", "Exit")
490 c=inuse.next("Ignore", "Retry", name="Ignore")
491 c.event("EndDialog", "Ignore")
492 c=inuse.cancel("Retry", "Exit", name="Retry")
493 c.event("EndDialog","Retry")
494
495
496 # See "Error Dialog". See "ICE20" for the required names of the controls.
497 error = Dialog(db, "ErrorDlg",
498 50, 10, 330, 101,
499 65543, # Error|Minimize|Modal|Visible
500 title,
501 "ErrorText", None, None)
502 error.text("ErrorText", 50,9,280,48,3, "")
503 error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
504 error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
505 error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
506 error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
507 error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
508 error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
509 error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
510 error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
511
512 #####################################################################
513 # Global "Query Cancel" dialog
514 cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
515 "No", "No", "No")
Tim Peters66cb0182004-08-26 05:23:19 +0000516 cancel.text("Text", 48, 15, 194, 30, 3,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000517 "Are you sure you want to cancel [ProductName] installation?")
518 cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
519 "py.ico", None, None)
520 c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
521 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000522
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000523 c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
524 c.event("EndDialog", "Return")
525
526 #####################################################################
527 # Global "Wait for costing" dialog
528 costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
529 "Return", "Return", "Return")
530 costing.text("Text", 48, 15, 194, 30, 3,
531 "Please wait while the installer finishes determining your disk space requirements.")
532 costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
533 "py.ico", None, None)
534 c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
535 c.event("EndDialog", "Exit")
536
537 #####################################################################
538 # Preparation dialog: no user input except cancellation
539 prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
540 "Cancel", "Cancel", "Cancel")
541 prep.text("Description", 135, 70, 220, 40, 0x30003,
542 "Please wait while the Installer prepares to guide you through the installation.")
543 prep.title("Welcome to the [ProductName] Installer")
544 c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...")
545 c.mapping("ActionText", "Text")
546 c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None)
547 c.mapping("ActionData", "Text")
548 prep.back("Back", None, active=0)
549 prep.next("Next", None, active=0)
550 c=prep.cancel("Cancel", None)
551 c.event("SpawnDialog", "CancelDlg")
552
553 #####################################################################
554 # Target directory selection
555 seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
556 "Next", "Next", "Cancel")
557 seldlg.title("Select Destination Directory")
558 seldlg.text("Description", 135, 50, 220, 40, 0x30003,
559 "Please select a directory for the [ProductName] files.")
560
561 seldlg.back("< Back", None, active=0)
562 c = seldlg.next("Next >", "Cancel")
563 c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1)
564 # If the target exists, but we found that we are going to remove old versions, don't bother
565 # confirming that the target directory exists. Strictly speaking, we should determine that
566 # the target directory is indeed the target of the product that we are going to remove, but
567 # I don't know how to do that.
568 c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2)
569 c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3)
570 c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4)
571 c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5)
572
573 c = seldlg.cancel("Cancel", "DirectoryCombo")
574 c.event("SpawnDialog", "CancelDlg")
575
576 seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219,
577 "TARGETDIR", None, "DirectoryList", None)
578 seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR",
579 None, "PathEdit", None)
580 seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None)
581 c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
582 c.event("DirectoryListUp", "0")
583 c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
584 c.event("DirectoryListNew", "0")
585
586 #####################################################################
587 # SelectFeaturesDlg
588 features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space,
589 title, "Tree", "Next", "Cancel")
590 features.title("Customize [ProductName]")
591 features.text("Description", 135, 35, 220, 15, 0x30003,
592 "Select the way you want features to be installed.")
593 features.text("Text", 135,45,220,30, 3,
594 "Click on the icons in the tree below to change the way features will be installed.")
595
596 c=features.back("< Back", "Next")
597 c.event("NewDialog", "SelectDirectoryDlg")
598
599 c=features.next("Next >", "Cancel")
600 c.mapping("SelectionNoItems", "Enabled")
601 c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1)
602 c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2)
603
604 c=features.cancel("Cancel", "Tree")
605 c.event("SpawnDialog", "CancelDlg")
606
Tim Peters66cb0182004-08-26 05:23:19 +0000607 # 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 +0000608 features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty",
609 "Tree of selections", "Back", None)
610
611 #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost")
612 #c.mapping("SelectionNoItems", "Enabled")
613 #c.event("Reset", "0")
Tim Peters66cb0182004-08-26 05:23:19 +0000614
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000615 features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None)
616
617 c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10)
618 c.mapping("SelectionNoItems","Enabled")
619 c.event("SpawnDialog", "DiskCostDlg")
620
621 c=features.xbutton("Advanced", "Advanced", None, 0.30)
622 c.event("SpawnDialog", "AdvancedDlg")
623
624 c=features.text("ItemDescription", 140, 180, 210, 30, 3,
625 "Multiline description of the currently selected item.")
626 c.mapping("SelectionDescription","Text")
Tim Peters66cb0182004-08-26 05:23:19 +0000627
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000628 c=features.text("ItemSize", 140, 210, 210, 45, 3,
629 "The size of the currently selected item.")
630 c.mapping("SelectionSize", "Text")
631
632 #####################################################################
633 # Disk cost
634 cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
635 "OK", "OK", "OK", bitmap=False)
636 cost.text("Title", 15, 6, 200, 15, 0x30003,
637 "{\DlgFontBold8}Disk Space Requirements")
638 cost.text("Description", 20, 20, 280, 20, 0x30003,
639 "The disk space required for the installation of the selected features.")
640 cost.text("Text", 20, 53, 330, 60, 3,
641 "The highlighted volumes (if any) do not have enough disk space "
642 "available for the currently selected features. You can either "
643 "remove some files from the highlighted volumes, or choose to "
644 "install less features onto local drive(s), or select different "
645 "destination drive(s).")
646 cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
647 None, "{120}{70}{70}{70}{70}", None, None)
648 cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
649
650 #####################################################################
651 # WhichUsers Dialog. Only available on NT, and for privileged users.
652 # This must be run before FindRelatedProducts, because that will
653 # take into account whether the previous installation was per-user
654 # or per-machine. We currently don't support going back to this
655 # dialog after "Next" was selected; to support this, we would need to
656 # find how to reset the ALLUSERS property, and how to re-run
657 # FindRelatedProducts.
658 # On Windows9x, the ALLUSERS property is ignored on the command line
659 # and in the Property table, but installer fails according to the documentation
660 # if a dialog attempts to set ALLUSERS.
661 whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
662 "AdminInstall", "Next", "Cancel")
663 whichusers.title("Select whether to install [ProductName] for all users of this computer.")
664 # A radio group with two options: allusers, justme
665 g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3,
666 "WhichUsers", "", "Next")
667 g.add("ALL", 0, 5, 150, 20, "Install for all users")
668 g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
669
Tim Peters66cb0182004-08-26 05:23:19 +0000670 whichusers.back("Back", None, active=0)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000671
672 c = whichusers.next("Next >", "Cancel")
673 c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
674 c.event("EndDialog", "Return", order = 2)
675
676 c = whichusers.cancel("Cancel", "AdminInstall")
677 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000678
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000679 #####################################################################
680 # Advanced Dialog.
681 advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
682 "CompilePyc", "Next", "Cancel")
683 advanced.title("Advanced Options for [ProductName]")
684 # A radio group with two options: allusers, justme
685 advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
686 "COMPILEALL", "Compile .py files to byte code after installation", "Next")
687
688 c = advanced.next("Finish", "Cancel")
689 c.event("EndDialog", "Return")
690
691 c = advanced.cancel("Cancel", "CompilePyc")
692 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000693
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000694 #####################################################################
Tim Peters66cb0182004-08-26 05:23:19 +0000695 # Existing Directory dialog
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000696 dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
697 "No", "No", "No")
698 dlg.text("Title", 10, 20, 180, 40, 3,
699 "[TARGETDIR] exists. Are you sure you want to overwrite existing files?")
700 c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No")
701 c.event("[TargetExists]", "0", order=1)
702 c.event("[TargetExistsOk]", "1", order=2)
703 c.event("EndDialog", "Return", order=3)
704 c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes")
705 c.event("EndDialog", "Return")
706
707 #####################################################################
708 # Installation Progress dialog (modeless)
709 progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
710 "Cancel", "Cancel", "Cancel", bitmap=False)
711 progress.text("Title", 20, 15, 200, 15, 0x30003,
712 "{\DlgFontBold8}[Progress1] [ProductName]")
713 progress.text("Text", 35, 65, 300, 30, 3,
714 "Please wait while the Installer [Progress2] [ProductName]. "
715 "This may take several minutes.")
716 progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
717
718 c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
719 c.mapping("ActionText", "Text")
720
721 #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
722 #c.mapping("ActionData", "Text")
723
724 c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
725 None, "Progress done", None, None)
726 c.mapping("SetProgress", "Progress")
727
728 progress.back("< Back", "Next", active=False)
729 progress.next("Next >", "Cancel", active=False)
730 progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
731
732 # Maintenance type: repair/uninstall
733 maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
734 "Next", "Next", "Cancel")
735 maint.title("Welcome to the [ProductName] Setup Wizard")
736 maint.text("BodyText", 135, 63, 230, 42, 3,
737 "Select whether you want to repair or remove [ProductName].")
738 g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3,
739 "MaintenanceForm_Action", "", "Next")
740 g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
741 g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
742 g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
Tim Peters66cb0182004-08-26 05:23:19 +0000743
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000744 maint.back("< Back", None, active=False)
745 c=maint.next("Finish", "Cancel")
746 # Change installation: Change progress dialog to "Change", then ask
747 # for feature selection
748 c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
749 c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
750
751 # Reinstall: Change progress dialog to "Repair", then invoke reinstall
752 # Also set list of reinstalled features to "ALL"
753 c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
754 c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
Raymond Hettinger72f08012004-11-07 07:08:25 +0000755 c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000756 c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
757
758 # Uninstall: Change progress to "Remove", then invoke uninstall
759 # Also set list of removed features to "ALL"
760 c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
761 c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
762 c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
763 c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
764
Tim Peters66cb0182004-08-26 05:23:19 +0000765 # Close dialog when maintenance action scheduled
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000766 c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
767 c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
Tim Peters66cb0182004-08-26 05:23:19 +0000768
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000769 maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000770
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000771
772# See "Feature Table". The feature level is 1 for all features,
773# and the feature attributes are 0 for the DefaultFeature, and
774# FollowParent for all other features. The numbers are the Display
775# column.
776def add_features(db):
777 # feature attributes:
778 # msidbFeatureAttributesFollowParent == 2
779 # msidbFeatureAttributesDisallowAdvertise == 8
780 # Features that need to be installed with together with the main feature
781 # (i.e. additional Python libraries) need to follow the parent feature.
782 # Features that have no advertisement trigger (e.g. the test suite)
783 # must not support advertisement
784 global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature
785 default_feature = Feature(db, "DefaultFeature", "Python",
786 "Python Interpreter and Libraries",
787 1, directory = "TARGETDIR")
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000788 # We don't support advertisement of extensions
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000789 ext_feature = Feature(db, "Extensions", "Register Extensions",
790 "Make this Python installation the default Python installation", 3,
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000791 parent = default_feature, attributes=2|8)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000792 if have_tcl:
793 tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000794 parent = default_feature, attributes=2)
795 htmlfiles = Feature(db, "Documentation", "Documentation",
796 "Python HTMLHelp File", 7, parent = default_feature)
797 tools = Feature(db, "Tools", "Utility Scripts",
Tim Peters66cb0182004-08-26 05:23:19 +0000798 "Python utility scripts (Tools/", 9,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000799 parent = default_feature, attributes=2)
800 testsuite = Feature(db, "Testsuite", "Test suite",
801 "Python test suite (Lib/test/)", 11,
802 parent = default_feature, attributes=2|8)
Tim Peters66cb0182004-08-26 05:23:19 +0000803
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000804def extract_msvcr71():
805 import _winreg
806 # Find the location of the merge modules
807 k = _winreg.OpenKey(
808 _winreg.HKEY_LOCAL_MACHINE,
809 r"Software\Microsoft\VisualStudio\7.1\Setup\VS")
810 dir = _winreg.QueryValueEx(k, "MSMDir")[0]
811 _winreg.CloseKey(k)
812 files = glob.glob1(dir, "*CRT71*")
813 assert len(files) == 1
814 file = os.path.join(dir, files[0])
815 # Extract msvcr71.dll
816 m = msilib.MakeMerge2()
817 m.OpenModule(file, 0)
818 m.ExtractFiles(".")
819 m.CloseModule()
820 # Find the version/language of msvcr71.dll
821 installer = msilib.MakeInstaller()
822 return installer.FileVersion("msvcr71.dll", 0), \
823 installer.FileVersion("msvcr71.dll", 1)
824
825class PyDirectory(Directory):
826 """By default, all components in the Python installer
827 can run from source."""
828 def __init__(self, *args, **kw):
829 if not kw.has_key("componentflags"):
830 kw['componentflags'] = 2 #msidbComponentAttributesOptional
831 Directory.__init__(self, *args, **kw)
832
833# See "File Table", "Component Table", "Directory Table",
834# "FeatureComponents Table"
835def add_files(db):
836 cab = CAB("python")
837 tmpfiles = []
838 # Add all executables, icons, text files into the TARGETDIR component
839 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
840 default_feature.set_current()
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000841 if not msilib.Win64:
842 root.add_file("PCBuild/w9xpopen.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000843 root.add_file("PC/py.ico")
844 root.add_file("PC/pyc.ico")
845 root.add_file("README.txt", src="README")
846 root.add_file("NEWS.txt", src="Misc/NEWS")
847 root.add_file("LICENSE.txt", src="LICENSE")
848 root.start_component("python.exe", keyfile="python.exe")
849 root.add_file("PCBuild/python.exe")
850 root.start_component("pythonw.exe", keyfile="pythonw.exe")
851 root.add_file("PCBuild/pythonw.exe")
852
853 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
854 dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
855 pydll = "python%s%s.dll" % (major, minor)
856 pydllsrc = srcdir + "/PCBuild/" + pydll
857 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll)
858 installer = msilib.MakeInstaller()
859 pyversion = installer.FileVersion(pydllsrc, 0)
860 if not snapshot:
861 # For releases, the Python DLL has the same version as the
862 # installer package.
863 assert pyversion.split(".")[:3] == current_version.split(".")
864 dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor),
865 version=pyversion,
866 language=installer.FileVersion(pydllsrc, 1))
867 # XXX determine dependencies
868 version, lang = extract_msvcr71()
869 dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll")
870 dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
871 version=version, language=lang)
872 tmpfiles.append("msvcr71.dll")
Tim Peters66cb0182004-08-26 05:23:19 +0000873
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000874 # Add all .py files in Lib, except lib-tk, test
875 dirs={}
876 pydirs = [(root,"Lib")]
877 while pydirs:
878 parent, dir = pydirs.pop()
879 if dir == "CVS" or dir.startswith("plat-"):
880 continue
881 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000882 if not have_tcl:
883 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000884 tcltk.set_current()
Martin v. Löwis5c9e55e2004-12-30 14:08:18 +0000885 elif dir in ['test', 'tests', 'data', 'output']:
886 # test: Lib, Lib/email, Lib/bsddb
887 # tests: Lib/distutils
888 # data: Lib/email/test
889 # output: Lib/test
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000890 testsuite.set_current()
891 else:
892 default_feature.set_current()
893 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
894 # Add additional files
895 dirs[dir]=lib
896 lib.glob("*.txt")
897 if dir=='site-packages':
Martin v. Löwis6d60c092004-11-21 10:16:26 +0000898 lib.add_file("README.txt", src="README")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000899 continue
900 files = lib.glob("*.py")
901 files += lib.glob("*.pyw")
902 if files:
903 # Add an entry to the RemoveFile table to remove bytecode files.
904 lib.remove_pyc()
905 if dir=='test' and parent.physical=='Lib':
906 lib.add_file("185test.db")
907 lib.add_file("audiotest.au")
908 lib.add_file("cfgparser.1")
909 lib.add_file("test.xml")
910 lib.add_file("test.xml.out")
911 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000912 lib.add_file("test_difflib_expect.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000913 lib.glob("*.uue")
914 lib.add_file("readme.txt", src="README")
915 if dir=='decimaltestdata':
916 lib.glob("*.decTest")
917 if dir=='output':
918 lib.glob("test_*")
919 if dir=='idlelib':
920 lib.glob("*.def")
921 lib.add_file("idle.bat")
922 if dir=="Icons":
923 lib.glob("*.gif")
924 lib.add_file("idle.icns")
925 if dir=="command":
926 lib.add_file("wininst-6.exe")
927 lib.add_file("wininst-7.1.exe")
928 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
929 # This should contain all non-CVS files listed in CVS
930 for f in os.listdir(lib.absolute):
931 if f.endswith(".txt") or f=="CVS":continue
932 if f.endswith(".au") or f.endswith(".gif"):
933 lib.add_file(f)
934 else:
935 print "WARNING: New file %s in email/test/data" % f
936 for f in os.listdir(lib.absolute):
937 if os.path.isdir(os.path.join(lib.absolute, f)):
938 pydirs.append((lib, f))
939 # Add DLLs
940 default_feature.set_current()
941 lib = PyDirectory(db, cab, root, srcdir+"/PCBuild", "DLLs", "DLLS|DLLs")
942 dlls = []
943 tclfiles = []
944 for f in extensions:
945 if f=="_tkinter.pyd":
946 continue
947 if not os.path.exists(srcdir+"/PCBuild/"+f):
948 print "WARNING: Missing extension", f
949 continue
950 dlls.append(f)
951 lib.add_file(f)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000952 if have_tcl:
953 if not os.path.exists(srcdir+"/PCBuild/_tkinter.pyd"):
954 print "WARNING: Missing _tkinter.pyd"
955 else:
956 lib.start_component("TkDLLs", tcltk)
957 lib.add_file("_tkinter.pyd")
958 dlls.append("_tkinter.pyd")
959 tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
960 for f in glob.glob1(tcldir, "*.dll"):
961 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000962 # check whether there are any unknown extensions
963 for f in glob.glob1(srcdir+"/PCBuild", "*.pyd"):
964 if f.endswith("_d.pyd"): continue # debug version
965 if f in dlls: continue
966 print "WARNING: Unknown extension", f
Tim Peters66cb0182004-08-26 05:23:19 +0000967
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000968 # Add headers
969 default_feature.set_current()
970 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
971 lib.glob("*.h")
972 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
973 # Add import libraries
974 lib = PyDirectory(db, cab, root, "PCBuild", "libs", "LIBS|libs")
975 for f in dlls:
976 lib.add_file(f.replace('pyd','lib'))
977 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwis9fda9312004-12-22 13:41:49 +0000978 # Add the mingw-format library
979 if have_mingw:
980 lib.add_file('libpython%s%s.a' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000981 if have_tcl:
982 # Add Tcl/Tk
983 tcldirs = [(root, '../tcltk/lib', 'tcl')]
984 tcltk.set_current()
985 while tcldirs:
986 parent, phys, dir = tcldirs.pop()
987 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
988 if not os.path.exists(lib.absolute):
989 continue
990 for f in os.listdir(lib.absolute):
991 if os.path.isdir(os.path.join(lib.absolute, f)):
992 tcldirs.append((lib, f, f))
993 else:
994 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000995 # Add tools
996 tools.set_current()
997 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
998 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
999 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1000 lib.glob("*.py")
1001 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1002 lib.remove_pyc()
1003 lib.glob("*.txt")
1004 if f == "pynche":
1005 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1006 x.glob("*.txt")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001007 if os.path.exists(os.path.join(lib.absolute, "README")):
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001008 lib.add_file("README.txt", src="README")
Martin v. Löwis4d930be2004-12-01 21:46:35 +00001009 if f == 'Scripts':
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001010 if have_tcl:
1011 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1012 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001013 # Add documentation
1014 htmlfiles.set_current()
1015 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
1016 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
1017 lib.add_file("Python%s%s.chm" % (major, minor))
1018
1019 cab.commit(db)
1020
1021 for f in tmpfiles:
1022 os.unlink(f)
1023
1024# See "Registry Table", "Component Table"
1025def add_registry(db):
1026 # File extensions, associated with the REGISTRY.def component
1027 # IDLE verbs depend on the tcltk feature.
1028 # msidbComponentAttributesRegistryKeyPath = 4
1029 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001030 tcldata = []
1031 if have_tcl:
1032 tcldata = [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001033 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4, None,
1034 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001035 add_data(db, "Component",
1036 # msidbComponentAttributesRegistryKeyPath = 4
1037 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", 4, None,
1038 "InstallPath"),
1039 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", 4,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001040 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001041 # See "FeatureComponents Table".
1042 # The association between TclTk and pythonw.exe is necessary to make ICE59
1043 # happy, because the installer otherwise believes that the IDLE and PyDoc
1044 # shortcuts might get installed without pythonw.exe being install. This
1045 # is not true, since installing TclTk will install the default feature, which
1046 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001047 # REGISTRY.tcl is not associated with any feature, as it will be requested
1048 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001049 tcldata = []
1050 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001051 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001052 add_data(db, "FeatureComponents",
1053 [(default_feature.id, "REGISTRY"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001054 (ext_feature.id, "REGISTRY.def")] +
1055 tcldata
1056 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001057 # Extensions are not advertised. For advertised extensions,
1058 # we would need separate binaries that install along with the
1059 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001060 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1061 ewi = "Edit with IDLE"
1062 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1063 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001064 tcl_verbs = []
1065 if have_tcl:
1066 tcl_verbs=[
1067 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1068 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1069 "REGISTRY.tcl"),
1070 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1071 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1072 "REGISTRY.tcl"),
1073 ]
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001074 add_data(db, "Registry",
1075 [# Extensions
1076 ("py.ext", -1, r"Software\Classes\."+ext, "",
1077 "Python.File", "REGISTRY.def"),
1078 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1079 "Python.NoConFile", "REGISTRY.def"),
1080 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1081 "Python.CompiledFile", "REGISTRY.def"),
1082 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1083 "Python.CompiledFile", "REGISTRY.def"),
1084 # MIME types
1085 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1086 "text/plain", "REGISTRY.def"),
1087 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1088 "text/plain", "REGISTRY.def"),
1089 #Verbs
1090 ("py.open", -1, pat % (testprefix, "", "open"), "",
1091 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1092 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1093 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1094 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1095 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwiseac02e62004-11-18 08:00:33 +00001096 ] + tcl_verbs + [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001097 #Icons
1098 ("py.icon", -1, pat2 % (testprefix, ""), "",
1099 r'[TARGETDIR]py.ico', "REGISTRY.def"),
1100 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
1101 r'[TARGETDIR]py.ico', "REGISTRY.def"),
1102 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
1103 r'[TARGETDIR]pyc.ico', "REGISTRY.def"),
1104 # Descriptions
1105 ("py.txt", -1, pat3 % (testprefix, ""), "",
1106 "Python File", "REGISTRY.def"),
1107 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1108 "Python File (no console)", "REGISTRY.def"),
1109 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1110 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001111 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001112
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001113 # Registry keys
1114 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1115 add_data(db, "Registry",
1116 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1117 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1118 "Python %s" % short_version, "REGISTRY"),
1119 ("PythonPath", -1, prefix+r"\PythonPath", "",
Martin v. Löwisf13337d2004-09-19 18:36:45 +00001120 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001121 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
1122 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY"),
1123 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1124 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1125 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1126 ])
1127 # Shortcuts, see "Shortcut Table"
1128 add_data(db, "Directory",
1129 [("ProgramMenuFolder", "TARGETDIR", "."),
1130 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1131 add_data(db, "RemoveFile",
1132 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001133 tcltkshortcuts = []
1134 if have_tcl:
1135 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001136 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001137 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 +00001138 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
Martin v. Löwisac191da2004-12-22 12:55:44 +00001139 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 +00001140 ]
1141 add_data(db, "Shortcut",
1142 tcltkshortcuts +
1143 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001144 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1145 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
1146 ("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1147 htmlfiles.id, None, None, None, None, None, None, None),
1148 ## Non-advertised shortcuts: must be associated with a registry component
1149 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1150 SystemFolderName+"msiexec", "/x%s" % product_code,
1151 None, None, None, None, None, None),
1152 ])
1153 db.Commit()
1154
1155db = build_database()
1156try:
1157 add_features(db)
1158 add_ui(db)
1159 add_files(db)
1160 add_registry(db)
1161 remove_old_versions(db)
1162 db.Commit()
1163finally:
1164 del db