Tk/Tcl packages: speed up file search (#35902)
This commit is contained in:
parent
ac5f0cc340
commit
3b15e7bf41
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from llnl.util.filesystem import find_first
|
||||||
|
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
from spack.util.environment import is_system_path
|
from spack.util.environment import is_system_path
|
||||||
|
|
||||||
@ -93,6 +95,18 @@ def command(self):
|
|||||||
os.path.realpath(self.prefix.bin.join("tclsh{0}".format(self.version.up_to(2))))
|
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):
|
def setup_run_environment(self, env):
|
||||||
"""Set TCL_LIBRARY to the directory containing init.tcl.
|
"""Set TCL_LIBRARY to the directory containing init.tcl.
|
||||||
|
|
||||||
@ -102,7 +116,7 @@ def setup_run_environment(self, env):
|
|||||||
"""
|
"""
|
||||||
# When using tkinter from within spack provided python+tkinter,
|
# When using tkinter from within spack provided python+tkinter,
|
||||||
# python will not be able to find Tcl unless TCL_LIBRARY is set.
|
# 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):
|
def setup_dependent_build_environment(self, env, dependent_spec):
|
||||||
"""Set TCL_LIBRARY to the directory containing init.tcl.
|
"""Set TCL_LIBRARY to the directory containing init.tcl.
|
||||||
@ -114,7 +128,7 @@ def setup_dependent_build_environment(self, env, dependent_spec):
|
|||||||
* https://wiki.tcl-lang.org/page/TCL_LIBRARY
|
* https://wiki.tcl-lang.org/page/TCL_LIBRARY
|
||||||
* https://wiki.tcl-lang.org/page/TCLLIBPATH
|
* 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
|
# If we set TCLLIBPATH, we must also ensure that the corresponding
|
||||||
# tcl is found in the build environment. This to prevent cases
|
# tcl is found in the build environment. This to prevent cases
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from llnl.util.filesystem import find_first
|
||||||
|
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
@ -118,6 +120,18 @@ def libs(self):
|
|||||||
["libtk{0}".format(self.version.up_to(2))], root=self.prefix, recursive=True
|
["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):
|
def setup_run_environment(self, env):
|
||||||
"""Set TK_LIBRARY to the directory containing tk.tcl.
|
"""Set TK_LIBRARY to the directory containing tk.tcl.
|
||||||
|
|
||||||
@ -127,7 +141,7 @@ def setup_run_environment(self, env):
|
|||||||
"""
|
"""
|
||||||
# When using tkinter from within spack provided python+tkinter,
|
# When using tkinter from within spack provided python+tkinter,
|
||||||
# python will not be able to find Tk unless TK_LIBRARY is set.
|
# 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):
|
def setup_dependent_build_environment(self, env, dependent_spec):
|
||||||
"""Set TK_LIBRARY to the directory containing tk.tcl.
|
"""Set TK_LIBRARY to the directory containing tk.tcl.
|
||||||
@ -136,4 +150,4 @@ def setup_dependent_build_environment(self, env, dependent_spec):
|
|||||||
|
|
||||||
* https://www.tcl-lang.org/man/tcl/TkCmd/tkvars.htm
|
* 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())
|
||||||
|
Loading…
Reference in New Issue
Block a user