Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0f780d

Browse files
committed
Conditionalize Tcl feature
1 parent e47c381 commit e0f780d

1 file changed

Lines changed: 57 additions & 35 deletions

File tree

Tools/msi/msi.py

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
# goes into file name and ProductCode. Defaults to
2323
# current_version.day for Snapshot, current_version otherwise
2424
full_current_version = None
25+
# Is Tcl available at all?
26+
have_tcl = True
2527

2628
try:
2729
from config import *
@@ -762,7 +764,8 @@ def add_features(db):
762764
ext_feature = Feature(db, "Extensions", "Register Extensions",
763765
"Make this Python installation the default Python installation", 3,
764766
parent = default_feature)
765-
tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
767+
if have_tcl:
768+
tcltk = Feature(db, "TclTk", "Tcl/Tk", "Tkinter, IDLE, pydoc", 5,
766769
parent = default_feature, attributes=2)
767770
htmlfiles = Feature(db, "Documentation", "Documentation",
768771
"Python HTMLHelp File", 7, parent = default_feature)
@@ -811,7 +814,8 @@ def add_files(db):
811814
# Add all executables, icons, text files into the TARGETDIR component
812815
root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
813816
default_feature.set_current()
814-
root.add_file("PCBuild/w9xpopen.exe")
817+
if not msilib.Win64:
818+
root.add_file("PCBuild/w9xpopen.exe")
815819
root.add_file("PC/py.ico")
816820
root.add_file("PC/pyc.ico")
817821
root.add_file("README.txt", src="README")
@@ -851,6 +855,8 @@ def add_files(db):
851855
if dir == "CVS" or dir.startswith("plat-"):
852856
continue
853857
elif dir in ["lib-tk", "idlelib", "Icons"]:
858+
if not have_tcl:
859+
continue
854860
tcltk.set_current()
855861
elif dir in ['test', 'output']:
856862
testsuite.set_current()
@@ -913,15 +919,16 @@ def add_files(db):
913919
continue
914920
dlls.append(f)
915921
lib.add_file(f)
916-
if not os.path.exists(srcdir+"/PCBuild/_tkinter.pyd"):
917-
print "WARNING: Missing _tkinter.pyd"
918-
else:
919-
lib.start_component("TkDLLs", tcltk)
920-
lib.add_file("_tkinter.pyd")
921-
dlls.append("_tkinter.pyd")
922-
tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
923-
for f in glob.glob1(tcldir, "*.dll"):
924-
lib.add_file(f, src=os.path.join(tcldir, f))
922+
if have_tcl:
923+
if not os.path.exists(srcdir+"/PCBuild/_tkinter.pyd"):
924+
print "WARNING: Missing _tkinter.pyd"
925+
else:
926+
lib.start_component("TkDLLs", tcltk)
927+
lib.add_file("_tkinter.pyd")
928+
dlls.append("_tkinter.pyd")
929+
tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
930+
for f in glob.glob1(tcldir, "*.dll"):
931+
lib.add_file(f, src=os.path.join(tcldir, f))
925932
# check whether there are any unknown extensions
926933
for f in glob.glob1(srcdir+"/PCBuild", "*.pyd"):
927934
if f.endswith("_d.pyd"): continue # debug version
@@ -938,19 +945,20 @@ def add_files(db):
938945
for f in dlls:
939946
lib.add_file(f.replace('pyd','lib'))
940947
lib.add_file('python%s%s.lib' % (major, minor))
941-
# Add Tcl/Tk
942-
tcldirs = [(root, '../tcltk/lib', 'tcl')]
943-
tcltk.set_current()
944-
while tcldirs:
945-
parent, phys, dir = tcldirs.pop()
946-
lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
947-
if not os.path.exists(lib.absolute):
948-
continue
949-
for f in os.listdir(lib.absolute):
950-
if os.path.isdir(os.path.join(lib.absolute, f)):
951-
tcldirs.append((lib, f, f))
952-
else:
953-
lib.add_file(f)
948+
if have_tcl:
949+
# Add Tcl/Tk
950+
tcldirs = [(root, '../tcltk/lib', 'tcl')]
951+
tcltk.set_current()
952+
while tcldirs:
953+
parent, phys, dir = tcldirs.pop()
954+
lib = PyDirectory(db, cab, parent, phys, dir, "%s|%s" % (parent.make_short(dir), dir))
955+
if not os.path.exists(lib.absolute):
956+
continue
957+
for f in os.listdir(lib.absolute):
958+
if os.path.isdir(os.path.join(lib.absolute, f)):
959+
tcldirs.append((lib, f, f))
960+
else:
961+
lib.add_file(f)
954962
# Add tools
955963
tools.set_current()
956964
tooldir = PyDirectory(db, cab, root, "Tools", "Tools", "TOOLS|Tools")
@@ -965,8 +973,9 @@ def add_files(db):
965973
x.glob("*.txt")
966974
if f == 'Scripts':
967975
lib.add_file("README.txt", src="README")
968-
lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
969-
lib.add_file("pydocgui.pyw")
976+
if have_tcl:
977+
lib.start_component("pydocgui.pyw", tcltk, keyfile="pydocgui.pyw")
978+
lib.add_file("pydocgui.pyw")
970979
# Add documentation
971980
htmlfiles.set_current()
972981
lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
@@ -984,25 +993,32 @@ def add_registry(db):
984993
# IDLE verbs depend on the tcltk feature.
985994
# msidbComponentAttributesRegistryKeyPath = 4
986995
# -1 for Root specifies "dependent on ALLUSERS property"
996+
tcldata = []
997+
if have_tcl:
998+
tcldata = [
999+
("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4,
1000+
"&%s <> 2" % ext_feature.id, "py.IDLE")]
9871001
add_data(db, "Component",
9881002
# msidbComponentAttributesRegistryKeyPath = 4
9891003
[("REGISTRY", msilib.gen_uuid(), "TARGETDIR", 4, None,
9901004
"InstallPath"),
9911005
("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", 4,
992-
None, None),
993-
("REGISTRY.tcl", msilib.gen_uuid(), "TARGETDIR", 4,
994-
"&%s <> 2" % ext_feature.id, "py.IDLE")])
1006+
None, None)] + tcldata)
9951007
# See "FeatureComponents Table".
9961008
# The association between TclTk and pythonw.exe is necessary to make ICE59
9971009
# happy, because the installer otherwise believes that the IDLE and PyDoc
9981010
# shortcuts might get installed without pythonw.exe being install. This
9991011
# is not true, since installing TclTk will install the default feature, which
10001012
# will cause pythonw.exe to be installed.
1013+
tcldata = []
1014+
if have_tcl:
1015+
tcltkdata = [(tcltk.id, "REGISTRY.tcl"),
1016+
(tcltk.id, "pythonw.exe")]
10011017
add_data(db, "FeatureComponents",
10021018
[(default_feature.id, "REGISTRY"),
1003-
(ext_feature.id, "REGISTRY.def"),
1004-
(tcltk.id, "REGISTRY.tcl"),
1005-
(tcltk.id, "pythonw.exe")])
1019+
(ext_feature.id, "REGISTRY.def")] +
1020+
tcldata
1021+
)
10061022

