From 29fbad20a2ad8bd5abc63169459040d6b67c960a Mon Sep 17 00:00:00 2001 From: psakiev Date: Tue, 21 Feb 2023 09:18:44 -0700 Subject: [PATCH] Undo hoops for avoiding env include --- lib/spack/spack/environment/environment.py | 2 +- lib/spack/spack/util/path.py | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 03bdc479aec..4140fcabb1d 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -83,7 +83,7 @@ def env_root_path(): """Override default root path if the user specified it""" return spack.util.path.canonicalize_path( - spack.config.get("config:environments_root", default=default_env_path), allow_env=False + spack.config.get("config:environments_root", default=default_env_path) ) diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py index fe5e821f30c..25b397f9350 100644 --- a/lib/spack/spack/util/path.py +++ b/lib/spack/spack/util/path.py @@ -275,7 +275,7 @@ def convert_to_platform_path(path): return format_os_path(path, mode=Path.platform_path) -def substitute_config_variables(path, allow_env=True): +def substitute_config_variables(path): """Substitute placeholders into paths. Spack allows paths in configs to have some placeholders, as follows: @@ -301,16 +301,6 @@ def substitute_config_variables(path, allow_env=True): """ _replacements = replacements() - if allow_env: - import spack.environment as ev # break circular - - env = ev.active_environment() - if env: - _replacements.update({"env": env.path}) - else: - # If a previous invocation added env, remove it - _replacements.pop("env", None) - # Look up replacements def repl(match): m = match.group(0) @@ -322,9 +312,9 @@ def repl(match): return re.sub(r"(\$\w+\b|\$\{\w+\})", repl, path) -def substitute_path_variables(path, allow_env=True): +def substitute_path_variables(path): """Substitute config vars, expand environment vars, expand user home.""" - path = substitute_config_variables(path, allow_env) + path = substitute_config_variables(path) path = os.path.expandvars(path) path = os.path.expanduser(path) return path @@ -366,7 +356,7 @@ def add_padding(path, length): return os.path.join(path, padding) -def canonicalize_path(path, default_wd=None, allow_env=True): +def canonicalize_path(path, default_wd=None): """Same as substitute_path_variables, but also take absolute path. If the string is a yaml object with file annotations, make absolute paths @@ -386,7 +376,7 @@ def canonicalize_path(path, default_wd=None, allow_env=True): filename = os.path.dirname(path._start_mark.name) assert path._start_mark.name == path._end_mark.name - path = substitute_path_variables(path, allow_env) + path = substitute_path_variables(path) if not os.path.isabs(path): if filename: path = os.path.join(filename, path)