[Python-checkins] CVS: python/dist/src/Lib/lib-tk FixTk.py,1.5,1.5.10.1
Michael Hudson
mwh@users.sourceforge.net
Mon, 25 Feb 2002 02:56:28 -0800
Update of /cvsroot/python/python/dist/src/Lib/lib-tk
In directory usw-pr-cvs1:/tmp/cvs-serv12798
Modified Files:
Tag: release22-maint
FixTk.py
Log Message:
backport loewis' checkin of
revision 1.6 of FixTk.py
Set TCL_LIBRARY before import _tkinter. Suggested by Kirill Simonov.
Fixes #418173 and #219960. 2.2.1 candidate.
Index: FixTk.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/FixTk.py,v
retrieving revision 1.5
retrieving revision 1.5.10.1
diff -C2 -d -r1.5 -r1.5.10.1
*** FixTk.py 12 Oct 2001 15:34:29 -0000 1.5
--- FixTk.py 25 Feb 2002 10:56:25 -0000 1.5.10.1
***************
*** 1,11 ****
! import sys, os, _tkinter
! ver = str(_tkinter.TCL_VERSION)
! for t in "tcl", "tk", "tix":
! key = t.upper() + "_LIBRARY"
! try:
! v = os.environ[key]
! except KeyError:
! v = os.path.join(sys.prefix, "tcl", t+ver)
! if os.path.exists(os.path.join(v, "tclIndex")):
! os.environ[key] = v
--- 1,32 ----
! import sys, os
! # Delay import _tkinter until we have set TCL_LIBRARY,
! # so that Tcl_FindExecutable has a chance to locate its
! # encoding directory.
!
! # Unfortunately, we cannot know the TCL_LIBRARY directory
! # if we don't know the tcl version, which we cannot find out
! # without import Tcl. Fortunately, Tcl will itself look in
! # <TCL_LIBRARY>\..\tcl<TCL_VERSION>, so anything close to
! # the real Tcl library will do.
!
! prefix = os.path.join(sys.prefix,"tcl")
! # if this does not exist, no further search is needed
! if os.path.exists(prefix):
! if not os.environ.has_key("TCL_LIBRARY"):
! for name in os.listdir(prefix):
! if name.startswith("tcl"):
! tcldir = os.path.join(prefix,name)
! if os.path.isdir(tcldir):
! os.environ["TCL_LIBRARY"] = tcldir
! # Now set the other variables accordingly
! import _tkinter
! ver = str(_tkinter.TCL_VERSION)
! for t in "tk", "tix":
! key = t.upper() + "_LIBRARY"
! try:
! v = os.environ[key]
! except KeyError:
! v = os.path.join(sys.prefix, "tcl", t+ver)
! if os.path.exists(os.path.join(v, "tclIndex")):
! os.environ[key] = v