diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2024-03-18 02:00:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 10:00:37 +0100 |
commit | 3d8136493a62c382bc8269d014a4503d7fe05f4d (patch) | |
tree | 09d0a2cf4aff312f52bd301ed26c9bd25380805a /lib | |
parent | 8cd160db858ed50e112ee9cf063507a7854f08dc (diff) | |
download | spack-3d8136493a62c382bc8269d014a4503d7fe05f4d.tar.gz spack-3d8136493a62c382bc8269d014a4503d7fe05f4d.tar.bz2 spack-3d8136493a62c382bc8269d014a4503d7fe05f4d.tar.xz spack-3d8136493a62c382bc8269d014a4503d7fe05f4d.zip |
performance: avoid `jinja2` import at startup unless needed (#43237)
`jinja2` can be a costly import, and right now it happens at startup every time we run
Spack. This slows down `spack --print-shell-vars` a bit, which is needed by `setup-env.*sh`.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/detection/test.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/spack/spack/detection/test.py b/lib/spack/spack/detection/test.py index a9a0311520..657188a38c 100644 --- a/lib/spack/spack/detection/test.py +++ b/lib/spack/spack/detection/test.py @@ -9,8 +9,6 @@ import pathlib import tempfile from typing import Any, Deque, Dict, Generator, List, NamedTuple, Tuple -import jinja2 - from llnl.util import filesystem import spack.repo @@ -85,6 +83,8 @@ class Runner: self.tmpdir.cleanup() def _create_executable_scripts(self, mock_executables: MockExecutables) -> List[pathlib.Path]: + import jinja2 + relative_paths = mock_executables.executables script = mock_executables.script script_template = jinja2.Template("#!/bin/bash\n{{ script }}\n") |