10071023
pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
10081024
ewi = "Edit with IDLE"
@@ -1028,7 +1044,8 @@ def add_registry(db):
10281044
# Non-advertised verbs: for advertised verbs, we would need to invoke the same
10291045
# executable for both open and "Edit with IDLE". This cannot work, as we want
10301046
# to use pythonw.exe in either case
1031-
add_data(db, "Registry",
1047+
if have_tcl:
1048+
add_data(db, "Registry",
10321049
[#Verbs
10331050
("py.IDLE", -1, pat % (testprefix, "", ewi), "",
10341051
r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
@@ -1058,12 +1075,17 @@ def add_registry(db):
10581075
("MenuDir", "ProgramMenuFolder", "PY%s%s|%sPython %s.%s" % (major,minor,testprefix,major,minor))])
10591076
add_data(db, "RemoveFile",
10601077
[("MenuDir", "TARGETDIR", None, "MenuDir", 2)])
1061-
add_data(db, "Shortcut",
1062-
[# Advertised shortcuts: targets are features, not files
1078+
tcltkshortcuts = []
1079+
if have_tcl:
1080+
tcltkshortcuts = [
10631081
("IDLE", "MenuDir", "IDLE|IDLE (Python GUI)", "pythonw.exe",
10641082
tcltk.id, r"[TARGETDIR]Lib\idlelib\idle.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"),
10651083
("PyDoc", "MenuDir", "MODDOCS|Module Docs", "pythonw.exe",
10661084
tcltk.id, r"[TARGETDIR]Tools\scripts\pydocgui.pyw", None, None, "python_icon.exe", 0, None, "TARGETDIR"),
1085+
]
1086+
add_data(db, "Shortcut",
1087+
tcltkshortcuts +
1088+
[# Advertised shortcuts: targets are features, not files
10671089
("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe",
10681090
default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"),
10691091
("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation",

0 commit comments

Comments
 (0)