@@ -26,9 +26,16 @@ def pre_spack(ctx: DeployContext) -> dict[str, Any] | None:
2626 _check_unsupported (ctx .machine , toolchain_pairs )
2727
2828 updates : dict [str , Any ] = {}
29+ exclude_packages = _get_spack_exclude_packages (ctx .config )
30+ _maybe_exclude_e3sm_hdf5_netcdf (
31+ exclude_packages = exclude_packages , machine_config = ctx .machine_config
32+ )
33+
2934 spack_path = _get_spack_path (ctx .config , ctx .machine , ctx .machine_config )
3035 if spack_path is not None :
3136 updates ['spack' ] = {'spack_path' : spack_path }
37+ if exclude_packages :
38+ updates .setdefault ('spack' , {})['exclude_packages' ] = exclude_packages
3239
3340 if _with_albany (ctx ):
3441 _check_albany_support (ctx .machine , toolchain_pairs )
@@ -105,6 +112,35 @@ def _get_toolchain_pairs(ctx: DeployContext) -> list[tuple[str, str]]:
105112 return toolchain_pairs
106113
107114
115+ def _get_spack_exclude_packages (config ) -> list [str ]:
116+ spack_cfg = config .get ('spack' , {})
117+ if not isinstance (spack_cfg , dict ):
118+ return []
119+
120+ exclude_packages = spack_cfg .get ('exclude_packages' , [])
121+ if exclude_packages is None :
122+ return []
123+ if isinstance (exclude_packages , str ):
124+ return [exclude_packages ]
125+
126+ return [str (package ) for package in exclude_packages ]
127+
128+
129+ def _maybe_exclude_e3sm_hdf5_netcdf (
130+ exclude_packages : list [str ], machine_config
131+ ) -> None :
132+ use_bundle = False
133+ if machine_config .has_section ('deploy' ) and machine_config .has_option (
134+ 'deploy' , 'use_e3sm_hdf5_netcdf'
135+ ):
136+ use_bundle = machine_config .getboolean (
137+ 'deploy' , 'use_e3sm_hdf5_netcdf'
138+ )
139+
140+ if not use_bundle and 'hdf5_netcdf' not in exclude_packages :
141+ exclude_packages .append ('hdf5_netcdf' )
142+
143+
108144def _check_unsupported (
109145 machine : str | None , toolchain_pairs : list [tuple [str , str ]]
110146) -> None :
0 commit comments