config: make path replacements lazy#34758
Merged
Conversation
Member
|
@spackbot fix style |
|
Let me see if I can fix that for you! |
|
I was able to run spack style --fix==> Running style checks on spack
selected: isort, mypy, black, flake8
==> Modified files
lib/spack/spack/util/path.py
==> Running isort checks
Fixing /tmp/tmpokzax4_7/spack/lib/spack/spack/util/path.py
isort checks were clean
==> Running mypy checks
Success: no issues found in 572 source files
mypy checks were clean
==> Running black checks
All done! ✨ 🍰 ✨
1 file left unchanged.
black checks were clean
==> Running flake8 checks
lib/spack/spack/util/path.py:58: [E302] expected 2 blank lines, found 1
flake8 found errors
I've updated the branch with style fixes. |
alalazo
previously requested changes
Jan 2, 2023
Member
alalazo
left a comment
There was a problem hiding this comment.
LGTM, but there's still a style issue (blank spaces) that spackbot can't fix
becker33
previously approved these changes
Jan 10, 2023
292536e to
5958227
Compare
Currently, all of the replacements in `spack.util.path.replacements()` get evaluated for each replacement. This makes it easy to get bootstrap issues, because config is used very early on in Spack. Right now, if I run `test_autotools_gnuconfig_replacement_no_gnuconfig` on my M1 mac, I get the circular reference error below. This fixes the issue by making all of the path replacements lazy lambdas. As a bonus, this cleans up the way we do substitution for `$env` -- it's consistent with other substitutions now. - [x] make all path `replacements()` lazy - [x] clean up handling of `$env` ```console > spack unit-test -k test_autotools_gnuconfig_replacement_no_gnuconfig ... ==> [2022-12-31-15:44:21.771459] Error: AttributeError: The 'autotools-config-replacement' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure /Users/gamblin2/src/spack/lib/spack/spack/package_base.py:1332, in prefix: 1330 @Property 1331 def prefix(self): >> 1332 """Get the prefix into which this package should be installed.""" 1333 return self.spec.prefix Traceback (most recent call last): File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 1030, in _setup_pkg_and_run kwargs["env_modifications"] = setup_package( ^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 757, in setup_package set_module_variables_for_package(pkg) File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 596, in set_module_variables_for_package m.std_cmake_args = spack.build_systems.cmake.CMakeBuilder.std_args(pkg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_systems/cmake.py", line 241, in std_args define("CMAKE_INSTALL_PREFIX", pkg.prefix), ^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/package_base.py", line 1333, in prefix return self.spec.prefix ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1710, in prefix self.prefix = spack.store.layout.path_for_spec(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 336, in path_for_spec path = self.relative_path_for_spec(spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 106, in relative_path_for_spec projection = spack.projections.get_projection(self.projections, spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/projections.py", line 13, in get_projection if spec.satisfies(spec_like, strict=True): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 3642, in satisfies if not self.virtual and other.virtual: ^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1622, in virtual return spack.repo.path.is_virtual(self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 890, in is_virtual return have_name and pkg_name in self.provider_index ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 770, in provider_index self._provider_index.merge(repo.provider_index) ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 1096, in provider_index return self.index["providers"] ~~~~~~~~~~^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 592, in __getitem__ self._build_all_indexes() File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 607, in _build_all_indexes self.indexes[name] = self._build_index(name, indexer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 616, in _build_index index_mtime = self.cache.mtime(cache_filename) ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 826, in __getattr__ return getattr(self.instance, name) ^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 825, in __getattr__ raise AttributeError() AttributeError ```
5958227 to
9b19b71
Compare
becker33
previously approved these changes
Jan 10, 2023
becker33
approved these changes
Jan 10, 2023
RikkiButler20
pushed a commit
to RikkiButler20/spack
that referenced
this pull request
Jan 24, 2023
Currently, all of the replacements in `spack.util.path.replacements()` get evaluated for each replacement. This makes it easy to get bootstrap issues, because config is used very early on in Spack. Right now, if I run `test_autotools_gnuconfig_replacement_no_gnuconfig` on my M1 mac, I get the circular reference error below. This fixes the issue by making all of the path replacements lazy lambdas. As a bonus, this cleans up the way we do substitution for `$env` -- it's consistent with other substitutions now. - [x] make all path `replacements()` lazy - [x] clean up handling of `$env` ```console > spack unit-test -k test_autotools_gnuconfig_replacement_no_gnuconfig ... ==> [2022-12-31-15:44:21.771459] Error: AttributeError: The 'autotools-config-replacement' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure /Users/gamblin2/src/spack/lib/spack/spack/package_base.py:1332, in prefix: 1330 @Property 1331 def prefix(self): >> 1332 """Get the prefix into which this package should be installed.""" 1333 return self.spec.prefix Traceback (most recent call last): File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 1030, in _setup_pkg_and_run kwargs["env_modifications"] = setup_package( ^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 757, in setup_package set_module_variables_for_package(pkg) File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 596, in set_module_variables_for_package m.std_cmake_args = spack.build_systems.cmake.CMakeBuilder.std_args(pkg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_systems/cmake.py", line 241, in std_args define("CMAKE_INSTALL_PREFIX", pkg.prefix), ^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/package_base.py", line 1333, in prefix return self.spec.prefix ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1710, in prefix self.prefix = spack.store.layout.path_for_spec(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 336, in path_for_spec path = self.relative_path_for_spec(spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 106, in relative_path_for_spec projection = spack.projections.get_projection(self.projections, spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/projections.py", line 13, in get_projection if spec.satisfies(spec_like, strict=True): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 3642, in satisfies if not self.virtual and other.virtual: ^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1622, in virtual return spack.repo.path.is_virtual(self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 890, in is_virtual return have_name and pkg_name in self.provider_index ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 770, in provider_index self._provider_index.merge(repo.provider_index) ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 1096, in provider_index return self.index["providers"] ~~~~~~~~~~^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 592, in __getitem__ self._build_all_indexes() File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 607, in _build_all_indexes self.indexes[name] = self._build_index(name, indexer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 616, in _build_index index_mtime = self.cache.mtime(cache_filename) ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 826, in __getattr__ return getattr(self.instance, name) ^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 825, in __getattr__ raise AttributeError() AttributeError ```
nhanford
pushed a commit
to nhanford/spack
that referenced
this pull request
Feb 15, 2023
Currently, all of the replacements in `spack.util.path.replacements()` get evaluated for each replacement. This makes it easy to get bootstrap issues, because config is used very early on in Spack. Right now, if I run `test_autotools_gnuconfig_replacement_no_gnuconfig` on my M1 mac, I get the circular reference error below. This fixes the issue by making all of the path replacements lazy lambdas. As a bonus, this cleans up the way we do substitution for `$env` -- it's consistent with other substitutions now. - [x] make all path `replacements()` lazy - [x] clean up handling of `$env` ```console > spack unit-test -k test_autotools_gnuconfig_replacement_no_gnuconfig ... ==> [2022-12-31-15:44:21.771459] Error: AttributeError: The 'autotools-config-replacement' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure /Users/gamblin2/src/spack/lib/spack/spack/package_base.py:1332, in prefix: 1330 @Property 1331 def prefix(self): >> 1332 """Get the prefix into which this package should be installed.""" 1333 return self.spec.prefix Traceback (most recent call last): File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 1030, in _setup_pkg_and_run kwargs["env_modifications"] = setup_package( ^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 757, in setup_package set_module_variables_for_package(pkg) File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 596, in set_module_variables_for_package m.std_cmake_args = spack.build_systems.cmake.CMakeBuilder.std_args(pkg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_systems/cmake.py", line 241, in std_args define("CMAKE_INSTALL_PREFIX", pkg.prefix), ^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/package_base.py", line 1333, in prefix return self.spec.prefix ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1710, in prefix self.prefix = spack.store.layout.path_for_spec(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 336, in path_for_spec path = self.relative_path_for_spec(spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 106, in relative_path_for_spec projection = spack.projections.get_projection(self.projections, spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/projections.py", line 13, in get_projection if spec.satisfies(spec_like, strict=True): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 3642, in satisfies if not self.virtual and other.virtual: ^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1622, in virtual return spack.repo.path.is_virtual(self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 890, in is_virtual return have_name and pkg_name in self.provider_index ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 770, in provider_index self._provider_index.merge(repo.provider_index) ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 1096, in provider_index return self.index["providers"] ~~~~~~~~~~^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 592, in __getitem__ self._build_all_indexes() File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 607, in _build_all_indexes self.indexes[name] = self._build_index(name, indexer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 616, in _build_index index_mtime = self.cache.mtime(cache_filename) ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 826, in __getattr__ return getattr(self.instance, name) ^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 825, in __getattr__ raise AttributeError() AttributeError ```
amd-toolchain-support
pushed a commit
to amd-toolchain-support/spack
that referenced
this pull request
Feb 16, 2023
Currently, all of the replacements in `spack.util.path.replacements()` get evaluated for each replacement. This makes it easy to get bootstrap issues, because config is used very early on in Spack. Right now, if I run `test_autotools_gnuconfig_replacement_no_gnuconfig` on my M1 mac, I get the circular reference error below. This fixes the issue by making all of the path replacements lazy lambdas. As a bonus, this cleans up the way we do substitution for `$env` -- it's consistent with other substitutions now. - [x] make all path `replacements()` lazy - [x] clean up handling of `$env` ```console > spack unit-test -k test_autotools_gnuconfig_replacement_no_gnuconfig ... ==> [2022-12-31-15:44:21.771459] Error: AttributeError: The 'autotools-config-replacement' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure /Users/gamblin2/src/spack/lib/spack/spack/package_base.py:1332, in prefix: 1330 @Property 1331 def prefix(self): >> 1332 """Get the prefix into which this package should be installed.""" 1333 return self.spec.prefix Traceback (most recent call last): File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 1030, in _setup_pkg_and_run kwargs["env_modifications"] = setup_package( ^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 757, in setup_package set_module_variables_for_package(pkg) File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 596, in set_module_variables_for_package m.std_cmake_args = spack.build_systems.cmake.CMakeBuilder.std_args(pkg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_systems/cmake.py", line 241, in std_args define("CMAKE_INSTALL_PREFIX", pkg.prefix), ^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/package_base.py", line 1333, in prefix return self.spec.prefix ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1710, in prefix self.prefix = spack.store.layout.path_for_spec(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 336, in path_for_spec path = self.relative_path_for_spec(spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 106, in relative_path_for_spec projection = spack.projections.get_projection(self.projections, spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/projections.py", line 13, in get_projection if spec.satisfies(spec_like, strict=True): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 3642, in satisfies if not self.virtual and other.virtual: ^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1622, in virtual return spack.repo.path.is_virtual(self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 890, in is_virtual return have_name and pkg_name in self.provider_index ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 770, in provider_index self._provider_index.merge(repo.provider_index) ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 1096, in provider_index return self.index["providers"] ~~~~~~~~~~^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 592, in __getitem__ self._build_all_indexes() File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 607, in _build_all_indexes self.indexes[name] = self._build_index(name, indexer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 616, in _build_index index_mtime = self.cache.mtime(cache_filename) ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 826, in __getattr__ return getattr(self.instance, name) ^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 825, in __getattr__ raise AttributeError() AttributeError ```
techxdave
pushed a commit
to Tech-XCorp/spack
that referenced
this pull request
Feb 17, 2023
Currently, all of the replacements in `spack.util.path.replacements()` get evaluated for each replacement. This makes it easy to get bootstrap issues, because config is used very early on in Spack. Right now, if I run `test_autotools_gnuconfig_replacement_no_gnuconfig` on my M1 mac, I get the circular reference error below. This fixes the issue by making all of the path replacements lazy lambdas. As a bonus, this cleans up the way we do substitution for `$env` -- it's consistent with other substitutions now. - [x] make all path `replacements()` lazy - [x] clean up handling of `$env` ```console > spack unit-test -k test_autotools_gnuconfig_replacement_no_gnuconfig ... ==> [2022-12-31-15:44:21.771459] Error: AttributeError: The 'autotools-config-replacement' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure /Users/gamblin2/src/spack/lib/spack/spack/package_base.py:1332, in prefix: 1330 @Property 1331 def prefix(self): >> 1332 """Get the prefix into which this package should be installed.""" 1333 return self.spec.prefix Traceback (most recent call last): File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 1030, in _setup_pkg_and_run kwargs["env_modifications"] = setup_package( ^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 757, in setup_package set_module_variables_for_package(pkg) File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 596, in set_module_variables_for_package m.std_cmake_args = spack.build_systems.cmake.CMakeBuilder.std_args(pkg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_systems/cmake.py", line 241, in std_args define("CMAKE_INSTALL_PREFIX", pkg.prefix), ^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/package_base.py", line 1333, in prefix return self.spec.prefix ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1710, in prefix self.prefix = spack.store.layout.path_for_spec(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 336, in path_for_spec path = self.relative_path_for_spec(spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 106, in relative_path_for_spec projection = spack.projections.get_projection(self.projections, spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/projections.py", line 13, in get_projection if spec.satisfies(spec_like, strict=True): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 3642, in satisfies if not self.virtual and other.virtual: ^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1622, in virtual return spack.repo.path.is_virtual(self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 890, in is_virtual return have_name and pkg_name in self.provider_index ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 770, in provider_index self._provider_index.merge(repo.provider_index) ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 1096, in provider_index return self.index["providers"] ~~~~~~~~~~^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 592, in __getitem__ self._build_all_indexes() File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 607, in _build_all_indexes self.indexes[name] = self._build_index(name, indexer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 616, in _build_index index_mtime = self.cache.mtime(cache_filename) ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 826, in __getattr__ return getattr(self.instance, name) ^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 825, in __getattr__ raise AttributeError() AttributeError ```
jmcarcell
pushed a commit
to key4hep/spack
that referenced
this pull request
Apr 13, 2023
Currently, all of the replacements in `spack.util.path.replacements()` get evaluated for each replacement. This makes it easy to get bootstrap issues, because config is used very early on in Spack. Right now, if I run `test_autotools_gnuconfig_replacement_no_gnuconfig` on my M1 mac, I get the circular reference error below. This fixes the issue by making all of the path replacements lazy lambdas. As a bonus, this cleans up the way we do substitution for `$env` -- it's consistent with other substitutions now. - [x] make all path `replacements()` lazy - [x] clean up handling of `$env` ```console > spack unit-test -k test_autotools_gnuconfig_replacement_no_gnuconfig ... ==> [2022-12-31-15:44:21.771459] Error: AttributeError: The 'autotools-config-replacement' package cannot find an attribute while trying to build from sources. This might be due to a change in Spack's package format to support multiple build-systems for a single package. You can fix this by updating the build recipe, and you can also report the issue as a bug. More information at https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure /Users/gamblin2/src/spack/lib/spack/spack/package_base.py:1332, in prefix: 1330 @Property 1331 def prefix(self): >> 1332 """Get the prefix into which this package should be installed.""" 1333 return self.spec.prefix Traceback (most recent call last): File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 1030, in _setup_pkg_and_run kwargs["env_modifications"] = setup_package( ^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 757, in setup_package set_module_variables_for_package(pkg) File "/Users/gamblin2/src/spack/lib/spack/spack/build_environment.py", line 596, in set_module_variables_for_package m.std_cmake_args = spack.build_systems.cmake.CMakeBuilder.std_args(pkg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/build_systems/cmake.py", line 241, in std_args define("CMAKE_INSTALL_PREFIX", pkg.prefix), ^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/package_base.py", line 1333, in prefix return self.spec.prefix ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1710, in prefix self.prefix = spack.store.layout.path_for_spec(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 336, in path_for_spec path = self.relative_path_for_spec(spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/directory_layout.py", line 106, in relative_path_for_spec projection = spack.projections.get_projection(self.projections, spec) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/projections.py", line 13, in get_projection if spec.satisfies(spec_like, strict=True): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 3642, in satisfies if not self.virtual and other.virtual: ^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/spec.py", line 1622, in virtual return spack.repo.path.is_virtual(self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 890, in is_virtual return have_name and pkg_name in self.provider_index ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 770, in provider_index self._provider_index.merge(repo.provider_index) ^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 1096, in provider_index return self.index["providers"] ~~~~~~~~~~^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 592, in __getitem__ self._build_all_indexes() File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 607, in _build_all_indexes self.indexes[name] = self._build_index(name, indexer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/spack/repo.py", line 616, in _build_index index_mtime = self.cache.mtime(cache_filename) ^^^^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 826, in __getattr__ return getattr(self.instance, name) ^^^^^^^^^^^^^ File "/Users/gamblin2/src/spack/lib/spack/llnl/util/lang.py", line 825, in __getattr__ raise AttributeError() AttributeError ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, all of the replacements in
spack.util.path.replacements()get evaluated for each replacement. This makes it easy to get bootstrap issues, because config is used very early on in Spack.Right now, if I run
test_autotools_gnuconfig_replacement_no_gnuconfigon my M1 mac, I get the circular reference error below. This fixes the issue by making all of the path replacements lazy lambdas.As a bonus, this cleans up the way we do substitution for
$env-- it's consistent with other substitutions now.replacements()lazy$env