Skip to content

NOAA-EMC/spack-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spack-helpers

pytest Test custom action

This Spack extension provides useful commands for modifying and validating and filter Spack environments.

Setup

To register the extension with Spack, activate a Spack instance ($SPACK_ROOT defined and spack executable available), then run:

  . source_me.sh

Compiler filtering: filter-compilers

The filter-compilers subcommand can be used to filter compilers inclusively or exclusively from Spack packages configuration to ensure unwanted compilers are not considered for use by the concretizer:

  spack filter-compilers <compiler-specs> (--keep-only | --remove)

Example: keep only a single gcc version:

  spack filter-compilers [email protected] --keep-only

Intel OneAPI configuration fixes: fix-intel-config

The fix-intel-config subcommand performs various fixes for Intel OneAPI external specs:

  1. Library path configuration: Adds LD_LIBRARY_PATH modifications to external Intel Classic (intel-oneapi-compilers-classic) specs. Without this, some package installations may fail with libimf.so not being found.

  2. Compiler consolidation (optional with -c/--consolidate): Consolidates intel-oneapi-compilers externals by version. Some Intel OneAPI installations have separate externals for C/C++ compilers (icx/icpx) and Fortran (ifx) with slightly different version numbers (e.g., 2025.3.1 vs 2025.3.0). The consolidation feature automatically merges these into a single external based on the first two version numbers.

Basic usage (applies library path fix only):

  spack fix-intel-config

With compiler consolidation:

  spack fix-intel-config --consolidate

Note: This should be run after detecting external Intel installations.

Dependency fetching for Go- and Rust/Cargo-based packages: fetch-deps (go|rust)

The fetch-deps subcommand can be used to fetch dependencies for Go packages (defined in go.mod) or Rust/Cargo packages (defined in Cargo.toml). This command requires a concretized environment. It checks the environment for go or rust dependents, fetches their source code, and retrieves dependencies to $GOMODCACHE/$CARGO_HOME (or default location).

To fetch dependencies for all Go-based packages:

spack fetch-deps go

To fetch dependencies for all Rust/Cargo-based packages and ensure that the spec'd rust dependency is used to do the fetching (this will install the rust package via Spack if it is not already present):

spack fetch-deps rust --use-spack-rust

Environment validation

Important

All of the following commands must be run in an active, concretized environment. Unconcretized root specs will not be accounted for.

Duplicate checking: validate check-duplicates

To check a concretized environment for more than one concretized spec for a given package name and ignore duplicates for specific packages foo and bar:

spack validate check-duplicates --ignore foo --ignore bar

Allow specific packages for a given C/C++/Fortran compiler: validate allow-pkgs-for-compiler

To verify that only specific packages to be built for a given compiler:

spack validate allow-pkgs-for-compiler gcc foo bar

will return an error message if any packages other than foo and bar are spec'd with %gcc.

Ensure only approved packages will be installed: validate check-approved-pkgs

To verify that only packages explicitly approved by the user have been concretized:

spack validate check-approved-pkgs --packages foo bar

or

spack validate check-approved-pkgs --pkgs-from-file approved_list.txt

where approved_list.txt contains newline-delimited package names:

gmake
cmake
gcc
gcc-runtime
...

Ensure only specific C/C++/Fortran compilers are used: validate compilers

To verify that only specific C/C++/Fortran compilers have been concretized:

spack validate compilers intel-oneapi-compilers gcc

will return an error if any packages have c/cxx/fortran providers that are not intel-oneapi-compilers or gcc.

spack-stack deployment

To run a deploy based on a deployments.yaml for a given spack-stack directory and site, run

spack deploy

Compared with the deploy.py utility in spack-stack, this will implement more robust checks. This copy and not the spack-stack one should be used for WCOSS2 installations.

Python API

To access the extensions via Spack Python API (spack-python etc.), do, e.g.:

spack.extensions.load_extension("helpers")
from spack.extensions.helpers import *
from spack.extensions.helpers.cmd import validate

after associating the extensions with your Spack instance (i.e., sourcing source_me.sh).

Unit tests

To run the unit tests:

spack unit-test --extension=helpers

See tests/README.md for more details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published