blob: 2dc94c9b6f9d980f9c51a585752830814e8754cf [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.
4import msilib, schema, sequence, os, glob, time
5from msilib import Feature, CAB, Directory, Dialog, Binary, add_data
6import uisample
7from win32com.client import constants
8
9# Settings can be overridden in config.py below
10# 1 for Itanium build
11msilib.Win64 = 0
12# 0 for official python.org releases
13# 1 for intermediate releases by anybody, with
14# a new product code for every package.
15snapshot = 1
16# 1 means that file extension is px, not py,
17# and binaries start with x
18testpackage = 0
19# Location of build tree
20srcdir = os.path.abspath("../..")
21# Text to be displayed as the version in dialogs etc.
22# goes into file name and ProductCode. Defaults to
23# current_version.day for Snapshot, current_version otherwise
24full_current_version = None
Martin v. Löwise0f780d2004-09-01 14:51:06 +000025# Is Tcl available at all?
26have_tcl = True
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +000027
28try:
29 from config import *
30except ImportError:
31 pass
32
33# Extract current version from Include/patchlevel.h
34lines = open(srcdir + "/Include/patchlevel.h").readlines()
35major = minor = micro = level = serial = None
36levels = {
37 'PY_RELEASE_LEVEL_ALPHA':0xA,
38 'PY_RELEASE_LEVEL_BETA': 0xB,
39 'PY_RELEASE_LEVEL_GAMMA':0xC,
40 'PY_RELEASE_LEVEL_FINAL':0xF
41 }
42for l in lines:
43 if not l.startswith("#define"):
44 continue
45 l = l.split()
46 if len(l) != 3:
47 continue
48 _, name, value = l
49 if name == 'PY_MAJOR_VERSION': major = value
50 if name == 'PY_MINOR_VERSION': minor = value
51 if name == 'PY_MICRO_VERSION': micro = value
52 if name == 'PY_RELEASE_LEVEL': level = levels[value]
53 if name == 'PY_RELEASE_SERIAL': serial = value
54
55short_version = major+"."+minor
56# See PC/make_versioninfo.c
57FIELD3 = 1000*int(micro) + 10*level + int(serial)
58current_version = "%s.%d" % (short_version, FIELD3)
59
60# This should never change. The UpgradeCode of this package can be
61# used in the Upgrade table of future packages to make the future
62# package replace this one. See "UpgradeCode Property".
63upgrade_code_snapshot='{92A24481-3ECB-40FC-8836-04B7966EC0D5}'
64upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}'
65
66# This should be extended for each Python release.
67# The product code must change whenever the name of the MSI file
68# changes, and when new component codes are issued for existing
69# components. See "Changing the Product Code". As we change the
70# component codes with every build, we need a new product code
71# each time. For intermediate (snapshot) releases, they are automatically
72# generated. For official releases, we record the product codes,
73# so people can refer to them.
74product_codes = {
75 '2.4.101': '{0e9b4d8e-6cda-446e-a208-7b92f3ddffa0}', # 2.4a1, released as a snapshot
76 '2.4.102': '{1b998745-4901-4edb-bc52-213689e1b922}', # 2.4a2
77 '2.4.103': '{33fc8bd2-1e8f-4add-a40a-ade2728d5942}', # 2.4a3
78 '2.4.111': '{51a7e2a8-2025-4ef0-86ff-e6aab742d1fa}', # 2.4b1
79 '2.4.112': '{4a5e7c1d-c659-4fe3-b8c9-7c65bd9c95a5}', # 2.4b2
80 '2.4.121': '{75508821-a8e9-40a8-95bd-dbe6033ddbea}', # 2.4c1
81 '2.4.122': '{83a9118b-4bdd-473b-afc3-bcb142feca9e}', # 2.4c2
82 '2.4.150': '{82d9302e-f209-4805-b548-52087047483a}', # 2.4.0
83}
84
85if snapshot:
86 current_version = "%s.%s.%s" % (major, minor, int(time.time()/3600/24))
87 product_code = msilib.gen_uuid()
88else:
89 product_code = product_codes[current_version]
90
91if full_current_version is None:
92 full_current_version = current_version
93
94extensions = [
95 'bz2.pyd',
96 'pyexpat.pyd',
97 'select.pyd',
98 'unicodedata.pyd',
99 'winsound.pyd',
100 'zlib.pyd',
101 '_bsddb.pyd',
102 '_socket.pyd',
103 '_ssl.pyd',
104 '_testcapi.pyd',
105 '_tkinter.pyd',
106]
107
108if major+minor <= "23":
109 extensions.extend([
110 '_csv.pyd',
111 '_sre.pyd',
112 '_symtable.pyd',
113 '_winreg.pyd',
114 'datetime.pyd'
115 'mmap.pyd',
Tim Peters66cb0182004-08-26 05:23:19 +0000116 'parser.pyd',
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000117 ])
118
119if testpackage:
120 ext = 'px'
121 testprefix = 'x'
122else:
123 ext = 'py'
124 testprefix = ''
125
126if msilib.Win64:
127 SystemFolderName = "[SystemFolder64]"
128else:
129 SystemFolderName = "[SystemFolder]"
130
131msilib.reset()
132
133# condition in which to install pythonxy.dll in system32:
134# a) it is Windows 9x or
135# b) it is NT, the user is privileged, and has chosen per-machine installation
136sys32cond = "(Windows9x or (Privileged and ALLUSERS))"
137
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000138def build_database():
139 """Generate an empty database, with just the schema and the
140 Summary information stream."""
141 if snapshot:
142 uc = upgrade_code_snapshot
143 else:
144 uc = upgrade_code
145 # schema represents the installer 2.0 database schema.
146 # sequence is the set of standard sequences
147 # (ui/execute, admin/advt/install)
148 if msilib.Win64:
149 w64 = ".ia64"
150 else:
151 w64 = ""
Tim Peters66cb0182004-08-26 05:23:19 +0000152 db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000153 schema, ProductName="Python "+full_current_version,
154 ProductCode=product_code,
155 ProductVersion=current_version,
156 Manufacturer=u"Martin v. L\xf6wis")
157 # The default sequencing of the RemoveExistingProducts action causes
158 # removal of files that got just installed. Place it after
159 # InstallInitialize, so we first uninstall everything, but still roll
160 # back in case the installation is interrupted
161 msilib.change_sequence(sequence.InstallExecuteSequence,
162 "RemoveExistingProducts", 1510)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000163 msilib.add_tables(db, sequence)
164 # We cannot set ALLUSERS in the property table, as this cannot be
165 # reset if the user choses a per-user installation. Instead, we
166 # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages
167 # this property, and when the execution starts, ALLUSERS is set
168 # accordingly.
169 add_data(db, "Property", [("UpgradeCode", uc),
170 ("WhichUsers", "ALL"),
171 ])
172 db.Commit()
173 return db
174
175def remove_old_versions(db):
176 "Fill the upgrade table."
177 start = "%s.%s.0" % (major, minor)
178 # This requests that feature selection states of an older
179 # installation should be forwarded into this one. Upgrading
180 # requires that both the old and the new installation are
181 # either both per-machine or per-user.
182 migrate_features = 1
183 # See "Upgrade Table". We remove releases with the same major and
184 # minor version. For an snapshot, we remove all earlier snapshots. For
185 # a release, we remove all snapshots, and all earlier releases.
186 if snapshot:
187 add_data(db, "Upgrade",
Tim Peters66cb0182004-08-26 05:23:19 +0000188 [(upgrade_code_snapshot, start,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000189 current_version,
190 None, # Ignore language
Tim Peters66cb0182004-08-26 05:23:19 +0000191 migrate_features,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000192 None, # Migrate ALL features
193 "REMOVEOLDSNAPSHOT")])
194 props = "REMOVEOLDSNAPSHOT"
195 else:
196 add_data(db, "Upgrade",
197 [(upgrade_code, start, current_version,
198 None, migrate_features, None, "REMOVEOLDVERSION"),
199 (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1),
200 None, migrate_features, None, "REMOVEOLDSNAPSHOT")])
201 props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION"
202 # Installer collects the product codes of the earlier releases in
203 # these properties. In order to allow modification of the properties,
204 # they must be declared as secure. See "SecureCustomProperties Property"
205 add_data(db, "Property", [("SecureCustomProperties", props)])
206
207class PyDialog(Dialog):
208 """Dialog class with a fixed layout: controls at the top, then a ruler,
209 then a list of buttons: back, next, cancel. Optionally a bitmap at the
210 left."""
211 def __init__(self, *args, **kw):
212 """Dialog(database, name, x, y, w, h, attributes, title, first,
213 default, cancel, bitmap=true)"""
214 Dialog.__init__(self, *args)
215 ruler = self.h - 36
216 bmwidth = 152*ruler/328
217 if kw.get("bitmap", True):
218 self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
219 self.line("BottomLine", 0, ruler, self.w, 0)
220
221 def title(self, title):
222 "Set the title text of the dialog at the top."
223 # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
224 # text, in VerdanaBold10
225 self.text("Title", 135, 10, 220, 60, 0x30003,
226 r"{\VerdanaBold10}%s" % title)
227
228 def back(self, title, next, name = "Back", active = 1):
229 """Add a back button with a given title, the tab-next button,
230 its name in the Control table, possibly initially disabled.
231
232 Return the button, so that events can be associated"""
233 if active:
234 flags = 3 # Visible|Enabled
235 else:
236 flags = 1 # Visible
237 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
238
239 def cancel(self, title, next, name = "Cancel", active = 1):
240 """Add a cancel button with a given title, the tab-next button,
241 its name in the Control table, possibly initially disabled.
242
243 Return the button, so that events can be associated"""
244 if active:
245 flags = 3 # Visible|Enabled
246 else:
247 flags = 1 # Visible
248 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
249
250 def next(self, title, next, name = "Next", active = 1):
251 """Add a Next button with a given title, the tab-next button,
252 its name in the Control table, possibly initially disabled.
253
254 Return the button, so that events can be associated"""
255 if active:
256 flags = 3 # Visible|Enabled
257 else:
258 flags = 1 # Visible
259 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
260
261 def xbutton(self, name, title, next, xpos):
262 """Add a button with a given title, the tab-next button,
263 its name in the Control table, giving its x position; the
264 y-position is aligned with the other buttons.
265
266 Return the button, so that events can be associated"""
267 return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
268
269def add_ui(db):
270 x = y = 50
271 w = 370
272 h = 300
273 title = "[ProductName] Setup"
274
275 # see "Dialog Style Bits"
276 modal = 3 # visible | modal
277 modeless = 1 # visible
278 track_disk_space = 32
279
280 add_data(db, 'ActionText', uisample.ActionText)
281 add_data(db, 'UIText', uisample.UIText)
282
283 # Bitmaps
284 if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
285 raise "Run icons.mak in PC directory"
286 add_data(db, "Binary",
287 [("PythonWin", msilib.Binary(srcdir+r"\PCbuild\installer.bmp")), # 152x328 pixels
288 ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
289 ])
290 add_data(db, "Icon",
291 [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))])
292
293 # Scripts
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000294 # CheckDir sets TargetExists if TARGETDIR exists.
295 # UpdateEditIDLE sets the REGISTRY.tcl component into
296 # the installed/uninstalled state according to both the
297 # Extensions and TclTk features.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000298 open("inst.vbs","w").write("""
299 Function CheckDir()
300 Set FSO = CreateObject("Scripting.FileSystemObject")
301 if FSO.FolderExists(Session.Property("TARGETDIR")) then
302 Session.Property("TargetExists") = "1"
303 else
304 Session.Property("TargetExists") = "0"
305 end if
306 End Function
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000307 Function UpdateEditIDLE()
308 Dim ext_new, tcl_new, regtcl_old
309 ext_new = Session.FeatureRequestState("Extensions")
310 tcl_new = Session.FeatureRequestState("TclTk")
311 if ext_new=-1 then
312 ext_new = Session.FeatureCurrentState("Extensions")
313 end if
314 if tcl_new=-1 then
315 tcl_new = Session.FeatureCurrentState("TclTk")
316 end if
317 regtcl_old = Session.ComponentCurrentState("REGISTRY.tcl")
318 if ext_new=3 and (tcl_new=3 or tcl_new=4) and regtcl_old<>3 then
319 Session.ComponentRequestState("REGISTRY.tcl")=3
320 end if
321 if (ext_new=2 or tcl_new=2) and regtcl_old<>2 then
322 Session.ComponentRequestState("REGISTRY.tcl")=2
323 end if
324 End Function
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000325 """)
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000326 # To add debug messages into scripts, the following fragment can be used
327 # set objRec = Session.Installer.CreateRecord(1)
328 # objRec.StringData(1) = "Debug message"
329 # Session.message &H04000000, objRec
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000330 add_data(db, "Binary", [("Script", msilib.Binary("inst.vbs"))])
331 # See "Custom Action Type 6"
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000332 add_data(db, "CustomAction",
333 [("CheckDir", 6, "Script", "CheckDir"),
334 ("UpdateEditIDLE", 6, "Script", "UpdateEditIDLE")])
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000335 os.unlink("inst.vbs")
336
337
338 # UI customization properties
339 add_data(db, "Property",
340 # See "DefaultUIFont Property"
341 [("DefaultUIFont", "DlgFont8"),
342 # See "ErrorDialog Style Bit"
343 ("ErrorDialog", "ErrorDlg"),
344 ("Progress1", "Install"), # modified in maintenance type dlg
345 ("Progress2", "installs"),
346 ("MaintenanceForm_Action", "Repair")])
347
348 # Fonts, see "TextStyle Table"
349 add_data(db, "TextStyle",
350 [("DlgFont8", "Tahoma", 9, None, 0),
351 ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
352 ("VerdanaBold10", "Verdana", 10, None, 1),
353 ])
354
355 # See "CustomAction Table"
356 add_data(db, "CustomAction", [
357 # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
358 # See "Custom Action Type 51",
359 # "Custom Action Execution Scheduling Options"
360 ("InitialTargetDir", 307, "TARGETDIR",
361 "[WindowsVolume]Python%s%s" % (major, minor)),
362 ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"),
363 ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName),
364 # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile
365 # See "Custom Action Type 18"
366 ("CompilePyc", 18, "python.exe", r"[TARGETDIR]Lib\compileall.py [TARGETDIR]Lib"),
367 ("CompilePyo", 18, "python.exe", r"-O [TARGETDIR]Lib\compileall.py [TARGETDIR]Lib")
368 ])
369
370 # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
371 # Numbers indicate sequence; see sequence.py for how these action integrate
372 add_data(db, "InstallUISequence",
373 [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
374 ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
375 ("InitialTargetDir", 'TARGETDIR=""', 750),
376 # In the user interface, assume all-users installation if privileged.
377 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
378 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
379 ("SelectDirectoryDlg", "Not Installed", 1230),
380 # XXX no support for resume installations yet
381 #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
382 ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
383 ("ProgressDlg", None, 1280)])
384 add_data(db, "AdminUISequence",
385 [("InitialTargetDir", 'TARGETDIR=""', 750),
386 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
387 ])
388
389 # Execute Sequences
390 add_data(db, "InstallExecuteSequence",
391 [("InitialTargetDir", 'TARGETDIR=""', 750),
392 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
393 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000394 ("UpdateEditIDLE", None, 1050),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000395 ("CompilePyc", "COMPILEALL", 6800),
396 ("CompilePyo", "COMPILEALL", 6801),
397 ])
398 add_data(db, "AdminExecuteSequence",
399 [("InitialTargetDir", 'TARGETDIR=""', 750),
400 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
401 ("CompilePyc", "COMPILEALL", 6800),
402 ("CompilePyo", "COMPILEALL", 6801),
403 ])
404
405 #####################################################################
406 # Standard dialogs: FatalError, UserExit, ExitDialog
407 fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
408 "Finish", "Finish", "Finish")
409 fatal.title("[ProductName] Installer ended prematurely")
410 fatal.back("< Back", "Finish", active = 0)
411 fatal.cancel("Cancel", "Back", active = 0)
412 fatal.text("Description1", 135, 70, 220, 80, 0x30003,
413 "[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.")
414 fatal.text("Description2", 135, 155, 220, 20, 0x30003,
415 "Click the Finish button to exit the Installer.")
416 c=fatal.next("Finish", "Cancel", name="Finish")
417 # See "ControlEvent Table". Parameters are the event, the parameter
418 # to the action, and optionally the condition for the event, and the order
419 # of events.
420 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000421
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000422 user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
423 "Finish", "Finish", "Finish")
424 user_exit.title("[ProductName] Installer was interrupted")
425 user_exit.back("< Back", "Finish", active = 0)
426 user_exit.cancel("Cancel", "Back", active = 0)
427 user_exit.text("Description1", 135, 70, 220, 80, 0x30003,
428 "[ProductName] setup was interrupted. Your system has not been modified. "
429 "To install this program at a later time, please run the installation again.")
430 user_exit.text("Description2", 135, 155, 220, 20, 0x30003,
431 "Click the Finish button to exit the Installer.")
432 c = user_exit.next("Finish", "Cancel", name="Finish")
433 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000434
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000435 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
436 "Finish", "Finish", "Finish")
437 exit_dialog.title("Completing the [ProductName] Installer")
438 exit_dialog.back("< Back", "Finish", active = 0)
439 exit_dialog.cancel("Cancel", "Back", active = 0)
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000440 exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003,
441 "Special Windows thanks to:\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000442 " LettError, Erik van Blokland, for the \n"
443 " Python for Windows graphic.\n"
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000444 " http://www.letterror.com/\n"
445 "\n"
Martin v. Löwisd3f61a22004-08-30 09:22:30 +0000446 " Mark Hammond, without whose years of freely \n"
447 " shared Windows expertise, Python for Windows \n"
448 " would still be Python for DOS.")
Tim Peters66cb0182004-08-26 05:23:19 +0000449
Martin v. Löwis2dd2a282004-08-22 17:10:12 +0000450 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000451 "Click the Finish button to exit the Installer.")
452 c = exit_dialog.next("Finish", "Cancel", name="Finish")
453 c.event("EndDialog", "Return")
454
455 #####################################################################
456 # Required dialog: FilesInUse, ErrorDlg
457 inuse = PyDialog(db, "FilesInUse",
458 x, y, w, h,
459 19, # KeepModeless|Modal|Visible
460 title,
461 "Retry", "Retry", "Retry", bitmap=False)
462 inuse.text("Title", 15, 6, 200, 15, 0x30003,
463 r"{\DlgFontBold8}Files in Use")
464 inuse.text("Description", 20, 23, 280, 20, 0x30003,
465 "Some files that need to be updated are currently in use.")
466 inuse.text("Text", 20, 55, 330, 50, 3,
467 "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.")
468 inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
469 None, None, None)
470 c=inuse.back("Exit", "Ignore", name="Exit")
471 c.event("EndDialog", "Exit")
472 c=inuse.next("Ignore", "Retry", name="Ignore")
473 c.event("EndDialog", "Ignore")
474 c=inuse.cancel("Retry", "Exit", name="Retry")
475 c.event("EndDialog","Retry")
476
477
478 # See "Error Dialog". See "ICE20" for the required names of the controls.
479 error = Dialog(db, "ErrorDlg",
480 50, 10, 330, 101,
481 65543, # Error|Minimize|Modal|Visible
482 title,
483 "ErrorText", None, None)
484 error.text("ErrorText", 50,9,280,48,3, "")
485 error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
486 error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
487 error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
488 error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
489 error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
490 error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
491 error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
492 error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
493
494 #####################################################################
495 # Global "Query Cancel" dialog
496 cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
497 "No", "No", "No")
Tim Peters66cb0182004-08-26 05:23:19 +0000498 cancel.text("Text", 48, 15, 194, 30, 3,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000499 "Are you sure you want to cancel [ProductName] installation?")
500 cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
501 "py.ico", None, None)
502 c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
503 c.event("EndDialog", "Exit")
Tim Peters66cb0182004-08-26 05:23:19 +0000504
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000505 c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
506 c.event("EndDialog", "Return")
507
508 #####################################################################
509 # Global "Wait for costing" dialog
510 costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
511 "Return", "Return", "Return")
512 costing.text("Text", 48, 15, 194, 30, 3,
513 "Please wait while the installer finishes determining your disk space requirements.")
514 costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
515 "py.ico", None, None)
516 c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
517 c.event("EndDialog", "Exit")
518
519 #####################################################################
520 # Preparation dialog: no user input except cancellation
521 prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
522 "Cancel", "Cancel", "Cancel")
523 prep.text("Description", 135, 70, 220, 40, 0x30003,
524 "Please wait while the Installer prepares to guide you through the installation.")
525 prep.title("Welcome to the [ProductName] Installer")
526 c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...")
527 c.mapping("ActionText", "Text")
528 c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None)
529 c.mapping("ActionData", "Text")
530 prep.back("Back", None, active=0)
531 prep.next("Next", None, active=0)
532 c=prep.cancel("Cancel", None)
533 c.event("SpawnDialog", "CancelDlg")
534
535 #####################################################################
536 # Target directory selection
537 seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
538 "Next", "Next", "Cancel")
539 seldlg.title("Select Destination Directory")
540 seldlg.text("Description", 135, 50, 220, 40, 0x30003,
541 "Please select a directory for the [ProductName] files.")
542
543 seldlg.back("< Back", None, active=0)
544 c = seldlg.next("Next >", "Cancel")
545 c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1)
546 # If the target exists, but we found that we are going to remove old versions, don't bother
547 # confirming that the target directory exists. Strictly speaking, we should determine that
548 # the target directory is indeed the target of the product that we are going to remove, but
549 # I don't know how to do that.
550 c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2)
551 c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3)
552 c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4)
553 c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5)
554
555 c = seldlg.cancel("Cancel", "DirectoryCombo")
556 c.event("SpawnDialog", "CancelDlg")
557
558 seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219,
559 "TARGETDIR", None, "DirectoryList", None)
560 seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR",
561 None, "PathEdit", None)
562 seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None)
563 c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
564 c.event("DirectoryListUp", "0")
565 c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
566 c.event("DirectoryListNew", "0")
567
568 #####################################################################
569 # SelectFeaturesDlg
570 features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space,
571 title, "Tree", "Next", "Cancel")
572 features.title("Customize [ProductName]")
573 features.text("Description", 135, 35, 220, 15, 0x30003,
574 "Select the way you want features to be installed.")
575 features.text("Text", 135,45,220,30, 3,
576 "Click on the icons in the tree below to change the way features will be installed.")
577
578 c=features.back("< Back", "Next")
579 c.event("NewDialog", "SelectDirectoryDlg")
580
581 c=features.next("Next >", "Cancel")
582 c.mapping("SelectionNoItems", "Enabled")
583 c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1)
584 c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2)
585
586 c=features.cancel("Cancel", "Tree")
587 c.event("SpawnDialog", "CancelDlg")
588
Tim Peters66cb0182004-08-26 05:23:19 +0000589 # 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 +0000590 features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty",
591 "Tree of selections", "Back", None)
592
593 #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost")
594 #c.mapping("SelectionNoItems", "Enabled")
595 #c.event("Reset", "0")
Tim Peters66cb0182004-08-26 05:23:19 +0000596
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000597 features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None)
598
599 c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10)
600 c.mapping("SelectionNoItems","Enabled")
601 c.event("SpawnDialog", "DiskCostDlg")
602
603 c=features.xbutton("Advanced", "Advanced", None, 0.30)
604 c.event("SpawnDialog", "AdvancedDlg")
605
606 c=features.text("ItemDescription", 140, 180, 210, 30, 3,
607 "Multiline description of the currently selected item.")
608 c.mapping("SelectionDescription","Text")
Tim Peters66cb0182004-08-26 05:23:19 +0000609
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000610 c=features.text("ItemSize", 140, 210, 210, 45, 3,
611 "The size of the currently selected item.")
612 c.mapping("SelectionSize", "Text")
613
614 #####################################################################
615 # Disk cost
616 cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
617 "OK", "OK", "OK", bitmap=False)
618 cost.text("Title", 15, 6, 200, 15, 0x30003,
619 "{\DlgFontBold8}Disk Space Requirements")
620 cost.text("Description", 20, 20, 280, 20, 0x30003,
621 "The disk space required for the installation of the selected features.")
622 cost.text("Text", 20, 53, 330, 60, 3,
623 "The highlighted volumes (if any) do not have enough disk space "
624 "available for the currently selected features. You can either "
625 "remove some files from the highlighted volumes, or choose to "
626 "install less features onto local drive(s), or select different "
627 "destination drive(s).")
628 cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
629 None, "{120}{70}{70}{70}{70}", None, None)
630 cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
631
632 #####################################################################
633 # WhichUsers Dialog. Only available on NT, and for privileged users.
634 # This must be run before FindRelatedProducts, because that will
635 # take into account whether the previous installation was per-user
636 # or per-machine. We currently don't support going back to this
637 # dialog after "Next" was selected; to support this, we would need to
638 # find how to reset the ALLUSERS property, and how to re-run
639 # FindRelatedProducts.
640 # On Windows9x, the ALLUSERS property is ignored on the command line
641 # and in the Property table, but installer fails according to the documentation
642 # if a dialog attempts to set ALLUSERS.
643 whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
644 "AdminInstall", "Next", "Cancel")
645 whichusers.title("Select whether to install [ProductName] for all users of this computer.")
646 # A radio group with two options: allusers, justme
647 g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3,
648 "WhichUsers", "", "Next")
649 g.add("ALL", 0, 5, 150, 20, "Install for all users")
650 g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
651
Tim Peters66cb0182004-08-26 05:23:19 +0000652 whichusers.back("Back", None, active=0)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000653
654 c = whichusers.next("Next >", "Cancel")
655 c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
656 c.event("EndDialog", "Return", order = 2)
657
658 c = whichusers.cancel("Cancel", "AdminInstall")
659 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000660
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000661 #####################################################################
662 # Advanced Dialog.
663 advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
664 "CompilePyc", "Next", "Cancel")
665 advanced.title("Advanced Options for [ProductName]")
666 # A radio group with two options: allusers, justme
667 advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
668 "COMPILEALL", "Compile .py files to byte code after installation", "Next")
669
670 c = advanced.next("Finish", "Cancel")
671 c.event("EndDialog", "Return")
672
673 c = advanced.cancel("Cancel", "CompilePyc")
674 c.event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000675
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000676 #####################################################################
Tim Peters66cb0182004-08-26 05:23:19 +0000677 # Existing Directory dialog
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000678 dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
679 "No", "No", "No")
680 dlg.text("Title", 10, 20, 180, 40, 3,
681 "[TARGETDIR] exists. Are you sure you want to overwrite existing files?")
682 c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No")
683 c.event("[TargetExists]", "0", order=1)
684 c.event("[TargetExistsOk]", "1", order=2)
685 c.event("EndDialog", "Return", order=3)
686 c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes")
687 c.event("EndDialog", "Return")
688
689 #####################################################################
690 # Installation Progress dialog (modeless)
691 progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
692 "Cancel", "Cancel", "Cancel", bitmap=False)
693 progress.text("Title", 20, 15, 200, 15, 0x30003,
694 "{\DlgFontBold8}[Progress1] [ProductName]")
695 progress.text("Text", 35, 65, 300, 30, 3,
696 "Please wait while the Installer [Progress2] [ProductName]. "
697 "This may take several minutes.")
698 progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
699
700 c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
701 c.mapping("ActionText", "Text")
702
703 #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
704 #c.mapping("ActionData", "Text")
705
706 c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
707 None, "Progress done", None, None)
708 c.mapping("SetProgress", "Progress")
709
710 progress.back("< Back", "Next", active=False)
711 progress.next("Next >", "Cancel", active=False)
712 progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
713
714 # Maintenance type: repair/uninstall
715 maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
716 "Next", "Next", "Cancel")
717 maint.title("Welcome to the [ProductName] Setup Wizard")
718 maint.text("BodyText", 135, 63, 230, 42, 3,
719 "Select whether you want to repair or remove [ProductName].")
720 g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3,
721 "MaintenanceForm_Action", "", "Next")
722 g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
723 g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
724 g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
Tim Peters66cb0182004-08-26 05:23:19 +0000725
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000726 maint.back("< Back", None, active=False)
727 c=maint.next("Finish", "Cancel")
728 # Change installation: Change progress dialog to "Change", then ask
729 # for feature selection
730 c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
731 c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
732
733 # Reinstall: Change progress dialog to "Repair", then invoke reinstall
734 # Also set list of reinstalled features to "ALL"
735 c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
736 c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
737 c.event("[Progress2]", "repaires", 'MaintenanceForm_Action="Repair"', 7)
738 c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
739
740 # Uninstall: Change progress to "Remove", then invoke uninstall
741 # Also set list of removed features to "ALL"
742 c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
743 c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
744 c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
745 c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
746
Tim Peters66cb0182004-08-26 05:23:19 +0000747 # Close dialog when maintenance action scheduled
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000748 c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
749 c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
Tim Peters66cb0182004-08-26 05:23:19 +0000750
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000751 maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
Tim Peters66cb0182004-08-26 05:23:19 +0000752
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000753
754# See "Feature Table". The feature level is 1 for all features,
755# and the feature attributes are 0 for the DefaultFeature, and
756# FollowParent for all other features. The numbers are the Display
757# column.
758def add_features(db):
759 # feature attributes:
760 # msidbFeatureAttributesFollowParent == 2
761 # msidbFeatureAttributesDisallowAdvertise == 8
762 # Features that need to be installed with together with the main feature
763 # (i.e. additional Python libraries) need to follow the parent feature.
764 # Features that have no advertisement trigger (e.g. the test suite)
765 # must not support advertisement
766 global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature
767 default_feature = Feature(db, "DefaultFeature", "Python",
768 "Python Interpreter and Libraries",
769 1, directory = "TARGETDIR")
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000770 # We don't support advertisement of extensions
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000771 ext_feature = Feature(db, "Extensions", "Register Extensions",
772 "Make this Python installation the default Python installation", 3,
Martin v. Löwisdff68d02004-09-10 09:20:10 +0000773 parent = default_feature, attributes=2|8)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000774 if have_tcl:
775 tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000776 parent = default_feature, attributes=2)
777 htmlfiles = Feature(db, "Documentation", "Documentation",
778 "Python HTMLHelp File", 7, parent = default_feature)
779 tools = Feature(db, "Tools", "Utility Scripts",
Tim Peters66cb0182004-08-26 05:23:19 +0000780 "Python utility scripts (Tools/", 9,
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000781 parent = default_feature, attributes=2)
782 testsuite = Feature(db, "Testsuite", "Test suite",
783 "Python test suite (Lib/test/)", 11,
784 parent = default_feature, attributes=2|8)
Tim Peters66cb0182004-08-26 05:23:19 +0000785
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000786def extract_msvcr71():
787 import _winreg
788 # Find the location of the merge modules
789 k = _winreg.OpenKey(
790 _winreg.HKEY_LOCAL_MACHINE,
791 r"Software\Microsoft\VisualStudio\7.1\Setup\VS")
792 dir = _winreg.QueryValueEx(k, "MSMDir")[0]
793 _winreg.CloseKey(k)
794 files = glob.glob1(dir, "*CRT71*")
795 assert len(files) == 1
796 file = os.path.join(dir, files[0])
797 # Extract msvcr71.dll
798 m = msilib.MakeMerge2()
799 m.OpenModule(file, 0)
800 m.ExtractFiles(".")
801 m.CloseModule()
802 # Find the version/language of msvcr71.dll
803 installer = msilib.MakeInstaller()
804 return installer.FileVersion("msvcr71.dll", 0), \
805 installer.FileVersion("msvcr71.dll", 1)
806
807class PyDirectory(Directory):
808 """By default, all components in the Python installer
809 can run from source."""
810 def __init__(self, *args, **kw):
811 if not kw.has_key("componentflags"):
812 kw['componentflags'] = 2 #msidbComponentAttributesOptional
813 Directory.__init__(self, *args, **kw)
814
815# See "File Table", "Component Table", "Directory Table",
816# "FeatureComponents Table"
817def add_files(db):
818 cab = CAB("python")
819 tmpfiles = []
820 # Add all executables, icons, text files into the TARGETDIR component
821 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
822 default_feature.set_current()
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000823 if not msilib.Win64:
824 root.add_file("PCBuild/w9xpopen.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000825 root.add_file("PC/py.ico")
826 root.add_file("PC/pyc.ico")
827 root.add_file("README.txt", src="README")
828 root.add_file("NEWS.txt", src="Misc/NEWS")
829 root.add_file("LICENSE.txt", src="LICENSE")
830 root.start_component("python.exe", keyfile="python.exe")
831 root.add_file("PCBuild/python.exe")
832 root.start_component("pythonw.exe", keyfile="pythonw.exe")
833 root.add_file("PCBuild/pythonw.exe")
Martin v. Löwis0b4a7d92004-09-08 16:09:14 +0000834 root.start_component("extpy.exe", feature=ext_feature, keyfile="extpy.exe")
835 root.add_file("extpy.exe", src="PCBuild/python.exe")
836 root.start_component("extpyw.exe", feature=ext_feature, keyfile="extpyw.exe")
837 root.add_file("extpyw.exe", src="PCBuild/pythonw.exe")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000838
839 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
840 dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
841 pydll = "python%s%s.dll" % (major, minor)
842 pydllsrc = srcdir + "/PCBuild/" + pydll
843 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll)
844 installer = msilib.MakeInstaller()
845 pyversion = installer.FileVersion(pydllsrc, 0)
846 if not snapshot:
847 # For releases, the Python DLL has the same version as the
848 # installer package.
849 assert pyversion.split(".")[:3] == current_version.split(".")
850 dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor),
851 version=pyversion,
852 language=installer.FileVersion(pydllsrc, 1))
853 # XXX determine dependencies
854 version, lang = extract_msvcr71()
855 dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll")
856 dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
857 version=version, language=lang)
858 tmpfiles.append("msvcr71.dll")
Tim Peters66cb0182004-08-26 05:23:19 +0000859
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000860 # Add all .py files in Lib, except lib-tk, test
861 dirs={}
862 pydirs = [(root,"Lib")]
863 while pydirs:
864 parent, dir = pydirs.pop()
865 if dir == "CVS" or dir.startswith("plat-"):
866 continue
867 elif dir in ["lib-tk", "idlelib", "Icons"]:
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000868 if not have_tcl:
869 continue
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000870 tcltk.set_current()
871 elif dir in ['test', 'output']:
872 testsuite.set_current()
873 else:
874 default_feature.set_current()
875 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
876 # Add additional files
877 dirs[dir]=lib
878 lib.glob("*.txt")
879 if dir=='site-packages':
880 continue
881 files = lib.glob("*.py")
882 files += lib.glob("*.pyw")
883 if files:
884 # Add an entry to the RemoveFile table to remove bytecode files.
885 lib.remove_pyc()
886 if dir=='test' and parent.physical=='Lib':
887 lib.add_file("185test.db")
888 lib.add_file("audiotest.au")
889 lib.add_file("cfgparser.1")
890 lib.add_file("test.xml")
891 lib.add_file("test.xml.out")
892 lib.add_file("testtar.tar")
Martin v. Löwis7d3755d2004-09-06 06:31:12 +0000893 lib.add_file("test_difflib_expect.html")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000894 lib.glob("*.uue")
895 lib.add_file("readme.txt", src="README")
896 if dir=='decimaltestdata':
897 lib.glob("*.decTest")
898 if dir=='output':
899 lib.glob("test_*")
900 if dir=='idlelib':
901 lib.glob("*.def")
902 lib.add_file("idle.bat")
903 if dir=="Icons":
904 lib.glob("*.gif")
905 lib.add_file("idle.icns")
906 if dir=="command":
907 lib.add_file("wininst-6.exe")
908 lib.add_file("wininst-7.1.exe")
909 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
910 # This should contain all non-CVS files listed in CVS
911 for f in os.listdir(lib.absolute):
912 if f.endswith(".txt") or f=="CVS":continue
913 if f.endswith(".au") or f.endswith(".gif"):
914 lib.add_file(f)
915 else:
916 print "WARNING: New file %s in email/test/data" % f
917 for f in os.listdir(lib.absolute):
918 if os.path.isdir(os.path.join(lib.absolute, f)):
919 pydirs.append((lib, f))
920 # Add DLLs
921 default_feature.set_current()
922 lib = PyDirectory(db, cab, root, srcdir+"/PCBuild", "DLLs", "DLLS|DLLs")
923 dlls = []
924 tclfiles = []
925 for f in extensions:
926 if f=="_tkinter.pyd":
927 continue
928 if not os.path.exists(srcdir+"/PCBuild/"+f):
929 print "WARNING: Missing extension", f
930 continue
931 dlls.append(f)
932 lib.add_file(f)
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000933 if have_tcl:
934 if not os.path.exists(srcdir+"/PCBuild/_tkinter.pyd"):
935 print "WARNING: Missing _tkinter.pyd"
936 else:
937 lib.start_component("TkDLLs", tcltk)
938 lib.add_file("_tkinter.pyd")
939 dlls.append("_tkinter.pyd")
940 tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
941 for f in glob.glob1(tcldir, "*.dll"):
942 lib.add_file(f, src=os.path.join(tcldir, f))
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000943 # check whether there are any unknown extensions
944 for f in glob.glob1(srcdir+"/PCBuild", "*.pyd"):
945 if f.endswith("_d.pyd"): continue # debug version
946 if f in dlls: continue
947 print "WARNING: Unknown extension", f
Tim Peters66cb0182004-08-26 05:23:19 +0000948
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000949 # Add headers
950 default_feature.set_current()
951 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
952 lib.glob("*.h")
953 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
954 # Add import libraries
955 lib = PyDirectory(db, cab, root, "PCBuild", "libs", "LIBS|libs")
956 for f in dlls:
957 lib.add_file(f.replace('pyd','lib'))
958 lib.add_file('python%s%s.lib' % (major, minor))
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000959 if have_tcl:
960 # Add Tcl/Tk
961 tcldirs = [(root, '../tcltk/lib', 'tcl')]
962 tcltk.set_current()
963 while tcldirs:
964 parent, phys, dir = tcldirs.pop()
965 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
966 if not os.path.exists(lib.absolute):
967 continue
968 for f in os.listdir(lib.absolute):
969 if os.path.isdir(os.path.join(lib.absolute, f)):
970 tcldirs.append((lib, f, f))
971 else:
972 lib.add_file(f)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000973 # Add tools
974 tools.set_current()
975 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
976 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
977 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
978 lib.glob("*.py")
979 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
980 lib.remove_pyc()
981 lib.glob("*.txt")
982 if f == "pynche":
983 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
984 x.glob("*.txt")
985 if f == 'Scripts':
986 lib.add_file("README.txt", src="README")
Martin v. Löwise0f780d2004-09-01 14:51:06 +0000987 if have_tcl:
988 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
989 lib.add_file("pydocgui.pyw")
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +0000990 # Add documentation
991 htmlfiles.set_current()
992 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
993 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
994 lib.add_file("Python%s%s.chm" % (major, minor))
995
996 cab.commit(db)
997
998 for f in tmpfiles:
999 os.unlink(f)
1000
1001# See "Registry Table", "Component Table"
1002def add_registry(db):
1003 # File extensions, associated with the REGISTRY.def component
1004 # IDLE verbs depend on the tcltk feature.
1005 # msidbComponentAttributesRegistryKeyPath = 4
1006 # -1 for Root specifies "dependent on ALLUSERS property"
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001007 tcldata = []
1008 if have_tcl:
1009 tcldata = [
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001010 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4, None,
1011 "py.IDLE")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001012 add_data(db, "Component",
1013 # msidbComponentAttributesRegistryKeyPath = 4
1014 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", 4, None,
1015 "InstallPath"),
1016 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", 4,
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001017 None, None)] + tcldata)
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001018 # See "FeatureComponents Table".
1019 # The association between TclTk and pythonw.exe is necessary to make ICE59
1020 # happy, because the installer otherwise believes that the IDLE and PyDoc
1021 # shortcuts might get installed without pythonw.exe being install. This
1022 # is not true, since installing TclTk will install the default feature, which
1023 # will cause pythonw.exe to be installed.
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001024 # REGISTRY.tcl is not associated with any feature, as it will be requested
1025 # through a custom action
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001026 tcldata = []
1027 if have_tcl:
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001028 tcldata = [(tcltk.id, "pythonw.exe")]
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001029 add_data(db, "FeatureComponents",
1030 [(default_feature.id, "REGISTRY"),
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001031 (ext_feature.id, "REGISTRY.def")] +
1032 tcldata
1033 )
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001034 # Extensions are not advertised. For advertised extensions,
1035 # we would need separate binaries that install along with the
1036 # extension.
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001037 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1038 ewi = "Edit with IDLE"
1039 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1040 pat3 = r"Software\Classes\%sPython.%sFile"
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001041 add_data(db, "Registry",
1042 [# Extensions
1043 ("py.ext", -1, r"Software\Classes\."+ext, "",
1044 "Python.File", "REGISTRY.def"),
1045 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1046 "Python.NoConFile", "REGISTRY.def"),
1047 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1048 "Python.CompiledFile", "REGISTRY.def"),
1049 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1050 "Python.CompiledFile", "REGISTRY.def"),
1051 # MIME types
1052 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1053 "text/plain", "REGISTRY.def"),
1054 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1055 "text/plain", "REGISTRY.def"),
1056 #Verbs
1057 ("py.open", -1, pat % (testprefix, "", "open"), "",
1058 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1059 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1060 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1061 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1062 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001063 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1064 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1065 "REGISTRY.tcl"),
1066 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1067 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1068 "REGISTRY.tcl"),
Martin v. Löwisdff68d02004-09-10 09:20:10 +00001069 #Icons
1070 ("py.icon", -1, pat2 % (testprefix, ""), "",
1071 r'[TARGETDIR]py.ico', "REGISTRY.def"),
1072 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
1073 r'[TARGETDIR]py.ico', "REGISTRY.def"),
1074 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
1075 r'[TARGETDIR]pyc.ico', "REGISTRY.def"),
1076 # Descriptions
1077 ("py.txt", -1, pat3 % (testprefix, ""), "",
1078 "Python File", "REGISTRY.def"),
1079 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1080 "Python File (no console)", "REGISTRY.def"),
1081 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1082 "Compiled Python File", "REGISTRY.def"),
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001083 ])
Tim Peters66cb0182004-08-26 05:23:19 +00001084
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001085 # Registry keys
1086 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1087 add_data(db, "Registry",
1088 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1089 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1090 "Python %s" % short_version, "REGISTRY"),
1091 ("PythonPath", -1, prefix+r"\PythonPath", "",
1092 "[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]lib-tk", "REGISTRY"),
1093 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
1094 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY"),
1095 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1096 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1097 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1098 ])
1099 # Shortcuts, see "Shortcut Table"
1100 add_data(db, "Directory",
1101 [("ProgramMenuFolder", "TARGETDIR", "."),
1102 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1103 add_data(db, "RemoveFile",
1104 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
Martin v. Löwise0f780d2004-09-01 14:51:06 +00001105 tcltkshortcuts = []
1106 if have_tcl:
1107 tcltkshortcuts = [
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001108 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
1109 tcltk.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"),
1110 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
1111 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 +00001112 ]
1113 add_data(db, "Shortcut",
1114 tcltkshortcuts +
1115 [# Advertised shortcuts: targets are features, not files
Martin v. Löwis8ffe9ab2004-08-22 13:34:34 +00001116 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1117 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
1118 ("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1119 htmlfiles.id, None, None, None, None, None, None, None),
1120 ## Non-advertised shortcuts: must be associated with a registry component
1121 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1122 SystemFolderName+"msiexec", "/x%s" % product_code,
1123 None, None, None, None, None, None),
1124 ])
1125 db.Commit()
1126
1127db = build_database()
1128try:
1129 add_features(db)
1130 add_ui(db)
1131 add_files(db)
1132 add_registry(db)
1133 remove_old_versions(db)
1134 db.Commit()
1135finally:
1136 del db