Adapt test_ast to the new ExceptHandler type.
[python.git] / Tools / msi / msi.py
blob03c07f3157fb3a579174a379c81bf91bd921544b
1 # Python MSI Generator
2 # (C) 2003 Martin v. Loewis
3 # See "FOO" in comments refers to MSDN sections with the title FOO.
4 import msilib, schema, sequence, os, glob, time, re, shutil
5 from msilib import Feature, CAB, Directory, Dialog, Binary, add_data
6 import uisample
7 from win32com.client import constants
8 from distutils.spawn import find_executable
9 from uuids import product_codes
11 # Settings can be overridden in config.py below
12 # 0 for official python.org releases
13 # 1 for intermediate releases by anybody, with
14 # a new product code for every package.
15 snapshot = 1
16 # 1 means that file extension is px, not py,
17 # and binaries start with x
18 testpackage = 0
19 # Location of build tree
20 srcdir = 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
24 full_current_version = None
25 # Is Tcl available at all?
26 have_tcl = True
27 # Where is sqlite3.dll located, relative to srcdir?
28 sqlite_dir = "../sqlite-source-3.3.4"
29 # path to PCbuild directory
30 PCBUILD="PCbuild"
31 # msvcrt version
32 #MSVCR = "71"
33 MSVCR = "90"
35 try:
36 from config import *
37 except ImportError:
38 pass
40 # Extract current version from Include/patchlevel.h
41 lines = open(srcdir + "/Include/patchlevel.h").readlines()
42 major = minor = micro = level = serial = None
43 levels = {
44 'PY_RELEASE_LEVEL_ALPHA':0xA,
45 'PY_RELEASE_LEVEL_BETA': 0xB,
46 'PY_RELEASE_LEVEL_GAMMA':0xC,
47 'PY_RELEASE_LEVEL_FINAL':0xF
49 for l in lines:
50 if not l.startswith("#define"):
51 continue
52 l = l.split()
53 if len(l) != 3:
54 continue
55 _, name, value = l
56 if name == 'PY_MAJOR_VERSION': major = value
57 if name == 'PY_MINOR_VERSION': minor = value
58 if name == 'PY_MICRO_VERSION': micro = value
59 if name == 'PY_RELEASE_LEVEL': level = levels[value]
60 if name == 'PY_RELEASE_SERIAL': serial = value
62 short_version = major+"."+minor
63 # See PC/make_versioninfo.c
64 FIELD3 = 1000*int(micro) + 10*level + int(serial)
65 current_version = "%s.%d" % (short_version, FIELD3)
67 # This should never change. The UpgradeCode of this package can be
68 # used in the Upgrade table of future packages to make the future
69 # package replace this one. See "UpgradeCode Property".
70 upgrade_code_snapshot='{92A24481-3ECB-40FC-8836-04B7966EC0D5}'
71 upgrade_code='{65E6DE48-A358-434D-AA4F-4AF72DB4718F}'
73 if snapshot:
74 current_version = "%s.%s.%s" % (major, minor, int(time.time()/3600/24))
75 product_code = msilib.gen_uuid()
76 else:
77 product_code = product_codes[current_version]
79 if full_current_version is None:
80 full_current_version = current_version
82 extensions = [
83 'bz2.pyd',
84 'pyexpat.pyd',
85 'select.pyd',
86 'unicodedata.pyd',
87 'winsound.pyd',
88 '_elementtree.pyd',
89 '_bsddb.pyd',
90 '_socket.pyd',
91 '_ssl.pyd',
92 '_testcapi.pyd',
93 '_tkinter.pyd',
94 '_msi.pyd',
95 '_ctypes.pyd',
96 '_ctypes_test.pyd',
97 '_sqlite3.pyd',
98 '_hashlib.pyd'
101 # Well-known component UUIDs
102 # These are needed for SharedDLLs reference counter; if
103 # a different UUID was used for each incarnation of, say,
104 # python24.dll, an upgrade would set the reference counter
105 # from 1 to 2 (due to what I consider a bug in MSI)
106 # Using the same UUID is fine since these files are versioned,
107 # so Installer will always keep the newest version.
108 # NOTE: All uuids are self generated.
109 msvcr71_uuid = "{8666C8DD-D0B4-4B42-928E-A69E32FA5D4D}"
110 msvcr90_uuid = "{9C28CD84-397C-4045-855C-28B02291A272}"
111 pythondll_uuid = {
112 "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}",
113 "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}",
114 "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}",
115 } [major+minor]
117 # Build the mingw import library, libpythonXY.a
118 # This requires 'nm' and 'dlltool' executables on your PATH
119 def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
120 warning = "WARNING: %s - libpythonXX.a not built"
121 nm = find_executable('nm')
122 dlltool = find_executable('dlltool')
124 if not nm or not dlltool:
125 print warning % "nm and/or dlltool were not found"
126 return False
128 nm_command = '%s -Cs %s' % (nm, lib_file)
129 dlltool_command = "%s --dllname %s --def %s --output-lib %s" % \
130 (dlltool, dll_file, def_file, mingw_lib)
131 export_match = re.compile(r"^_imp__(.*) in python\d+\.dll").match
133 f = open(def_file,'w')
134 print >>f, "LIBRARY %s" % dll_file
135 print >>f, "EXPORTS"
137 nm_pipe = os.popen(nm_command)
138 for line in nm_pipe.readlines():
139 m = export_match(line)
140 if m:
141 print >>f, m.group(1)
142 f.close()
143 exit = nm_pipe.close()
145 if exit:
146 print warning % "nm did not run successfully"
147 return False
149 if os.system(dlltool_command) != 0:
150 print warning % "dlltool did not run successfully"
151 return False
153 return True
155 # Target files (.def and .a) go in PCBuild directory
156 lib_file = os.path.join(srcdir, PCBUILD, "python%s%s.lib" % (major, minor))
157 def_file = os.path.join(srcdir, PCBUILD, "python%s%s.def" % (major, minor))
158 dll_file = "python%s%s.dll" % (major, minor)
159 mingw_lib = os.path.join(srcdir, PCBUILD, "libpython%s%s.a" % (major, minor))
161 have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
163 # Determine the target architechture
164 dll_path = os.path.join(srcdir, PCBUILD, dll_file)
165 msilib.set_arch_from_file(dll_path)
166 if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
167 raise SystemError, "msisupport.dll for incorrect architecture"
169 if testpackage:
170 ext = 'px'
171 testprefix = 'x'
172 else:
173 ext = 'py'
174 testprefix = ''
176 if msilib.Win64:
177 SystemFolderName = "[System64Folder]"
178 registry_component = 4|256
179 else:
180 SystemFolderName = "[SystemFolder]"
181 registry_component = 4
183 msilib.reset()
185 # condition in which to install pythonxy.dll in system32:
186 # a) it is Windows 9x or
187 # b) it is NT, the user is privileged, and has chosen per-machine installation
188 sys32cond = "(Windows9x or (Privileged and ALLUSERS))"
190 def build_database():
191 """Generate an empty database, with just the schema and the
192 Summary information stream."""
193 if snapshot:
194 uc = upgrade_code_snapshot
195 else:
196 uc = upgrade_code
197 # schema represents the installer 2.0 database schema.
198 # sequence is the set of standard sequences
199 # (ui/execute, admin/advt/install)
200 db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
201 schema, ProductName="Python "+full_current_version,
202 ProductCode=product_code,
203 ProductVersion=current_version,
204 Manufacturer=u"Python Software Foundation")
205 # The default sequencing of the RemoveExistingProducts action causes
206 # removal of files that got just installed. Place it after
207 # InstallInitialize, so we first uninstall everything, but still roll
208 # back in case the installation is interrupted
209 msilib.change_sequence(sequence.InstallExecuteSequence,
210 "RemoveExistingProducts", 1510)
211 msilib.add_tables(db, sequence)
212 # We cannot set ALLUSERS in the property table, as this cannot be
213 # reset if the user choses a per-user installation. Instead, we
214 # maintain WhichUsers, which can be "ALL" or "JUSTME". The UI manages
215 # this property, and when the execution starts, ALLUSERS is set
216 # accordingly.
217 add_data(db, "Property", [("UpgradeCode", uc),
218 ("WhichUsers", "ALL"),
219 ("ProductLine", "Python%s%s" % (major, minor)),
221 db.Commit()
222 return db
224 def remove_old_versions(db):
225 "Fill the upgrade table."
226 start = "%s.%s.0" % (major, minor)
227 # This requests that feature selection states of an older
228 # installation should be forwarded into this one. Upgrading
229 # requires that both the old and the new installation are
230 # either both per-machine or per-user.
231 migrate_features = 1
232 # See "Upgrade Table". We remove releases with the same major and
233 # minor version. For an snapshot, we remove all earlier snapshots. For
234 # a release, we remove all snapshots, and all earlier releases.
235 if snapshot:
236 add_data(db, "Upgrade",
237 [(upgrade_code_snapshot, start,
238 current_version,
239 None, # Ignore language
240 migrate_features,
241 None, # Migrate ALL features
242 "REMOVEOLDSNAPSHOT")])
243 props = "REMOVEOLDSNAPSHOT"
244 else:
245 add_data(db, "Upgrade",
246 [(upgrade_code, start, current_version,
247 None, migrate_features, None, "REMOVEOLDVERSION"),
248 (upgrade_code_snapshot, start, "%s.%d.0" % (major, int(minor)+1),
249 None, migrate_features, None, "REMOVEOLDSNAPSHOT")])
250 props = "REMOVEOLDSNAPSHOT;REMOVEOLDVERSION"
251 # Installer collects the product codes of the earlier releases in
252 # these properties. In order to allow modification of the properties,
253 # they must be declared as secure. See "SecureCustomProperties Property"
254 add_data(db, "Property", [("SecureCustomProperties", props)])
256 class PyDialog(Dialog):
257 """Dialog class with a fixed layout: controls at the top, then a ruler,
258 then a list of buttons: back, next, cancel. Optionally a bitmap at the
259 left."""
260 def __init__(self, *args, **kw):
261 """Dialog(database, name, x, y, w, h, attributes, title, first,
262 default, cancel, bitmap=true)"""
263 Dialog.__init__(self, *args)
264 ruler = self.h - 36
265 bmwidth = 152*ruler/328
266 if kw.get("bitmap", True):
267 self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
268 self.line("BottomLine", 0, ruler, self.w, 0)
270 def title(self, title):
271 "Set the title text of the dialog at the top."
272 # name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
273 # text, in VerdanaBold10
274 self.text("Title", 135, 10, 220, 60, 0x30003,
275 r"{\VerdanaBold10}%s" % title)
277 def back(self, title, next, name = "Back", active = 1):
278 """Add a back button with a given title, the tab-next button,
279 its name in the Control table, possibly initially disabled.
281 Return the button, so that events can be associated"""
282 if active:
283 flags = 3 # Visible|Enabled
284 else:
285 flags = 1 # Visible
286 return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
288 def cancel(self, title, next, name = "Cancel", active = 1):
289 """Add a cancel button with a given title, the tab-next button,
290 its name in the Control table, possibly initially disabled.
292 Return the button, so that events can be associated"""
293 if active:
294 flags = 3 # Visible|Enabled
295 else:
296 flags = 1 # Visible
297 return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
299 def next(self, title, next, name = "Next", active = 1):
300 """Add a Next button with a given title, the tab-next button,
301 its name in the Control table, possibly initially disabled.
303 Return the button, so that events can be associated"""
304 if active:
305 flags = 3 # Visible|Enabled
306 else:
307 flags = 1 # Visible
308 return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
310 def xbutton(self, name, title, next, xpos):
311 """Add a button with a given title, the tab-next button,
312 its name in the Control table, giving its x position; the
313 y-position is aligned with the other buttons.
315 Return the button, so that events can be associated"""
316 return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
318 def add_ui(db):
319 x = y = 50
320 w = 370
321 h = 300
322 title = "[ProductName] Setup"
324 # see "Dialog Style Bits"
325 modal = 3 # visible | modal
326 modeless = 1 # visible
327 track_disk_space = 32
329 add_data(db, 'ActionText', uisample.ActionText)
330 add_data(db, 'UIText', uisample.UIText)
332 # Bitmaps
333 if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
334 raise "Run icons.mak in PC directory"
335 add_data(db, "Binary",
336 [("PythonWin", msilib.Binary(r"%s\PCbuild\installer.bmp" % srcdir)), # 152x328 pixels
337 ("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
339 add_data(db, "Icon",
340 [("python_icon.exe", msilib.Binary(srcdir+r"\PC\python_icon.exe"))])
342 # Scripts
343 # CheckDir sets TargetExists if TARGETDIR exists.
344 # UpdateEditIDLE sets the REGISTRY.tcl component into
345 # the installed/uninstalled state according to both the
346 # Extensions and TclTk features.
347 if os.system("nmake /nologo /c /f msisupport.mak") != 0:
348 raise "'nmake /f msisupport.mak' failed"
349 add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
350 # See "Custom Action Type 1"
351 if msilib.Win64:
352 CheckDir = "CheckDir"
353 UpdateEditIDLE = "UpdateEditIDLE"
354 else:
355 CheckDir = "_CheckDir@4"
356 UpdateEditIDLE = "_UpdateEditIDLE@4"
357 add_data(db, "CustomAction",
358 [("CheckDir", 1, "Script", CheckDir)])
359 if have_tcl:
360 add_data(db, "CustomAction",
361 [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)])
363 # UI customization properties
364 add_data(db, "Property",
365 # See "DefaultUIFont Property"
366 [("DefaultUIFont", "DlgFont8"),
367 # See "ErrorDialog Style Bit"
368 ("ErrorDialog", "ErrorDlg"),
369 ("Progress1", "Install"), # modified in maintenance type dlg
370 ("Progress2", "installs"),
371 ("MaintenanceForm_Action", "Repair")])
373 # Fonts, see "TextStyle Table"
374 add_data(db, "TextStyle",
375 [("DlgFont8", "Tahoma", 9, None, 0),
376 ("DlgFontBold8", "Tahoma", 8, None, 1), #bold
377 ("VerdanaBold10", "Verdana", 10, None, 1),
378 ("VerdanaRed9", "Verdana", 9, 255, 0),
381 compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x bad_coding|badsyntax|site-packages "[TARGETDIR]Lib"'
382 # See "CustomAction Table"
383 add_data(db, "CustomAction", [
384 # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
385 # See "Custom Action Type 51",
386 # "Custom Action Execution Scheduling Options"
387 ("InitialTargetDir", 307, "TARGETDIR",
388 "[WindowsVolume]Python%s%s" % (major, minor)),
389 ("SetDLLDirToTarget", 307, "DLLDIR", "[TARGETDIR]"),
390 ("SetDLLDirToSystem32", 307, "DLLDIR", SystemFolderName),
391 # msidbCustomActionTypeExe + msidbCustomActionTypeSourceFile
392 # See "Custom Action Type 18"
393 ("CompilePyc", 18, "python.exe", compileargs),
394 ("CompilePyo", 18, "python.exe", "-O "+compileargs),
397 # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
398 # Numbers indicate sequence; see sequence.py for how these action integrate
399 add_data(db, "InstallUISequence",
400 [("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
401 ("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
402 ("InitialTargetDir", 'TARGETDIR=""', 750),
403 # In the user interface, assume all-users installation if privileged.
404 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
405 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
406 ("SelectDirectoryDlg", "Not Installed", 1230),
407 # XXX no support for resume installations yet
408 #("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
409 ("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
410 ("ProgressDlg", None, 1280)])
411 add_data(db, "AdminUISequence",
412 [("InitialTargetDir", 'TARGETDIR=""', 750),
413 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
416 # Execute Sequences
417 add_data(db, "InstallExecuteSequence",
418 [("InitialTargetDir", 'TARGETDIR=""', 750),
419 ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
420 ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
421 ("UpdateEditIDLE", None, 1050),
422 ("CompilePyc", "COMPILEALL", 6800),
423 ("CompilePyo", "COMPILEALL", 6801),
425 add_data(db, "AdminExecuteSequence",
426 [("InitialTargetDir", 'TARGETDIR=""', 750),
427 ("SetDLLDirToTarget", 'DLLDIR=""', 751),
428 ("CompilePyc", "COMPILEALL", 6800),
429 ("CompilePyo", "COMPILEALL", 6801),
432 #####################################################################
433 # Standard dialogs: FatalError, UserExit, ExitDialog
434 fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
435 "Finish", "Finish", "Finish")
436 fatal.title("[ProductName] Installer ended prematurely")
437 fatal.back("< Back", "Finish", active = 0)
438 fatal.cancel("Cancel", "Back", active = 0)
439 fatal.text("Description1", 135, 70, 220, 80, 0x30003,
440 "[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.")
441 fatal.text("Description2", 135, 155, 220, 20, 0x30003,
442 "Click the Finish button to exit the Installer.")
443 c=fatal.next("Finish", "Cancel", name="Finish")
444 # See "ControlEvent Table". Parameters are the event, the parameter
445 # to the action, and optionally the condition for the event, and the order
446 # of events.
447 c.event("EndDialog", "Exit")
449 user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
450 "Finish", "Finish", "Finish")
451 user_exit.title("[ProductName] Installer was interrupted")
452 user_exit.back("< Back", "Finish", active = 0)
453 user_exit.cancel("Cancel", "Back", active = 0)
454 user_exit.text("Description1", 135, 70, 220, 80, 0x30003,
455 "[ProductName] setup was interrupted. Your system has not been modified. "
456 "To install this program at a later time, please run the installation again.")
457 user_exit.text("Description2", 135, 155, 220, 20, 0x30003,
458 "Click the Finish button to exit the Installer.")
459 c = user_exit.next("Finish", "Cancel", name="Finish")
460 c.event("EndDialog", "Exit")
462 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
463 "Finish", "Finish", "Finish")
464 exit_dialog.title("Completing the [ProductName] Installer")
465 exit_dialog.back("< Back", "Finish", active = 0)
466 exit_dialog.cancel("Cancel", "Back", active = 0)
467 exit_dialog.text("Acknowledgements", 135, 95, 220, 120, 0x30003,
468 "Special Windows thanks to:\n"
469 " Mark Hammond, without whose years of freely \n"
470 " shared Windows expertise, Python for Windows \n"
471 " would still be Python for DOS.")
473 c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003,
474 "{\\VerdanaRed9}Warning: Python 2.5.x is the last "
475 "Python release for Windows 9x.")
476 c.condition("Hide", "NOT Version9X")
478 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
479 "Click the Finish button to exit the Installer.")
480 c = exit_dialog.next("Finish", "Cancel", name="Finish")
481 c.event("EndDialog", "Return")
483 #####################################################################
484 # Required dialog: FilesInUse, ErrorDlg
485 inuse = PyDialog(db, "FilesInUse",
486 x, y, w, h,
487 19, # KeepModeless|Modal|Visible
488 title,
489 "Retry", "Retry", "Retry", bitmap=False)
490 inuse.text("Title", 15, 6, 200, 15, 0x30003,
491 r"{\DlgFontBold8}Files in Use")
492 inuse.text("Description", 20, 23, 280, 20, 0x30003,
493 "Some files that need to be updated are currently in use.")
494 inuse.text("Text", 20, 55, 330, 50, 3,
495 "The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.")
496 inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
497 None, None, None)
498 c=inuse.back("Exit", "Ignore", name="Exit")
499 c.event("EndDialog", "Exit")
500 c=inuse.next("Ignore", "Retry", name="Ignore")
501 c.event("EndDialog", "Ignore")
502 c=inuse.cancel("Retry", "Exit", name="Retry")
503 c.event("EndDialog","Retry")
506 # See "Error Dialog". See "ICE20" for the required names of the controls.
507 error = Dialog(db, "ErrorDlg",
508 50, 10, 330, 101,
509 65543, # Error|Minimize|Modal|Visible
510 title,
511 "ErrorText", None, None)
512 error.text("ErrorText", 50,9,280,48,3, "")
513 error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
514 error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
515 error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
516 error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
517 error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
518 error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
519 error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
520 error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
522 #####################################################################
523 # Global "Query Cancel" dialog
524 cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
525 "No", "No", "No")
526 cancel.text("Text", 48, 15, 194, 30, 3,
527 "Are you sure you want to cancel [ProductName] installation?")
528 cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
529 "py.ico", None, None)
530 c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
531 c.event("EndDialog", "Exit")
533 c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
534 c.event("EndDialog", "Return")
536 #####################################################################
537 # Global "Wait for costing" dialog
538 costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
539 "Return", "Return", "Return")
540 costing.text("Text", 48, 15, 194, 30, 3,
541 "Please wait while the installer finishes determining your disk space requirements.")
542 costing.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
543 "py.ico", None, None)
544 c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
545 c.event("EndDialog", "Exit")
547 #####################################################################
548 # Preparation dialog: no user input except cancellation
549 prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
550 "Cancel", "Cancel", "Cancel")
551 prep.text("Description", 135, 70, 220, 40, 0x30003,
552 "Please wait while the Installer prepares to guide you through the installation.")
553 prep.title("Welcome to the [ProductName] Installer")
554 c=prep.text("ActionText", 135, 110, 220, 20, 0x30003, "Pondering...")
555 c.mapping("ActionText", "Text")
556 c=prep.text("ActionData", 135, 135, 220, 30, 0x30003, None)
557 c.mapping("ActionData", "Text")
558 prep.back("Back", None, active=0)
559 prep.next("Next", None, active=0)
560 c=prep.cancel("Cancel", None)
561 c.event("SpawnDialog", "CancelDlg")
563 #####################################################################
564 # Target directory selection
565 seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title,
566 "Next", "Next", "Cancel")
567 seldlg.title("Select Destination Directory")
568 c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003,
569 "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.")
570 c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""')
571 seldlg.text("Description", 135, 50, 220, 40, 0x30003,
572 "Please select a directory for the [ProductName] files.")
574 seldlg.back("< Back", None, active=0)
575 c = seldlg.next("Next >", "Cancel")
576 c.event("DoAction", "CheckDir", "TargetExistsOk<>1", order=1)
577 # If the target exists, but we found that we are going to remove old versions, don't bother
578 # confirming that the target directory exists. Strictly speaking, we should determine that
579 # the target directory is indeed the target of the product that we are going to remove, but
580 # I don't know how to do that.
581 c.event("SpawnDialog", "ExistingDirectoryDlg", 'TargetExists=1 and REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""', 2)
582 c.event("SetTargetPath", "TARGETDIR", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 3)
583 c.event("SpawnWaitDialog", "WaitForCostingDlg", "CostingComplete=1", 4)
584 c.event("NewDialog", "SelectFeaturesDlg", 'TargetExists=0 or REMOVEOLDVERSION<>"" or REMOVEOLDSNAPSHOT<>""', 5)
586 c = seldlg.cancel("Cancel", "DirectoryCombo")
587 c.event("SpawnDialog", "CancelDlg")
589 seldlg.control("DirectoryCombo", "DirectoryCombo", 135, 70, 172, 80, 393219,
590 "TARGETDIR", None, "DirectoryList", None)
591 seldlg.control("DirectoryList", "DirectoryList", 135, 90, 208, 136, 3, "TARGETDIR",
592 None, "PathEdit", None)
593 seldlg.control("PathEdit", "PathEdit", 135, 230, 206, 16, 3, "TARGETDIR", None, "Next", None)
594 c = seldlg.pushbutton("Up", 306, 70, 18, 18, 3, "Up", None)
595 c.event("DirectoryListUp", "0")
596 c = seldlg.pushbutton("NewDir", 324, 70, 30, 18, 3, "New", None)
597 c.event("DirectoryListNew", "0")
599 #####################################################################
600 # SelectFeaturesDlg
601 features = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal|track_disk_space,
602 title, "Tree", "Next", "Cancel")
603 features.title("Customize [ProductName]")
604 features.text("Description", 135, 35, 220, 15, 0x30003,
605 "Select the way you want features to be installed.")
606 features.text("Text", 135,45,220,30, 3,
607 "Click on the icons in the tree below to change the way features will be installed.")
609 c=features.back("< Back", "Next")
610 c.event("NewDialog", "SelectDirectoryDlg")
612 c=features.next("Next >", "Cancel")
613 c.mapping("SelectionNoItems", "Enabled")
614 c.event("SpawnDialog", "DiskCostDlg", "OutOfDiskSpace=1", order=1)
615 c.event("EndDialog", "Return", "OutOfDiskSpace<>1", order=2)
617 c=features.cancel("Cancel", "Tree")
618 c.event("SpawnDialog", "CancelDlg")
620 # The browse property is not used, since we have only a single target path (selected already)
621 features.control("Tree", "SelectionTree", 135, 75, 220, 95, 7, "_BrowseProperty",
622 "Tree of selections", "Back", None)
624 #c=features.pushbutton("Reset", 42, 243, 56, 17, 3, "Reset", "DiskCost")
625 #c.mapping("SelectionNoItems", "Enabled")
626 #c.event("Reset", "0")
628 features.control("Box", "GroupBox", 135, 170, 225, 90, 1, None, None, None, None)
630 c=features.xbutton("DiskCost", "Disk &Usage", None, 0.10)
631 c.mapping("SelectionNoItems","Enabled")
632 c.event("SpawnDialog", "DiskCostDlg")
634 c=features.xbutton("Advanced", "Advanced", None, 0.30)
635 c.event("SpawnDialog", "AdvancedDlg")
637 c=features.text("ItemDescription", 140, 180, 210, 30, 3,
638 "Multiline description of the currently selected item.")
639 c.mapping("SelectionDescription","Text")
641 c=features.text("ItemSize", 140, 210, 210, 45, 3,
642 "The size of the currently selected item.")
643 c.mapping("SelectionSize", "Text")
645 #####################################################################
646 # Disk cost
647 cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
648 "OK", "OK", "OK", bitmap=False)
649 cost.text("Title", 15, 6, 200, 15, 0x30003,
650 "{\DlgFontBold8}Disk Space Requirements")
651 cost.text("Description", 20, 20, 280, 20, 0x30003,
652 "The disk space required for the installation of the selected features.")
653 cost.text("Text", 20, 53, 330, 60, 3,
654 "The highlighted volumes (if any) do not have enough disk space "
655 "available for the currently selected features. You can either "
656 "remove some files from the highlighted volumes, or choose to "
657 "install less features onto local drive(s), or select different "
658 "destination drive(s).")
659 cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
660 None, "{120}{70}{70}{70}{70}", None, None)
661 cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
663 #####################################################################
664 # WhichUsers Dialog. Only available on NT, and for privileged users.
665 # This must be run before FindRelatedProducts, because that will
666 # take into account whether the previous installation was per-user
667 # or per-machine. We currently don't support going back to this
668 # dialog after "Next" was selected; to support this, we would need to
669 # find how to reset the ALLUSERS property, and how to re-run
670 # FindRelatedProducts.
671 # On Windows9x, the ALLUSERS property is ignored on the command line
672 # and in the Property table, but installer fails according to the documentation
673 # if a dialog attempts to set ALLUSERS.
674 whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
675 "AdminInstall", "Next", "Cancel")
676 whichusers.title("Select whether to install [ProductName] for all users of this computer.")
677 # A radio group with two options: allusers, justme
678 g = whichusers.radiogroup("AdminInstall", 135, 60, 160, 50, 3,
679 "WhichUsers", "", "Next")
680 g.add("ALL", 0, 5, 150, 20, "Install for all users")
681 g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
683 whichusers.back("Back", None, active=0)
685 c = whichusers.next("Next >", "Cancel")
686 c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
687 c.event("EndDialog", "Return", order = 2)
689 c = whichusers.cancel("Cancel", "AdminInstall")
690 c.event("SpawnDialog", "CancelDlg")
692 #####################################################################
693 # Advanced Dialog.
694 advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
695 "CompilePyc", "Next", "Cancel")
696 advanced.title("Advanced Options for [ProductName]")
697 # A radio group with two options: allusers, justme
698 advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
699 "COMPILEALL", "Compile .py files to byte code after installation", "Next")
701 c = advanced.next("Finish", "Cancel")
702 c.event("EndDialog", "Return")
704 c = advanced.cancel("Cancel", "CompilePyc")
705 c.event("SpawnDialog", "CancelDlg")
707 #####################################################################
708 # Existing Directory dialog
709 dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
710 "No", "No", "No")
711 dlg.text("Title", 10, 20, 180, 40, 3,
712 "[TARGETDIR] exists. Are you sure you want to overwrite existing files?")
713 c=dlg.pushbutton("Yes", 30, 60, 55, 17, 3, "Yes", "No")
714 c.event("[TargetExists]", "0", order=1)
715 c.event("[TargetExistsOk]", "1", order=2)
716 c.event("EndDialog", "Return", order=3)
717 c=dlg.pushbutton("No", 115, 60, 55, 17, 3, "No", "Yes")
718 c.event("EndDialog", "Return")
720 #####################################################################
721 # Installation Progress dialog (modeless)
722 progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
723 "Cancel", "Cancel", "Cancel", bitmap=False)
724 progress.text("Title", 20, 15, 200, 15, 0x30003,
725 "{\DlgFontBold8}[Progress1] [ProductName]")
726 progress.text("Text", 35, 65, 300, 30, 3,
727 "Please wait while the Installer [Progress2] [ProductName]. "
728 "This may take several minutes.")
729 progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
731 c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
732 c.mapping("ActionText", "Text")
734 #c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
735 #c.mapping("ActionData", "Text")
737 c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
738 None, "Progress done", None, None)
739 c.mapping("SetProgress", "Progress")
741 progress.back("< Back", "Next", active=False)
742 progress.next("Next >", "Cancel", active=False)
743 progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
745 # Maintenance type: repair/uninstall
746 maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
747 "Next", "Next", "Cancel")
748 maint.title("Welcome to the [ProductName] Setup Wizard")
749 maint.text("BodyText", 135, 63, 230, 42, 3,
750 "Select whether you want to repair or remove [ProductName].")
751 g=maint.radiogroup("RepairRadioGroup", 135, 108, 230, 60, 3,
752 "MaintenanceForm_Action", "", "Next")
753 g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
754 g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
755 g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
757 maint.back("< Back", None, active=False)
758 c=maint.next("Finish", "Cancel")
759 # Change installation: Change progress dialog to "Change", then ask
760 # for feature selection
761 c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
762 c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
764 # Reinstall: Change progress dialog to "Repair", then invoke reinstall
765 # Also set list of reinstalled features to "ALL"
766 c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
767 c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
768 c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
769 c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
771 # Uninstall: Change progress to "Remove", then invoke uninstall
772 # Also set list of removed features to "ALL"
773 c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
774 c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
775 c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
776 c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
778 # Close dialog when maintenance action scheduled
779 c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
780 c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
782 maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
785 # See "Feature Table". The feature level is 1 for all features,
786 # and the feature attributes are 0 for the DefaultFeature, and
787 # FollowParent for all other features. The numbers are the Display
788 # column.
789 def add_features(db):
790 # feature attributes:
791 # msidbFeatureAttributesFollowParent == 2
792 # msidbFeatureAttributesDisallowAdvertise == 8
793 # Features that need to be installed with together with the main feature
794 # (i.e. additional Python libraries) need to follow the parent feature.
795 # Features that have no advertisement trigger (e.g. the test suite)
796 # must not support advertisement
797 global default_feature, tcltk, htmlfiles, tools, testsuite, ext_feature
798 default_feature = Feature(db, "DefaultFeature", "Python",
799 "Python Interpreter and Libraries",
800 1, directory = "TARGETDIR")
801 # We don't support advertisement of extensions
802 ext_feature = Feature(db, "Extensions", "Register Extensions",
803 "Make this Python installation the default Python installation", 3,
804 parent = default_feature, attributes=2|8)
805 if have_tcl:
806 tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
807 parent = default_feature, attributes=2)
808 htmlfiles = Feature(db, "Documentation", "Documentation",
809 "Python HTMLHelp File", 7, parent = default_feature)
810 tools = Feature(db, "Tools", "Utility Scripts",
811 "Python utility scripts (Tools/", 9,
812 parent = default_feature, attributes=2)
813 testsuite = Feature(db, "Testsuite", "Test suite",
814 "Python test suite (Lib/test/)", 11,
815 parent = default_feature, attributes=2|8)
817 def extract_msvcr71():
818 import _winreg
819 # Find the location of the merge modules
820 k = _winreg.OpenKey(
821 _winreg.HKEY_LOCAL_MACHINE,
822 r"Software\Microsoft\VisualStudio\7.1\Setup\VS")
823 dir = _winreg.QueryValueEx(k, "MSMDir")[0]
824 _winreg.CloseKey(k)
825 files = glob.glob1(dir, "*CRT71*")
826 assert len(files) == 1, (dir, files)
827 file = os.path.join(dir, files[0])
828 # Extract msvcr71.dll
829 m = msilib.MakeMerge2()
830 m.OpenModule(file, 0)
831 m.ExtractFiles(".")
832 m.CloseModule()
833 # Find the version/language of msvcr71.dll
834 installer = msilib.MakeInstaller()
835 return installer.FileVersion("msvcr71.dll", 0), \
836 installer.FileVersion("msvcr71.dll", 1)
838 def extract_msvcr90():
839 # Find the redistributable files
840 dir = os.path.join(os.environ['VS90COMNTOOLS'], r"..\..\VC\redist\x86\Microsoft.VC90.CRT")
842 result = []
843 installer = msilib.MakeInstaller()
844 # omit msvcm90 and msvcp90, as they aren't really needed
845 files = ["Microsoft.VC90.CRT.manifest", "msvcr90.dll"]
846 for f in files:
847 path = os.path.join(dir, f)
848 kw = {'src':path}
849 if f.endswith('.dll'):
850 kw['version'] = installer.FileVersion(path, 0)
851 kw['language'] = installer.FileVersion(path, 1)
852 result.append((f, kw))
853 return result
855 class PyDirectory(Directory):
856 """By default, all components in the Python installer
857 can run from source."""
858 def __init__(self, *args, **kw):
859 if not kw.has_key("componentflags"):
860 kw['componentflags'] = 2 #msidbComponentAttributesOptional
861 Directory.__init__(self, *args, **kw)
863 # See "File Table", "Component Table", "Directory Table",
864 # "FeatureComponents Table"
865 def add_files(db):
866 cab = CAB("python")
867 tmpfiles = []
868 # Add all executables, icons, text files into the TARGETDIR component
869 root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
870 default_feature.set_current()
871 if not msilib.Win64:
872 root.add_file("%s/w9xpopen.exe" % PCBUILD)
873 root.add_file("README.txt", src="README")
874 root.add_file("NEWS.txt", src="Misc/NEWS")
875 root.add_file("LICENSE.txt", src="LICENSE")
876 root.start_component("python.exe", keyfile="python.exe")
877 root.add_file("%s/python.exe" % PCBUILD)
878 root.start_component("pythonw.exe", keyfile="pythonw.exe")
879 root.add_file("%s/pythonw.exe" % PCBUILD)
881 # msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
882 #dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
883 #install python30.dll into root dir for now
884 dlldir = root
886 pydll = "python%s%s.dll" % (major, minor)
887 pydllsrc = os.path.join(srcdir, PCBUILD, pydll)
888 dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid)
889 installer = msilib.MakeInstaller()
890 pyversion = installer.FileVersion(pydllsrc, 0)
891 if not snapshot:
892 # For releases, the Python DLL has the same version as the
893 # installer package.
894 assert pyversion.split(".")[:3] == current_version.split(".")
895 dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor),
896 version=pyversion,
897 language=installer.FileVersion(pydllsrc, 1))
898 DLLs = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
899 # XXX determine dependencies
900 if MSVCR == "90":
901 root.start_component("msvcr90")
902 for file, kw in extract_msvcr90():
903 root.add_file(file, **kw)
904 if file.endswith("manifest"):
905 DLLs.add_file(file, **kw)
906 else:
907 version, lang = extract_msvcr71()
908 dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll",
909 uuid=msvcr71_uuid)
910 dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
911 version=version, language=lang)
912 tmpfiles.append("msvcr71.dll")
915 # Check if _ctypes.pyd exists
916 have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
917 if not have_ctypes:
918 print "WARNING: _ctypes.pyd not found, ctypes will not be included"
919 extensions.remove("_ctypes.pyd")
921 # Add all .py files in Lib, except lib-tk, test
922 dirs={}
923 pydirs = [(root,"Lib")]
924 while pydirs:
925 parent, dir = pydirs.pop()
926 if dir == ".svn" or dir.startswith("plat-"):
927 continue
928 elif dir in ["lib-tk", "idlelib", "Icons"]:
929 if not have_tcl:
930 continue
931 tcltk.set_current()
932 elif dir in ['test', 'tests', 'data', 'output']:
933 # test: Lib, Lib/email, Lib/bsddb, Lib/ctypes, Lib/sqlite3
934 # tests: Lib/distutils
935 # data: Lib/email/test
936 # output: Lib/test
937 testsuite.set_current()
938 elif not have_ctypes and dir == "ctypes":
939 continue
940 else:
941 default_feature.set_current()
942 lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir))
943 # Add additional files
944 dirs[dir]=lib
945 lib.glob("*.txt")
946 if dir=='site-packages':
947 lib.add_file("README.txt", src="README")
948 continue
949 files = lib.glob("*.py")
950 files += lib.glob("*.pyw")
951 if files:
952 # Add an entry to the RemoveFile table to remove bytecode files.
953 lib.remove_pyc()
954 if dir.endswith('.egg-info'):
955 lib.add_file('entry_points.txt')
956 lib.add_file('PKG-INFO')
957 lib.add_file('top_level.txt')
958 lib.add_file('zip-safe')
959 continue
960 if dir=='test' and parent.physical=='Lib':
961 lib.add_file("185test.db")
962 lib.add_file("audiotest.au")
963 lib.add_file("cfgparser.1")
964 lib.add_file("sgml_input.html")
965 lib.add_file("test.xml")
966 lib.add_file("test.xml.out")
967 lib.add_file("testtar.tar")
968 lib.add_file("test_difflib_expect.html")
969 lib.add_file("check_soundcard.vbs")
970 lib.add_file("empty.vbs")
971 lib.glob("*.uue")
972 lib.glob("*.pem")
973 lib.glob("*.pck")
974 lib.add_file("readme.txt", src="README")
975 if dir=='decimaltestdata':
976 lib.glob("*.decTest")
977 if dir=='output':
978 lib.glob("test_*")
979 if dir=='idlelib':
980 lib.glob("*.def")
981 lib.add_file("idle.bat")
982 if dir=="Icons":
983 lib.glob("*.gif")
984 lib.add_file("idle.icns")
985 if dir=="command" and parent.physical=="distutils":
986 lib.add_file("wininst-6.0.exe")
987 lib.add_file("wininst-7.1.exe")
988 lib.add_file("wininst-8.0.exe")
989 lib.add_file("wininst-9.0.exe")
990 if dir=="setuptools":
991 lib.add_file("cli.exe")
992 lib.add_file("gui.exe")
993 if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
994 # This should contain all non-.svn files listed in subversion
995 for f in os.listdir(lib.absolute):
996 if f.endswith(".txt") or f==".svn":continue
997 if f.endswith(".au") or f.endswith(".gif"):
998 lib.add_file(f)
999 else:
1000 print "WARNING: New file %s in email/test/data" % f
1001 for f in os.listdir(lib.absolute):
1002 if os.path.isdir(os.path.join(lib.absolute, f)):
1003 pydirs.append((lib, f))
1004 # Add DLLs
1005 default_feature.set_current()
1006 lib = DLLs
1007 lib.add_file("py.ico", src=srcdir+"/PC/py.ico")
1008 lib.add_file("pyc.ico", src=srcdir+"/PC/pyc.ico")
1009 dlls = []
1010 tclfiles = []
1011 for f in extensions:
1012 if f=="_tkinter.pyd":
1013 continue
1014 if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
1015 print "WARNING: Missing extension", f
1016 continue
1017 dlls.append(f)
1018 lib.add_file(f)
1019 # Add sqlite
1020 if msilib.msi_type=="Intel64;1033":
1021 sqlite_arch = "/ia64"
1022 elif msilib.msi_type=="x64;1033":
1023 sqlite_arch = "/amd64"
1024 tclsuffix = "64"
1025 else:
1026 sqlite_arch = ""
1027 tclsuffix = ""
1028 lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
1029 if have_tcl:
1030 if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
1031 print "WARNING: Missing _tkinter.pyd"
1032 else:
1033 lib.start_component("TkDLLs", tcltk)
1034 lib.add_file("_tkinter.pyd")
1035 dlls.append("_tkinter.pyd")
1036 tcldir = os.path.normpath(srcdir+("/../tcltk%s/bin" % tclsuffix))
1037 for f in glob.glob1(tcldir, "*.dll"):
1038 lib.add_file(f, src=os.path.join(tcldir, f))
1039 # check whether there are any unknown extensions
1040 for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
1041 if f.endswith("_d.pyd"): continue # debug version
1042 if f in dlls: continue
1043 print "WARNING: Unknown extension", f
1045 # Add headers
1046 default_feature.set_current()
1047 lib = PyDirectory(db, cab, root, "include", "include", "INCLUDE|include")
1048 lib.glob("*.h")
1049 lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
1050 # Add import libraries
1051 lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
1052 for f in dlls:
1053 lib.add_file(f.replace('pyd','lib'))
1054 lib.add_file('python%s%s.lib' % (major, minor))
1055 # Add the mingw-format library
1056 if have_mingw:
1057 lib.add_file('libpython%s%s.a' % (major, minor))
1058 if have_tcl:
1059 # Add Tcl/Tk
1060 tcldirs = [(root, '../tcltk%s/lib' % tclsuffix, 'tcl')]
1061 tcltk.set_current()
1062 while tcldirs:
1063 parent, phys, dir = tcldirs.pop()
1064 lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
1065 if not os.path.exists(lib.absolute):
1066 continue
1067 for f in os.listdir(lib.absolute):
1068 if os.path.isdir(os.path.join(lib.absolute, f)):
1069 tcldirs.append((lib, f, f))
1070 else:
1071 lib.add_file(f)
1072 # Add tools
1073 tools.set_current()
1074 tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
1075 for f in ['i18n', 'pynche', 'Scripts', 'versioncheck', 'webchecker']:
1076 lib = PyDirectory(db, cab, tooldir, f, f, "%s|%s" % (tooldir.make_short(f), f))
1077 lib.glob("*.py")
1078 lib.glob("*.pyw", exclude=['pydocgui.pyw'])
1079 lib.remove_pyc()
1080 lib.glob("*.txt")
1081 if f == "pynche":
1082 x = PyDirectory(db, cab, lib, "X", "X", "X|X")
1083 x.glob("*.txt")
1084 if os.path.exists(os.path.join(lib.absolute, "README")):
1085 lib.add_file("README.txt", src="README")
1086 if f == 'Scripts':
1087 if have_tcl:
1088 lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
1089 lib.add_file("pydocgui.pyw")
1090 # Add documentation
1091 htmlfiles.set_current()
1092 lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
1093 lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
1094 lib.add_file("Python%s%s.chm" % (major, minor), src="build/htmlhelp/pydoc.chm")
1096 cab.commit(db)
1098 for f in tmpfiles:
1099 os.unlink(f)
1101 # See "Registry Table", "Component Table"
1102 def add_registry(db):
1103 # File extensions, associated with the REGISTRY.def component
1104 # IDLE verbs depend on the tcltk feature.
1105 # msidbComponentAttributesRegistryKeyPath = 4
1106 # -1 for Root specifies "dependent on ALLUSERS property"
1107 tcldata = []
1108 if have_tcl:
1109 tcldata = [
1110 ("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
1111 "py.IDLE")]
1112 add_data(db, "Component",
1113 # msidbComponentAttributesRegistryKeyPath = 4
1114 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
1115 "InstallPath"),
1116 ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", registry_component, None,
1117 "Documentation"),
1118 ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", registry_component,
1119 None, None)] + tcldata)
1120 # See "FeatureComponents Table".
1121 # The association between TclTk and pythonw.exe is necessary to make ICE59
1122 # happy, because the installer otherwise believes that the IDLE and PyDoc
1123 # shortcuts might get installed without pythonw.exe being install. This
1124 # is not true, since installing TclTk will install the default feature, which
1125 # will cause pythonw.exe to be installed.
1126 # REGISTRY.tcl is not associated with any feature, as it will be requested
1127 # through a custom action
1128 tcldata = []
1129 if have_tcl:
1130 tcldata = [(tcltk.id, "pythonw.exe")]
1131 add_data(db, "FeatureComponents",
1132 [(default_feature.id, "REGISTRY"),
1133 (htmlfiles.id, "REGISTRY.doc"),
1134 (ext_feature.id, "REGISTRY.def")] +
1135 tcldata
1137 # Extensions are not advertised. For advertised extensions,
1138 # we would need separate binaries that install along with the
1139 # extension.
1140 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
1141 ewi = "Edit with IDLE"
1142 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
1143 pat3 = r"Software\Classes\%sPython.%sFile"
1144 tcl_verbs = []
1145 if have_tcl:
1146 tcl_verbs=[
1147 ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
1148 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1149 "REGISTRY.tcl"),
1150 ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
1151 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
1152 "REGISTRY.tcl"),
1154 add_data(db, "Registry",
1155 [# Extensions
1156 ("py.ext", -1, r"Software\Classes\."+ext, "",
1157 "Python.File", "REGISTRY.def"),
1158 ("pyw.ext", -1, r"Software\Classes\."+ext+'w', "",
1159 "Python.NoConFile", "REGISTRY.def"),
1160 ("pyc.ext", -1, r"Software\Classes\."+ext+'c', "",
1161 "Python.CompiledFile", "REGISTRY.def"),
1162 ("pyo.ext", -1, r"Software\Classes\."+ext+'o', "",
1163 "Python.CompiledFile", "REGISTRY.def"),
1164 # MIME types
1165 ("py.mime", -1, r"Software\Classes\."+ext, "Content Type",
1166 "text/plain", "REGISTRY.def"),
1167 ("pyw.mime", -1, r"Software\Classes\."+ext+'w', "Content Type",
1168 "text/plain", "REGISTRY.def"),
1169 #Verbs
1170 ("py.open", -1, pat % (testprefix, "", "open"), "",
1171 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1172 ("pyw.open", -1, pat % (testprefix, "NoCon", "open"), "",
1173 r'"[TARGETDIR]pythonw.exe" "%1" %*', "REGISTRY.def"),
1174 ("pyc.open", -1, pat % (testprefix, "Compiled", "open"), "",
1175 r'"[TARGETDIR]python.exe" "%1" %*', "REGISTRY.def"),
1176 ] + tcl_verbs + [
1177 #Icons
1178 ("py.icon", -1, pat2 % (testprefix, ""), "",
1179 r'[DLLs]py.ico', "REGISTRY.def"),
1180 ("pyw.icon", -1, pat2 % (testprefix, "NoCon"), "",
1181 r'[DLLs]py.ico', "REGISTRY.def"),
1182 ("pyc.icon", -1, pat2 % (testprefix, "Compiled"), "",
1183 r'[DLLs]pyc.ico', "REGISTRY.def"),
1184 # Descriptions
1185 ("py.txt", -1, pat3 % (testprefix, ""), "",
1186 "Python File", "REGISTRY.def"),
1187 ("pyw.txt", -1, pat3 % (testprefix, "NoCon"), "",
1188 "Python File (no console)", "REGISTRY.def"),
1189 ("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
1190 "Compiled Python File", "REGISTRY.def"),
1193 # Registry keys
1194 prefix = r"Software\%sPython\PythonCore\%s" % (testprefix, short_version)
1195 add_data(db, "Registry",
1196 [("InstallPath", -1, prefix+r"\InstallPath", "", "[TARGETDIR]", "REGISTRY"),
1197 ("InstallGroup", -1, prefix+r"\InstallPath\InstallGroup", "",
1198 "Python %s" % short_version, "REGISTRY"),
1199 ("PythonPath", -1, prefix+r"\PythonPath", "",
1200 r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
1201 ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
1202 r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"),
1203 ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
1204 ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
1205 "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
1207 # Shortcuts, see "Shortcut Table"
1208 add_data(db, "Directory",
1209 [("ProgramMenuFolder", "TARGETDIR", "."),
1210 ("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
1211 add_data(db, "RemoveFile",
1212 [("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
1213 tcltkshortcuts = []
1214 if have_tcl:
1215 tcltkshortcuts = [
1216 ("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
1217 tcltk.id, r'"[TARGETDIR]Lib\idlelib\idle.pyw"', None, None, "python_icon.exe", 0, None, "TARGETDIR"),
1218 ("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
1219 tcltk.id, r'"[TARGETDIR]Tools\scripts\pydocgui.pyw"', None, None, "python_icon.exe", 0, None, "TARGETDIR"),
1221 add_data(db, "Shortcut",
1222 tcltkshortcuts +
1223 [# Advertised shortcuts: targets are features, not files
1224 ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
1225 default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
1226 # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an
1227 # icon first.
1228 #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",
1229 # htmlfiles.id, None, None, None, None, None, None, None),
1230 ## Non-advertised shortcuts: must be associated with a registry component
1231 ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
1232 "[#Python%s%s.chm]" % (major,minor), None,
1233 None, None, None, None, None, None),
1234 ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
1235 SystemFolderName+"msiexec", "/x%s" % product_code,
1236 None, None, None, None, None, None),
1238 db.Commit()
1240 db = build_database()
1241 try:
1242 add_features(db)
1243 add_ui(db)
1244 add_files(db)
1245 add_registry(db)
1246 remove_old_versions(db)
1247 db.Commit()
1248 finally:
1249 del db