diff options
author | Alberto Invernizzi <9337627+albestro@users.noreply.github.com> | 2024-01-31 15:18:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-31 15:18:25 +0100 |
commit | 72eaca23fe1913a9d1c8320cc1ca0d5a094971e4 (patch) | |
tree | 1a734996c9cef103d242bbe9128070c73971dfc0 /lib | |
parent | 1f11b3844afacd4e190ffe4db7d3241bb298c451 (diff) | |
download | spack-72eaca23fe1913a9d1c8320cc1ca0d5a094971e4.tar.gz spack-72eaca23fe1913a9d1c8320cc1ca0d5a094971e4.tar.bz2 spack-72eaca23fe1913a9d1c8320cc1ca0d5a094971e4.tar.xz spack-72eaca23fe1913a9d1c8320cc1ca0d5a094971e4.zip |
environments: `develop` paths were not getting expanded (#34986)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/environment/environment.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/dev_build.py | 38 |
2 files changed, 40 insertions, 2 deletions
diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 634c1925d3..c8496f255d 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -378,8 +378,8 @@ def _rewrite_relative_dev_paths_on_relocation(env, init_file_dir): if not dev_specs: return for name, entry in dev_specs.items(): - dev_path = entry["path"] - expanded_path = os.path.normpath(os.path.join(init_file_dir, entry["path"])) + dev_path = substitute_path_variables(entry["path"]) + expanded_path = spack.util.path.canonicalize_path(dev_path, default_wd=init_file_dir) # Skip if the expanded path is the same (e.g. when absolute) if dev_path == expanded_path: diff --git a/lib/spack/spack/test/cmd/dev_build.py b/lib/spack/spack/test/cmd/dev_build.py index 8649e17490..0a717fa747 100644 --- a/lib/spack/spack/test/cmd/dev_build.py +++ b/lib/spack/spack/test/cmd/dev_build.py @@ -215,6 +215,44 @@ spack: assert f.read() == spec.package.replacement_string +def test_dev_build_env_with_vars(tmpdir, install_mockery, mutable_mock_env_path, monkeypatch): + """Test Spack does dev builds for packages in develop section of env (path with variables).""" + # setup dev-build-test-install package for dev build + build_dir = tmpdir.mkdir("build") + spec = spack.spec.Spec(f"dev-build-test-install@0.0.0 dev_path={build_dir}") + spec.concretize() + + # store the build path in an environment variable that will be used in the environment + monkeypatch.setenv("CUSTOM_BUILD_PATH", build_dir) + + with build_dir.as_cwd(), open(spec.package.filename, "w") as f: + f.write(spec.package.original_string) + + # setup environment + envdir = tmpdir.mkdir("env") + with envdir.as_cwd(): + with open("spack.yaml", "w") as f: + f.write( + """\ +spack: + specs: + - dev-build-test-install@0.0.0 + + develop: + dev-build-test-install: + spec: dev-build-test-install@0.0.0 + path: $CUSTOM_BUILD_PATH +""" + ) + env("create", "test", "./spack.yaml") + with ev.read("test"): + install() + + assert spec.package.filename in os.listdir(spec.prefix) + with open(os.path.join(spec.prefix, spec.package.filename), "r") as f: + assert f.read() == spec.package.replacement_string + + def test_dev_build_env_version_mismatch(tmpdir, install_mockery, mutable_mock_env_path): """Test Spack constraints concretization by develop specs.""" # setup dev-build-test-install package for dev build |