diff options
-rw-r--r-- | var/spack/repos/builtin/packages/tcl/package.py | 18 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/tk/package.py | 18 |
2 files changed, 32 insertions, 4 deletions
diff --git a/var/spack/repos/builtin/packages/tcl/package.py b/var/spack/repos/builtin/packages/tcl/package.py index 9bd54ce247..951c9b8811 100644 --- a/var/spack/repos/builtin/packages/tcl/package.py +++ b/var/spack/repos/builtin/packages/tcl/package.py @@ -5,6 +5,8 @@ import os +from llnl.util.filesystem import find_first + from spack.package import * from spack.util.environment import is_system_path @@ -93,6 +95,18 @@ class Tcl(AutotoolsPackage, SourceforgePackage): os.path.realpath(self.prefix.bin.join("tclsh{0}".format(self.version.up_to(2)))) ) + def _find_script_dir(self): + # Put more-specific prefixes first + check_prefixes = [ + join_path(self.prefix, "share", "tcl{0}".format(self.version.up_to(2))), + self.prefix, + ] + for prefix in check_prefixes: + result = find_first(prefix, "init.tcl") + if result: + return os.path.dirname(result) + raise RuntimeError("Cannot locate init.tcl") + def setup_run_environment(self, env): """Set TCL_LIBRARY to the directory containing init.tcl. @@ -102,7 +116,7 @@ class Tcl(AutotoolsPackage, SourceforgePackage): """ # When using tkinter from within spack provided python+tkinter, # python will not be able to find Tcl unless TCL_LIBRARY is set. - env.set("TCL_LIBRARY", os.path.dirname(sorted(find(self.prefix, "init.tcl"))[0])) + env.set("TCL_LIBRARY", self._find_script_dir()) def setup_dependent_build_environment(self, env, dependent_spec): """Set TCL_LIBRARY to the directory containing init.tcl. @@ -114,7 +128,7 @@ class Tcl(AutotoolsPackage, SourceforgePackage): * https://wiki.tcl-lang.org/page/TCL_LIBRARY * https://wiki.tcl-lang.org/page/TCLLIBPATH """ - env.set("TCL_LIBRARY", os.path.dirname(sorted(find(self.prefix, "init.tcl"))[0])) + env.set("TCL_LIBRARY", self._find_script_dir()) # If we set TCLLIBPATH, we must also ensure that the corresponding # tcl is found in the build environment. This to prevent cases diff --git a/var/spack/repos/builtin/packages/tk/package.py b/var/spack/repos/builtin/packages/tk/package.py index 557a57cce8..316005caa5 100644 --- a/var/spack/repos/builtin/packages/tk/package.py +++ b/var/spack/repos/builtin/packages/tk/package.py @@ -5,6 +5,8 @@ import os +from llnl.util.filesystem import find_first + from spack.package import * @@ -118,6 +120,18 @@ class Tk(AutotoolsPackage, SourceforgePackage): ["libtk{0}".format(self.version.up_to(2))], root=self.prefix, recursive=True ) + def _find_script_dir(self): + # Put more-specific prefixes first + check_prefixes = [ + join_path(self.prefix, "share", "tk{0}".format(self.version.up_to(2))), + self.prefix, + ] + for prefix in check_prefixes: + result = find_first(prefix, "tk.tcl") + if result: + return os.path.dirname(result) + raise RuntimeError("Cannot locate tk.tcl") + def setup_run_environment(self, env): """Set TK_LIBRARY to the directory containing tk.tcl. @@ -127,7 +141,7 @@ class Tk(AutotoolsPackage, SourceforgePackage): """ # When using tkinter from within spack provided python+tkinter, # python will not be able to find Tk unless TK_LIBRARY is set. - env.set("TK_LIBRARY", os.path.dirname(sorted(find(self.prefix, "tk.tcl"))[0])) + env.set("TK_LIBRARY", self._find_script_dir()) def setup_dependent_build_environment(self, env, dependent_spec): """Set TK_LIBRARY to the directory containing tk.tcl. @@ -136,4 +150,4 @@ class Tk(AutotoolsPackage, SourceforgePackage): * https://www.tcl-lang.org/man/tcl/TkCmd/tkvars.htm """ - env.set("TK_LIBRARY", os.path.dirname(sorted(find(self.prefix, "tk.tcl"))[0])) + env.set("TK_LIBRARY", self._find_script_dir()) |