Update lib/spack/spack/environment/environment.py

Co-authored-by: Greg Becker <becker33@llnl.gov>

Add back path canonicalization
This commit is contained in:
psakievich 2022-09-27 11:02:32 -06:00 committed by psakiev
parent 490b5eef7c
commit 76fde639e8
3 changed files with 11 additions and 12 deletions

View File

@ -77,13 +77,12 @@
#: Name of the directory where environments store repos, logs, views
env_subdir_name = ".spack-env"
def env_root_path():
"""Override default root path if the user specified it"""
config_path = spack.config.get("config:environments_root", default = None)
if config_path:
return config_path
else:
return env_path
return spack.util.path.canonicalize_path(
spack.config.get("config:environments_root", default=env_path), allow_env=False
)
def default_manifest_yaml():

View File

@ -1444,9 +1444,9 @@ def test_environment_created_in_users_location(mutable_config, tmpdir):
assert tmpdir.strpath in env_dir
assert not os.path.isdir(env_dir)
os.makedirs(env_dir)
env('create', 'test')
out = env('list')
assert 'test' in out
env("create", "test")
out = env("list")
assert "test" in out
assert env_dir in ev.root('test')
assert os.path.isdir(os.path.join(env_dir, 'test'))
assert env_dir in ev.root("test")
assert os.path.isdir(os.path.join(env_dir, "test"))

View File

@ -262,7 +262,7 @@ 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, allow_env=True):
"""Substitute config vars, expand environment vars, expand user home."""
path = substitute_config_variables(path, allow_env)
path = os.path.expandvars(path)
@ -306,7 +306,7 @@ def add_padding(path, length):
return os.path.join(path, padding)
def canonicalize_path(path, allow_env = True):
def canonicalize_path(path, allow_env=True):
"""Same as substitute_path_variables, but also take absolute path.
Arguments: