123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import sys, os
- try:
- import ctypes
- ctypes.windll.kernel32.GetFinalPathNameByHandleW
- except (ImportError, AttributeError):
- def convert_path(s):
- return s
- else:
- def convert_path(s):
- assert isinstance(s, str)
- udir = s.decode("mbcs")
- hdir = ctypes.windll.kernel32.\
- CreateFileW(udir, 0x80,
- 1,
- None, 3,
- 0x02000000,
- None)
- if hdir == -1:
-
- return s
- buf = ctypes.create_unicode_buffer(u"", 32768)
- res = ctypes.windll.kernel32.\
- GetFinalPathNameByHandleW(hdir, buf, len(buf),
- 0)
- ctypes.windll.kernel32.CloseHandle(hdir)
- if res == 0:
-
- return s
- s = buf[:res].encode("mbcs")
-
- if s.startswith("\\\\?\\"):
- s = s[4:]
- if s.startswith("UNC"):
- s = "\\" + s[3:]
- return s
- prefix = os.path.join(sys.prefix,"tcl")
- if not os.path.exists(prefix):
-
- tcltk = 'tcltk'
- if sys.maxsize > 2**31 - 1:
- tcltk = 'tcltk64'
- prefix = os.path.join(sys.prefix, "externals", tcltk, "lib")
- prefix = os.path.abspath(prefix)
- if os.path.exists(prefix):
- prefix = convert_path(prefix)
- if "TCL_LIBRARY" not in os.environ:
- 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
-
-
- import _tkinter
- ver = str(_tkinter.TCL_VERSION)
- if "TK_LIBRARY" not in os.environ:
- v = os.path.join(prefix, 'tk'+ver)
- if os.path.exists(os.path.join(v, "tclIndex")):
- os.environ['TK_LIBRARY'] = v
-
-
- if "TIX_LIBRARY" not in os.environ:
- for name in os.listdir(prefix):
- if name.startswith("tix"):
- tixdir = os.path.join(prefix,name)
- if os.path.isdir(tixdir):
- os.environ["TIX_LIBRARY"] = tixdir
|