| OLD | NEW |
| 1 import sys, os | 1 import sys, os |
| 2 | 2 |
| 3 # Delay import _tkinter until we have set TCL_LIBRARY, | 3 # Delay import _tkinter until we have set TCL_LIBRARY, |
| 4 # so that Tcl_FindExecutable has a chance to locate its | 4 # so that Tcl_FindExecutable has a chance to locate its |
| 5 # encoding directory. | 5 # encoding directory. |
| 6 | 6 |
| 7 # Unfortunately, we cannot know the TCL_LIBRARY directory | 7 # Unfortunately, we cannot know the TCL_LIBRARY directory |
| 8 # if we don't know the tcl version, which we cannot find out | 8 # if we don't know the tcl version, which we cannot find out |
| 9 # without import Tcl. Fortunately, Tcl will itself look in | 9 # without import Tcl. Fortunately, Tcl will itself look in |
| 10 # <TCL_LIBRARY>\..\tcl<TCL_VERSION>, so anything close to | 10 # <TCL_LIBRARY>\..\tcl<TCL_VERSION>, so anything close to |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 # Conversion failed (e.g. network location) | 39 # Conversion failed (e.g. network location) |
| 40 return s | 40 return s |
| 41 s = buf[:res] | 41 s = buf[:res] |
| 42 # Ignore leading \\?\ | 42 # Ignore leading \\?\ |
| 43 if s.startswith("\\\\?\\"): | 43 if s.startswith("\\\\?\\"): |
| 44 s = s[4:] | 44 s = s[4:] |
| 45 if s.startswith("UNC"): | 45 if s.startswith("UNC"): |
| 46 s = "\\" + s[3:] | 46 s = "\\" + s[3:] |
| 47 return s | 47 return s |
| 48 | 48 |
| 49 prefix = os.path.join(sys.prefix,"tcl") | 49 prefix = os.path.join(sys.base_prefix,"tcl") |
| 50 if not os.path.exists(prefix): | 50 if not os.path.exists(prefix): |
| 51 # devdir/../tcltk/lib | 51 # devdir/../tcltk/lib |
| 52 prefix = os.path.join(sys.prefix, os.path.pardir, "tcltk", "lib") | 52 prefix = os.path.join(sys.base_prefix, os.path.pardir, "tcltk", "lib") |
| 53 prefix = os.path.abspath(prefix) | 53 prefix = os.path.abspath(prefix) |
| 54 # if this does not exist, no further search is needed | 54 # if this does not exist, no further search is needed |
| 55 if os.path.exists(prefix): | 55 if os.path.exists(prefix): |
| 56 prefix = convert_path(prefix) | 56 prefix = convert_path(prefix) |
| 57 if "TCL_LIBRARY" not in os.environ: | 57 if "TCL_LIBRARY" not in os.environ: |
| 58 for name in os.listdir(prefix): | 58 for name in os.listdir(prefix): |
| 59 if name.startswith("tcl"): | 59 if name.startswith("tcl"): |
| 60 tcldir = os.path.join(prefix,name) | 60 tcldir = os.path.join(prefix,name) |
| 61 if os.path.isdir(tcldir): | 61 if os.path.isdir(tcldir): |
| 62 os.environ["TCL_LIBRARY"] = tcldir | 62 os.environ["TCL_LIBRARY"] = tcldir |
| 63 # Compute TK_LIBRARY, knowing that it has the same version | 63 # Compute TK_LIBRARY, knowing that it has the same version |
| 64 # as Tcl | 64 # as Tcl |
| 65 import _tkinter | 65 import _tkinter |
| 66 ver = str(_tkinter.TCL_VERSION) | 66 ver = str(_tkinter.TCL_VERSION) |
| 67 if "TK_LIBRARY" not in os.environ: | 67 if "TK_LIBRARY" not in os.environ: |
| 68 v = os.path.join(prefix, 'tk'+ver) | 68 v = os.path.join(prefix, 'tk'+ver) |
| 69 if os.path.exists(os.path.join(v, "tclIndex")): | 69 if os.path.exists(os.path.join(v, "tclIndex")): |
| 70 os.environ['TK_LIBRARY'] = v | 70 os.environ['TK_LIBRARY'] = v |
| 71 # We don't know the Tix version, so we must search the entire | 71 # We don't know the Tix version, so we must search the entire |
| 72 # directory | 72 # directory |
| 73 if "TIX_LIBRARY" not in os.environ: | 73 if "TIX_LIBRARY" not in os.environ: |
| 74 for name in os.listdir(prefix): | 74 for name in os.listdir(prefix): |
| 75 if name.startswith("tix"): | 75 if name.startswith("tix"): |
| 76 tixdir = os.path.join(prefix,name) | 76 tixdir = os.path.join(prefix,name) |
| 77 if os.path.isdir(tixdir): | 77 if os.path.isdir(tixdir): |
| 78 os.environ["TIX_LIBRARY"] = tixdir | 78 os.environ["TIX_LIBRARY"] = tixdir |
| OLD | NEW |