|
1 | 1 | ## |
2 | | -# Copyright 2009-2025 Ghent University |
3 | | -# Copyright 2015-2025 Stanford University |
| 2 | +# Copyright 2009-2026 Ghent University |
| 3 | +# Copyright 2015-2026 Stanford University |
4 | 4 | # |
5 | 5 | # This file is part of EasyBuild, |
6 | 6 | # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), |
|
40 | 40 | from easybuild.easyblocks.generic.pythonpackage import det_pylibdir |
41 | 41 | from easybuild.framework.easyconfig import CUSTOM |
42 | 42 | from easybuild.tools.build_log import EasyBuildError |
43 | | -from easybuild.tools.modules import get_software_root |
| 43 | +from easybuild.tools.modules import get_software_root, get_software_version |
44 | 44 | from easybuild.tools.run import run_shell_cmd |
45 | 45 | from easybuild.tools.filetools import remove_dir, which |
| 46 | +from easybuild.tools.systemtools import get_shared_lib_ext |
46 | 47 |
|
47 | 48 |
|
48 | 49 | class EB_Amber(CMakeMake): |
@@ -164,13 +165,25 @@ def configure_step(self): |
164 | 165 |
|
165 | 166 | pythonroot = get_software_root('Python') |
166 | 167 | if pythonroot: |
| 168 | + version = get_software_version('Python') |
| 169 | + shlib_ext = get_shared_lib_ext() |
167 | 170 | self.cfg.update('configopts', '-DDOWNLOAD_MINICONDA=FALSE') |
168 | | - self.cfg.update('configopts', '-DPYTHON_EXECUTABLE=%s' % os.path.join(pythonroot, 'bin', 'python')) |
169 | 171 |
|
170 | 172 | self.pylibdir = det_pylibdir() |
171 | 173 | pythonpath = os.environ.get('PYTHONPATH', '') |
172 | 174 | env.setvar('PYTHONPATH', os.pathsep.join([os.path.join(self.installdir, self.pylibdir), pythonpath])) |
173 | 175 |
|
| 176 | + # AmberTools uses the deprecated FindPythonLibs. Ensure we use the correct library and include dir |
| 177 | + version_maj_min = '.'.join(version.split('.')[:2]) |
| 178 | + python_library = os.path.join(pythonroot, 'lib', f'libpython{version_maj_min}.{shlib_ext}') |
| 179 | + python_incdir = os.path.join(pythonroot, 'include', 'python%s' % version_maj_min) |
| 180 | + if not os.path.isfile(python_library): |
| 181 | + raise EasyBuildError("Cannot find Python library '%s'!" % python_library) |
| 182 | + if not os.path.isdir(python_incdir): |
| 183 | + raise EasyBuildError("Cannot find Python include directory '%s'!" % python_incdir) |
| 184 | + self.cfg.update('configopts', f'-DPYTHON_LIBRARY={python_library}') |
| 185 | + self.cfg.update('configopts', f'-DPYTHON_INCLUDE_DIR={python_incdir}') |
| 186 | + |
174 | 187 | if get_software_root('FFTW'): |
175 | 188 | external_libs_list.append('fftw') |
176 | 189 | if get_software_root('netCDF'): |
@@ -343,7 +356,10 @@ def install_step(self): |
343 | 356 | testdir = self.builddir |
344 | 357 | testname_cs = 'test.cuda_serial' |
345 | 358 | testname_cp = 'test.cuda_parallel' |
346 | | - pretestcommands = 'source %s/amber.sh && cd %s' % (self.installdir, testdir) |
| 359 | + pretestcommands = ' && '.join([ |
| 360 | + 'export OMP_NUM_THREADS=1', # avoid having as many threads as cores |
| 361 | + 'source %s/amber.sh && cd %s' % (self.installdir, testdir) |
| 362 | + ]) |
347 | 363 |
|
348 | 364 | # serial tests |
349 | 365 | if LooseVersion(self.version) >= LooseVersion('24'): |
|
0 commit comments