Apply fix suggested by @becker33 to copy over relatives includes at env creation
This commit is contained in:
parent
d6334f7d39
commit
0301896bf1
@ -2634,6 +2634,29 @@ def _ensure_env_dir():
|
||||
|
||||
shutil.copy(envfile, target_manifest)
|
||||
|
||||
# Copy relative path includes that live inside the environment dir
|
||||
try:
|
||||
manifest = EnvironmentManifestFile(environment_dir)
|
||||
except Exception as e:
|
||||
msg = f"cannot initialize environment, '{environment_dir}' from manifest"
|
||||
raise SpackEnvironmentError(msg) from e
|
||||
else:
|
||||
includes = manifest[TOP_LEVEL_KEY].get("include", [])
|
||||
for include in includes:
|
||||
if os.path.isabs(include):
|
||||
continue
|
||||
|
||||
abspath = pathlib.Path(os.path.normpath(environment_dir / include))
|
||||
if not abspath.is_relative_to(environment_dir):
|
||||
# Warn that we are not copying relative path
|
||||
msg = "Spack will not copy relative include path from outside environment"
|
||||
msg += f" directory: {include}"
|
||||
tty.warn(msg)
|
||||
continue
|
||||
|
||||
orig_abspath = os.path.normpath(envfile.parent / include)
|
||||
shutil.copy(orig_abspath, abspath)
|
||||
|
||||
|
||||
class EnvironmentManifestFile(collections.abc.Mapping):
|
||||
"""Manages the in-memory representation of a manifest file, and its synchronization
|
||||
|
Loading…
Reference in New Issue
Block a user