@@ -565,11 +565,11 @@ def checkEnvironment():
565565 ]
566566
567567 # For 10.6+ builds, we build two versions of _tkinter:
568- # - the traditional version (renamed to _tkinter .so.framework ) linked
568+ # - the traditional version (renamed to _tkinter_library .so) linked
569569 # with /Library/Frameworks/{Tcl,Tk}.framework
570- # - the default version linked with our private copies of Tcl and Tk
570+ # - the default version linked with our builtin copies of Tcl and Tk
571571 if DEPTARGET > '10.5' :
572- EXPECTED_SHARED_LIBS ['_tkinter .so.framework ' ] = \
572+ EXPECTED_SHARED_LIBS ['_tkinter_library .so' ] = \
573573 EXPECTED_SHARED_LIBS ['_tkinter.so' ]
574574 EXPECTED_SHARED_LIBS ['_tkinter.so' ] = [
575575 "/Library/Frameworks/Python.framework/Versions/%s/lib/libtcl%s.dylib"
@@ -966,18 +966,18 @@ def buildPython():
966966 # of Tcl and Cocoa Aqua Tk libs because the Apple-supplied Tk 8.5 is
967967 # out-of-date and has critical bugs. Save the _tkinter.so that was
968968 # linked with /Library/Frameworks/{Tck,Tk}.framework and build
969- # another _tkinter.so linked with our private Tcl and Tk libs.
969+ # another _tkinter.so linked with our builtin Tcl and Tk libs.
970970 if DEPTARGET > '10.5' :
971971 runCommand ("find build -name '_tkinter.so' "
972- " -execdir mv '{}' '{}'.framework \;" )
973- print ("Running make to rebuild _tkinter" )
972+ " -execdir mv '{}' _tkinter_library.so \;" )
973+ print ("Running make to build builtin _tkinter" )
974974 runCommand ("make TCLTK_INCLUDES='-I%s/libraries/usr/local/include' "
975975 "TCLTK_LIBS='-L%s/libraries/usr/local/lib -ltcl8.5 -ltk8.5'" % (
976976 shellQuote (WORKDIR )[1 :- 1 ],
977977 shellQuote (WORKDIR )[1 :- 1 ]))
978- # make a backup copy, just in case
978+ # make a copy which will be moved to lib-tkinter later
979979 runCommand ("find build -name '_tkinter.so' "
980- " -execdir cp -p '{}' '{}'.private \;" )
980+ " -execdir cp -p '{}' _tkinter_builtin.so \;" )
981981
982982 print ("Running make install" )
983983 runCommand ("make install DESTDIR=%s" % (
@@ -999,11 +999,31 @@ def buildPython():
999999 'Python.framework' , 'Versions' , getVersion (),
10001000 'lib' ))))
10011001
1002+ path_to_lib = os .path .join (rootDir , 'Library' , 'Frameworks' ,
1003+ 'Python.framework' , 'Versions' ,
1004+ version , 'lib' , 'python%s' % (version ,))
1005+
1006+ # If we made multiple versions of _tkinter, move them to
1007+ # their own directories under python lib. This allows
1008+ # users to select which to import by manipulating sys.path
1009+ # directly or with PYTHONPATH.
1010+
1011+ if DEPTARGET > '10.5' :
1012+ TKINTERS = ['builtin' , 'library' ]
1013+ tkinter_moves = [('_tkinter_' + tkn + '.so' ,
1014+ os .path .join (path_to_lib , 'lib-tkinter' , tkn ))
1015+ for tkn in TKINTERS ]
1016+ # Create the destination directories under lib-tkinter.
1017+ # The permissions and uid/gid will be fixed up next.
1018+ for tkm in tkinter_moves :
1019+ os .makedirs (tkm [1 ])
1020+
10021021 print ("Fix file modes" )
10031022 frmDir = os .path .join (rootDir , 'Library' , 'Frameworks' , 'Python.framework' )
10041023 gid = grp .getgrnam ('admin' ).gr_gid
10051024
10061025 shared_lib_error = False
1026+ moves_list = []
10071027 for dirpath , dirnames , filenames in os .walk (frmDir ):
10081028 for dn in dirnames :
10091029 os .chmod (os .path .join (dirpath , dn ), STAT_0o775 )
@@ -1029,9 +1049,25 @@ def buildPython():
10291049 % (sl , p ))
10301050 shared_lib_error = True
10311051
1052+ # If this is a _tkinter variant, move it to its own directory
1053+ # now that we have fixed its permissions and checked that it
1054+ # was linked properly. The directory was created earlier.
1055+ # The files are moved after the entire tree has been walked
1056+ # since the shared library checking depends on the files
1057+ # having unique names.
1058+ if DEPTARGET > '10.5' :
1059+ for tkm in tkinter_moves :
1060+ if fn == tkm [0 ]:
1061+ moves_list .append (
1062+ (p , os .path .join (tkm [1 ], '_tkinter.so' )))
1063+
10321064 if shared_lib_error :
10331065 fatal ("Unexpected shared library errors." )
10341066
1067+ # Now do the moves.
1068+ for ml in moves_list :
1069+ shutil .move (ml [0 ], ml [1 ])
1070+
10351071 if PYTHON_3 :
10361072 LDVERSION = None
10371073 VERSION = None
@@ -1061,10 +1097,6 @@ def buildPython():
10611097 include_path = '-I%s/libraries/usr/local/include' % (WORKDIR ,)
10621098 lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR ,)
10631099
1064- path_to_lib = os .path .join (rootDir , 'Library' , 'Frameworks' ,
1065- 'Python.framework' , 'Versions' ,
1066- version , 'lib' , 'python%s' % (version ,))
1067-
10681100 # fix Makefile
10691101 path = os .path .join (path_to_lib , 'config' + config_suffix , 'Makefile' )
10701102 fp = open (path , 'r' )
0 commit comments