Skip to content

Commit c4f40fb

Browse files
committed
Merge branch 'develop' into 5.0.x
2 parents 45d8f28 + 1d3d418 commit c4f40fb

File tree

5 files changed

+189
-77
lines changed

5 files changed

+189
-77
lines changed

easybuild/easyblocks/generic/cargo.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ def get_workspace_members(crate_dir):
125125
return [os.path.join(crate_dir, m) for m in members]
126126

127127

128+
def get_checksum(src, log):
129+
"""Get the checksum from an extracted source"""
130+
checksum = src['checksum']
131+
if isinstance(checksum, dict):
132+
try:
133+
checksum = checksum[src['name']]
134+
except KeyError:
135+
log.warning('No checksum for %s in %s', checksum, src['name'])
136+
checksum = None
137+
return checksum
138+
139+
128140
class Cargo(ExtensionEasyBlock):
129141
"""Support for installing Cargo packages (Rust)"""
130142

@@ -186,13 +198,7 @@ def __init__(self, *args, **kwargs):
186198
"""Constructor for Cargo easyblock."""
187199
super(Cargo, self).__init__(*args, **kwargs)
188200
self.cargo_home = os.path.join(self.builddir, '.cargo')
189-
env.setvar('CARGO_HOME', self.cargo_home)
190-
env.setvar('RUSTC', 'rustc')
191-
env.setvar('RUSTDOC', 'rustdoc')
192-
env.setvar('RUSTFMT', 'rustfmt')
193-
env.setvar('RUSTFLAGS', self.rustc_optarch())
194-
env.setvar('RUST_LOG', 'DEBUG')
195-
env.setvar('RUST_BACKTRACE', '1')
201+
self.set_cargo_vars()
196202

197203
# Populate sources from "crates" list of tuples
198204
sources = []
@@ -219,11 +225,31 @@ def __init__(self, *args, **kwargs):
219225

220226
self.cfg.update('sources', sources)
221227

228+
def set_cargo_vars(self):
229+
"""Set environment variables for Rust compilation and Cargo"""
230+
env.setvar('CARGO_HOME', self.cargo_home)
231+
env.setvar('RUSTC', 'rustc')
232+
env.setvar('RUSTDOC', 'rustdoc')
233+
env.setvar('RUSTFMT', 'rustfmt')
234+
env.setvar('RUSTFLAGS', self.rustc_optarch())
235+
env.setvar('RUST_LOG', 'DEBUG')
236+
env.setvar('RUST_BACKTRACE', '1')
237+
222238
@property
223239
def crates(self):
224240
"""Return the crates as defined in the EasyConfig"""
225241
return self.cfg['crates']
226242

