@@ -291,6 +291,10 @@ def add_ui(db):
291291 [("python_icon.exe" , msilib .Binary (srcdir + r"\PC\python_icon.exe" ))])
292292
293293 # Scripts
294+ # 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.
294298 open ("inst.vbs" ,"w" ).write ("""
295299 Function CheckDir()
296300 Set FSO = CreateObject("Scripting.FileSystemObject")
@@ -300,10 +304,34 @@ def add_ui(db):
300304 Session.Property("TargetExists") = "0"
301305 end if
302306 End Function
307+ 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
303325 """ )
326+ # 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
304330 add_data (db , "Binary" , [("Script" , msilib .Binary ("inst.vbs" ))])
305331 # See "Custom Action Type 6"
306- add_data (db , "CustomAction" , [("CheckDir" , 6 , "Script" , "CheckDir" )])
332+ add_data (db , "CustomAction" ,
333+ [("CheckDir" , 6 , "Script" , "CheckDir" ),
334+ ("UpdateEditIDLE" , 6 , "Script" , "UpdateEditIDLE" )])
307335 os .unlink ("inst.vbs" )
308336
309337
@@ -363,6 +391,7 @@ def add_ui(db):
363391 [("InitialTargetDir" , 'TARGETDIR=""' , 750 ),
364392 ("SetDLLDirToSystem32" , 'DLLDIR="" and ' + sys32cond , 751 ),
365393 ("SetDLLDirToTarget" , 'DLLDIR="" and not ' + sys32cond , 752 ),
394+ ("UpdateEditIDLE" , None , 1050 ),
366395 ("CompilePyc" , "COMPILEALL" , 6800 ),
367396 ("CompilePyo" , "COMPILEALL" , 6801 ),
368397 ])
@@ -738,19 +767,10 @@ def add_features(db):
738767 default_feature = Feature (db , "DefaultFeature" , "Python" ,
739768 "Python Interpreter and Libraries" ,
740769 1 , directory = "TARGETDIR" )
741- # The extensions feature is tricky wrt. advertisement and follow parent.
742- # The following combinations must be supported:
743- # default feature extensions effect on extensions
744- # locally/from source locally/from source registered
745- # advertised advertised/locally/from source advertised
746- # locally/from source not installed not installed
747- # advertised not installed not advertised
748- # (only shortcuts are)
749- # The following combination might be considered meaningless, but cannot be excluded
750- # locally/from source advertised registered
770+ # We don't support advertisement of extensions
751771 ext_feature = Feature (db , "Extensions" , "Register Extensions" ,
752772 "Make this Python installation the default Python installation" , 3 ,
753- parent = default_feature )
773+ parent = default_feature , attributes = 2 | 8 )
754774 if have_tcl :
755775 tcltk = Feature (db , "TclTk" , "Tcl/Tk" , "Tkinter, IDLE, pydoc" , 5 ,
756776 parent = default_feature , attributes = 2 )
@@ -763,7 +783,6 @@ def add_features(db):
763783 "Python test suite (Lib/test/)" , 11 ,
764784 parent = default_feature , attributes = 2 | 8 )
765785
766-
767786def extract_msvcr71 ():
768787 import _winreg
769788 # Find the location of the merge modules
@@ -988,9 +1007,8 @@ def add_registry(db):
9881007 tcldata = []
9891008 if have_tcl :
9901009 tcldata = [
991- ("REGISTRY.tcl" , msilib .gen_uuid (), "TARGETDIR" , 4 ,
992- "&%s <> 2" % ext_feature .id ,
993- "py.IDLE" )]
1010+ ("REGISTRY.tcl" , msilib .gen_uuid (), "TARGETDIR" , 4 , None ,
1011+ "py.IDLE" )]
9941012 add_data (db , "Component" ,
9951013 # msidbComponentAttributesRegistryKeyPath = 4
9961014 [("REGISTRY" , msilib .gen_uuid (), "TARGETDIR" , 4 , None ,
@@ -1003,49 +1021,65 @@ def add_registry(db):
10031021 # shortcuts might get installed without pythonw.exe being install. This
10041022 # is not true, since installing TclTk will install the default feature, which
10051023 # will cause pythonw.exe to be installed.
1024+ # REGISTRY.tcl is not associated with any feature, as it will be requested
1025+ # through a custom action
10061026 tcldata = []
10071027 if have_tcl :
1008- tcldata = [(tcltk .id , "REGISTRY.tcl" ),
1009- (tcltk .id , "pythonw.exe" )]
1028+ tcldata = [(tcltk .id , "pythonw.exe" )]
10101029 add_data (db , "FeatureComponents" ,
10111030 [(default_feature .id , "REGISTRY" ),
10121031 (ext_feature .id , "REGISTRY.def" )] +
10131032 tcldata
10141033 )
1015-
1034+ # Extensions are not advertised. For advertised extensions,
1035+ # we would need separate binaries that install along with the
1036+ # extension.
10161037 pat = r"Software\Classes\%sPython.%sFile\shell\%s\command"
10171038 ewi = "Edit with IDLE"
10181039 pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
10191040 pat3 = r"Software\Classes\%sPython.%sFile"
1020- # Advertised extensions
1021- add_data (db , "Extension" ,
1022- [("py" , "extpy.exe" , "Python.File" , None , ext_feature .id ),
1023- ("pyw" , "extpyw.exe" , "Python.NoConFile" , None , ext_feature .id ),
1024- ("pyc" , "extpy.exe" , "Python.CompiledFile" , None , ext_feature .id ),
1025- ("pyo" , "extpy.exe" , "Python.CompiledFile" , None , ext_feature .id )])
1026- # add_data(db, "MIME") XXX
1027- add_data (db , "Verb" ,
1028- [("py" , "open" , 1 , None , r'"%1"' ),
1029- ("pyw" , "open" , 1 , None , r'"%1"' ),
1030- ("pyc" , "open" , 1 , None , r'"%1"' ),
1031- ("pyo" , "open" , 1 , None , r'"%1"' )])
1032- add_data (db , "ProgId" ,
1033- [("Python.File" , None , None , "Python File" , "python_icon.exe" , 0 ),
1034- ("Python.NoConFile" , None , None , "Python File (no console)" , "python_icon.exe" , 0 ),
1035- ("Python.CompiledFile" , None , None , "Compiled Python File" , "python_icon.exe" , 1 )])
1036-
1037- # Non-advertised verbs: for advertised verbs, we would need to invoke the same
1038- # executable for both open and "Edit with IDLE". This cannot work, as we want
1039- # to use pythonw.exe in either case
1040- if have_tcl :
1041- add_data (db , "Registry" ,
1042- [#Verbs
1041+ 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" ),
10431063 ("py.IDLE" , - 1 , pat % (testprefix , "" , ewi ), "" ,
10441064 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"' ,
10451065 "REGISTRY.tcl" ),
10461066 ("pyw.IDLE" , - 1 , pat % (testprefix , "NoCon" , ewi ), "" ,
10471067 r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"' ,
10481068 "REGISTRY.tcl" ),
1069+ #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" ),
10491083 ])
10501084
10511085 # Registry keys
0 commit comments