243+
def load_module(self, *args, **kwargs):
244+
"""(Re)set environment variables after loading module file.
245+
246+
Required here to ensure the variables are defined for stand-alone installations and extensions,
247+
because the environment is reset to the initial environment right before loading the module.
248+
"""
249+
250+
super(Cargo, self).load_module(*args, **kwargs)
251+
self.set_cargo_vars()
252+
227253
def extract_step(self):
228254
"""
229255
Unpack the source files and populate them with required .cargo-checksum.json if offline
@@ -257,12 +283,13 @@ def extract_step(self):
257283
except KeyError:
258284
git_sources[git_key] = src
259285
else:
260-
previous_checksum = previous_source['checksum']
261-
current_checksum = src['checksum']
286+
previous_checksum = get_checksum(previous_source, self.log)
287+
current_checksum = get_checksum(src, self.log)
262288
if previous_checksum and current_checksum and previous_checksum != current_checksum:
263-
raise EasyBuildError("Sources for the same git repository need to be identical."
264-
"Mismatch found for %s rev %s in %s vs %s",
265-
git_repo, rev, previous_source['name'], src['name'])
289+
raise EasyBuildError("Sources for the same git repository need to be identical. "
290+
"Mismatch found for %s rev %s in %s (checksum: %s) vs %s (checksum: %s)",
291+
git_repo, rev, previous_source['name'], previous_checksum,
292+
src['name'], current_checksum)
266293
self.log.info("Source %s already extracted to %s by %s. Skipping extraction.",
267294
src['name'], previous_source['finalpath'], previous_source['name'])
268295
src['finalpath'] = previous_source['finalpath']

easybuild/easyblocks/generic/pythonpackage.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,9 @@ def test_step(self, return_output_ec=False):
876876
actual_installdir = os.path.join(test_installdir, 'local')
877877
else:
878878
actual_installdir = test_installdir
879+
# Export the temporary installdir as an environment variable
880+
# Some tests (e.g. for astropy) require to be run in the installdir
881+
env.setvar('EB_PYTHONPACKAGE_TEST_INSTALLDIR', actual_installdir)
879882

880883
self.log.debug("Pre-creating subdirectories in %s: %s", actual_installdir, self.all_pylibdirs)
881884
for pylibdir in self.all_pylibdirs:

easybuild/easyblocks/l/lammps.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
'skylake_avx512': 'SKX',
127127
'cascadelake': 'SKX',
128128
'icelake': 'SKX',
129+
'sapphirerapids': 'SKX',
129130
'knights-landing': 'KNL',
130131
'zen': 'ZEN',
131132
'zen2': 'ZEN2',
@@ -242,6 +243,7 @@ def update_kokkos_cpu_mapping(self):
242243

243244
if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('2Aug2023')):
244245
self.kokkos_cpu_mapping['icelake'] = 'ICX'
246+
self.kokkos_cpu_mapping['sapphirerapids'] = 'SPR'
245247

246248
def prepare_step(self, *args, **kwargs):
247249
"""Custom prepare step for LAMMPS."""
@@ -478,7 +480,7 @@ def install_step(self):
478480

479481
mkdir(site_packages, parents=True)
480482

481-
self.lammpsdir = os.path.join(self.builddir, '%s-*_%s' % (self.name.lower(), self.version))
483+
self.lammpsdir = os.path.join(self.builddir, '%s-*' % self.name.lower())
482484
self.python_dir = os.path.join(self.lammpsdir, 'python')
483485

484486
# The -i flag is added through a patch to the lammps source file python/install.py

easybuild/easyblocks/o/openfoam.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import easybuild.tools.toolchain as toolchain
4949
from easybuild.easyblocks.generic.cmakemake import setup_cmake_env
5050
from easybuild.framework.easyblock import EasyBlock
51+
from easybuild.framework.easyconfig import CUSTOM
5152
from easybuild.tools.build_log import EasyBuildError
5253
from easybuild.tools.filetools import adjust_permissions, apply_regex_substitutions, mkdir, write_file
5354
from easybuild.tools.modules import get_software_root, get_software_version
@@ -58,6 +59,15 @@
5859
class EB_OpenFOAM(EasyBlock):
5960
"""Support for building and installing OpenFOAM."""
6061

62+
@staticmethod
63+
def extra_options():
64+
"""Custom easyconfig parameter specific to OpenFOAM."""
65+
extra_vars = EasyBlock.extra_options()
66+
extra_vars.update({
67+
'sanity_check_motorbike': [True, "Should the motorbike sanity check run?", CUSTOM],
68+
})
69+
return extra_vars
70+
6171
def __init__(self, *args, **kwargs):
6272
"""Specify that OpenFOAM should be built in install dir."""
6373

@@ -540,7 +550,8 @@ def sanity_check_step(self):
540550

541551
# run motorBike tutorial case to ensure the installation is functional (if it's available);
542552
# only for recent (>= v6.0) versions of openfoam.org variant
543-
if self.is_dot_org and self.looseversion >= LooseVersion('6'):
553+
# could be turned off by set 'sanity_check_motorbike' to False (default True)
554+
if self.is_dot_org and self.looseversion >= LooseVersion('6') and self.cfg['sanity_check_motorbike']:
544555
openfoamdir_path = os.path.join(self.installdir, self.openfoamdir)
545556
if self.looseversion <= LooseVersion('10'):
546557
motorbike_path = os.path.join(

0 commit comments

Comments
 (0)