From 5989313c9f06cb14f46abbbce3b2260439f91a2e Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 15:44:53 +0200 Subject: [PATCH 01/25] generate version from the source files for using software-commit --- easybuild/easyblocks/l/lammps.py | 107 ++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 30 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 9e8d2861944..2be7b31f923 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -154,18 +154,18 @@ ref_version = '29Sep2021' -def translate_lammps_version(version): +def generate_cur_version(items): + """Generate computer readable version""" + + + +def translate_lammps_version(version, path=""): """Translate the LAMMPS version into something that can be used in a comparison""" - items = [x for x in re.split('(\\d+)', version) if x] - if len(items) < 3: - raise ValueError("Version %s does not have (at least) 3 elements" % version) month_map = { "JAN": '01', "FEB": '02', "MAR": '03', "APR": '04', - "MAY": '05', - "JUN": '06', "JUL": '07', "AUG": '08', "SEP": '09', @@ -173,7 +173,28 @@ def translate_lammps_version(version): "NOV": '11', "DEC": '12' } - return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) + # create a function that does the split and returns cur_version + # Than this can simply be tried once if the first one fails than it goes looking in the lammps file + # If I just do a try and except than I also get rit of the stupid len check + # because this one is already not doing a very good check since a previous update of the EasyBlock + items = [x for x in re.split('(\\d+)', version) if x] + if len(items) < 3: + raise ValueError("Version %s does not have (at least) 3 elements" % version) + try: + return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) + except: + # avoid failing miserably under --module-only --force + if os.path.exists(path) and os.listdir(path): + with open("%ssrc/version.h" % (path)) as file: + file_contents = file.read() + lines = re.split('\n', file_contents) + regex = r'\d+ \S+ \d+' + result = re.search(regex, lines[0]) + gen_version = result.group() + items = [x for x in re.split('\s', gen_version) if x] + return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) + else: + raise ValueError("Version %s cannot be generated" % version) class EB_LAMMPS(CMakeMake): @@ -185,13 +206,51 @@ def __init__(self, *args, **kwargs): """LAMMPS easyblock constructor: determine whether we should build with CUDA support enabled.""" super(EB_LAMMPS, self).__init__(*args, **kwargs) + # DEBUG + print("I don't know if this exhists: ", dir(self.start_dir)) + # DEBUG + cuda_dep = 'cuda' in [dep['name'].lower() for dep in self.cfg.dependencies()] cuda_toolchain = hasattr(self.toolchain, 'COMPILER_CUDA_FAMILY') self.cuda = cuda_dep or cuda_toolchain + + def update_kokkos_cpu_mapping(self): + + if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('31Mar2017')): + self.kokkos_cpu_mapping['neoverse_n1'] = 'ARMV81' + self.kokkos_cpu_mapping['neoverse_v1'] = 'ARMV81' + + if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('21sep2021')): + self.kokkos_cpu_mapping['a64fx'] = 'A64FX' + self.kokkos_cpu_mapping['zen4'] = 'ZEN3' + + + @staticmethod + def extra_options(**kwargs): + """Custom easyconfig parameters for LAMMPS""" + extra_vars = CMakeMake.extra_options() + extra_vars.update({ + 'general_packages': [None, "List of general packages (without prefix PKG_).", MANDATORY], + 'kokkos': [True, "Enable kokkos build.", CUSTOM], + 'kokkos_arch': [None, "Set kokkos processor arch manually, if auto-detection doesn't work.", CUSTOM], + 'user_packages': [None, "List user packages (without prefix PKG_ or USER-PKG_).", CUSTOM], + 'sanity_check_test_inputs': [None, "List of tests for sanity-check.", CUSTOM], + }) + extra_vars['separate_build_dir'][0] = True + return extra_vars + + + def prepare_step(self, *args, **kwargs): + """Custom prepare step for LAMMPS.""" + super(EB_LAMMPS, self).prepare_step(*args, **kwargs) + + # DEBUG + print("Is there anything more here in the prepare step: ", self.start_dir) + # version 1.3.2 is used in the test suite to check easyblock can be initialised if self.version != '1.3.2': - self.cur_version = translate_lammps_version(self.version) + self.cur_version = translate_lammps_version(self.version, path=self.start_dir) else: self.cur_version = self.version self.ref_version = translate_lammps_version(ref_version) @@ -211,20 +270,11 @@ def __init__(self, *args, **kwargs): self.kokkos_cpu_mapping = copy.deepcopy(KOKKOS_CPU_MAPPING) self.update_kokkos_cpu_mapping() + # DEBUG - @staticmethod - def extra_options(**kwargs): - """Custom easyconfig parameters for LAMMPS""" - extra_vars = CMakeMake.extra_options() - extra_vars.update({ - 'general_packages': [None, "List of general packages (without prefix PKG_).", MANDATORY], - 'kokkos': [True, "Enable kokkos build.", CUSTOM], - 'kokkos_arch': [None, "Set kokkos processor arch manually, if auto-detection doesn't work.", CUSTOM], - 'user_packages': [None, "List user packages (without prefix PKG_ or USER-PKG_).", CUSTOM], - 'sanity_check_test_inputs': [None, "List of tests for sanity-check.", CUSTOM], - }) - extra_vars['separate_build_dir'][0] = True - return extra_vars + # Unset LIBS when using both KOKKOS and CUDA - it will mix lib paths otherwise + if self.cfg['kokkos'] and self.cuda: + env.unset_env_vars(['LIBS']) def update_kokkos_cpu_mapping(self): @@ -236,17 +286,13 @@ def update_kokkos_cpu_mapping(self): self.kokkos_cpu_mapping['a64fx'] = 'A64FX' self.kokkos_cpu_mapping['zen4'] = 'ZEN3' - def prepare_step(self, *args, **kwargs): - """Custom prepare step for LAMMPS.""" - super(EB_LAMMPS, self).prepare_step(*args, **kwargs) - - # Unset LIBS when using both KOKKOS and CUDA - it will mix lib paths otherwise - if self.cfg['kokkos'] and self.cuda: - env.unset_env_vars(['LIBS']) - def configure_step(self, **kwargs): """Custom configuration procedure for LAMMPS.""" + # DEBUG + print("Is there anything more here in the configure step: ", dir(self)) + # DEBUG + if not get_software_root('VTK'): if self.cfg['user_packages']: self.cfg['user_packages'] = [x for x in self.cfg['user_packages'] if x != 'VTK'] @@ -471,7 +517,7 @@ def install_step(self): mkdir(site_packages, parents=True) - self.lammpsdir = os.path.join(self.builddir, '%s-*_%s' % (self.name.lower(), self.version)) + self.lammpsdir = os.path.join(self.builddir, '%s-*%s' % (self.name.lower(), self.version)) self.python_dir = os.path.join(self.lammpsdir, 'python') # The -i flag is added through a patch to the lammps source file python/install.py @@ -670,3 +716,4 @@ def get_cpu_arch(): if ec: raise EasyBuildError("Failed to determine CPU architecture: %s", out) return out.strip() + From c91686bd9456b9b3c63b8826ee2b7803714e2157 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 15:51:53 +0200 Subject: [PATCH 02/25] generate version from the source files for using software-commit --- easybuild/easyblocks/l/lammps.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 2be7b31f923..d1b418c0cde 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -154,11 +154,6 @@ ref_version = '29Sep2021' -def generate_cur_version(items): - """Generate computer readable version""" - - - def translate_lammps_version(version, path=""): """Translate the LAMMPS version into something that can be used in a comparison""" month_map = { @@ -166,6 +161,8 @@ def translate_lammps_version(version, path=""): "FEB": '02', "MAR": '03', "APR": '04', + "MAY": '05', + "JUN": '06', "JUL": '07', "AUG": '08', "SEP": '09', @@ -173,10 +170,6 @@ def translate_lammps_version(version, path=""): "NOV": '11', "DEC": '12' } - # create a function that does the split and returns cur_version - # Than this can simply be tried once if the first one fails than it goes looking in the lammps file - # If I just do a try and except than I also get rit of the stupid len check - # because this one is already not doing a very good check since a previous update of the EasyBlock items = [x for x in re.split('(\\d+)', version) if x] if len(items) < 3: raise ValueError("Version %s does not have (at least) 3 elements" % version) From 4beab6994a8b4405b344c5dab8dd2b70ddc7d8a7 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 15:58:26 +0200 Subject: [PATCH 03/25] generate version from the source files for using software-commit --- easybuild/easyblocks/l/lammps.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index d1b418c0cde..ced734c60a2 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -199,10 +199,6 @@ def __init__(self, *args, **kwargs): """LAMMPS easyblock constructor: determine whether we should build with CUDA support enabled.""" super(EB_LAMMPS, self).__init__(*args, **kwargs) - # DEBUG - print("I don't know if this exhists: ", dir(self.start_dir)) - # DEBUG - cuda_dep = 'cuda' in [dep['name'].lower() for dep in self.cfg.dependencies()] cuda_toolchain = hasattr(self.toolchain, 'COMPILER_CUDA_FAMILY') self.cuda = cuda_dep or cuda_toolchain @@ -238,9 +234,6 @@ def prepare_step(self, *args, **kwargs): """Custom prepare step for LAMMPS.""" super(EB_LAMMPS, self).prepare_step(*args, **kwargs) - # DEBUG - print("Is there anything more here in the prepare step: ", self.start_dir) - # version 1.3.2 is used in the test suite to check easyblock can be initialised if self.version != '1.3.2': self.cur_version = translate_lammps_version(self.version, path=self.start_dir) @@ -263,7 +256,6 @@ def prepare_step(self, *args, **kwargs): self.kokkos_cpu_mapping = copy.deepcopy(KOKKOS_CPU_MAPPING) self.update_kokkos_cpu_mapping() - # DEBUG # Unset LIBS when using both KOKKOS and CUDA - it will mix lib paths otherwise if self.cfg['kokkos'] and self.cuda: @@ -709,4 +701,3 @@ def get_cpu_arch(): if ec: raise EasyBuildError("Failed to determine CPU architecture: %s", out) return out.strip() - From ab990fb2660787a39dd5713c22aba2aac88cb096 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 16:01:16 +0200 Subject: [PATCH 04/25] generate version from the source files for using software-commit --- easybuild/easyblocks/l/lammps.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index ced734c60a2..c68986220b3 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -261,15 +261,6 @@ def prepare_step(self, *args, **kwargs): if self.cfg['kokkos'] and self.cuda: env.unset_env_vars(['LIBS']) - def update_kokkos_cpu_mapping(self): - - if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('31Mar2017')): - self.kokkos_cpu_mapping['neoverse_n1'] = 'ARMV81' - self.kokkos_cpu_mapping['neoverse_v1'] = 'ARMV81' - - if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('21sep2021')): - self.kokkos_cpu_mapping['a64fx'] = 'A64FX' - self.kokkos_cpu_mapping['zen4'] = 'ZEN3' def configure_step(self, **kwargs): """Custom configuration procedure for LAMMPS.""" From bdf7024614b695d9d4fc987f3698d9f7421e393a Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 16:02:37 +0200 Subject: [PATCH 05/25] generate version from the source files for using software-commit --- easybuild/easyblocks/l/lammps.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index c68986220b3..5b5dc26c63b 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -265,10 +265,6 @@ def prepare_step(self, *args, **kwargs): def configure_step(self, **kwargs): """Custom configuration procedure for LAMMPS.""" - # DEBUG - print("Is there anything more here in the configure step: ", dir(self)) - # DEBUG - if not get_software_root('VTK'): if self.cfg['user_packages']: self.cfg['user_packages'] = [x for x in self.cfg['user_packages'] if x != 'VTK'] From 787b0803710a2d63bd834be80b4d1d4fc0ed75d2 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 16:19:29 +0200 Subject: [PATCH 06/25] generate version from the source files for using software-commit --- easybuild/easyblocks/l/lammps.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 5b5dc26c63b..b8cf7936e0b 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -175,7 +175,7 @@ def translate_lammps_version(version, path=""): raise ValueError("Version %s does not have (at least) 3 elements" % version) try: return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) - except: + except ValueError: # avoid failing miserably under --module-only --force if os.path.exists(path) and os.listdir(path): with open("%ssrc/version.h" % (path)) as file: @@ -184,7 +184,7 @@ def translate_lammps_version(version, path=""): regex = r'\d+ \S+ \d+' result = re.search(regex, lines[0]) gen_version = result.group() - items = [x for x in re.split('\s', gen_version) if x] + items = [x for x in re.split('(\\s)', gen_version) if x] return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) else: raise ValueError("Version %s cannot be generated" % version) @@ -203,9 +203,8 @@ def __init__(self, *args, **kwargs): cuda_toolchain = hasattr(self.toolchain, 'COMPILER_CUDA_FAMILY') self.cuda = cuda_dep or cuda_toolchain - def update_kokkos_cpu_mapping(self): - + """Add new kokkos_cpu_mapping to the list based on in which version they were added to LAMMPS""" if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('31Mar2017')): self.kokkos_cpu_mapping['neoverse_n1'] = 'ARMV81' self.kokkos_cpu_mapping['neoverse_v1'] = 'ARMV81' @@ -214,7 +213,6 @@ def update_kokkos_cpu_mapping(self): self.kokkos_cpu_mapping['a64fx'] = 'A64FX' self.kokkos_cpu_mapping['zen4'] = 'ZEN3' - @staticmethod def extra_options(**kwargs): """Custom easyconfig parameters for LAMMPS""" @@ -229,7 +227,6 @@ def extra_options(**kwargs): extra_vars['separate_build_dir'][0] = True return extra_vars - def prepare_step(self, *args, **kwargs): """Custom prepare step for LAMMPS.""" super(EB_LAMMPS, self).prepare_step(*args, **kwargs) @@ -261,7 +258,6 @@ def prepare_step(self, *args, **kwargs): if self.cfg['kokkos'] and self.cuda: env.unset_env_vars(['LIBS']) - def configure_step(self, **kwargs): """Custom configuration procedure for LAMMPS.""" From c60c7c824468aab2d0255521db1813e4ba62c845 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 16:58:36 +0200 Subject: [PATCH 07/25] fix exception --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index b8cf7936e0b..77fbcd94253 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -175,7 +175,7 @@ def translate_lammps_version(version, path=""): raise ValueError("Version %s does not have (at least) 3 elements" % version) try: return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) - except ValueError: + except KeyError: # avoid failing miserably under --module-only --force if os.path.exists(path) and os.listdir(path): with open("%ssrc/version.h" % (path)) as file: From 3d295a926318468e3e8fdd99fdcfea02cd796403 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 14 Oct 2024 17:53:15 +0200 Subject: [PATCH 08/25] fix re.split by space --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 77fbcd94253..0ba77a55031 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -184,7 +184,7 @@ def translate_lammps_version(version, path=""): regex = r'\d+ \S+ \d+' result = re.search(regex, lines[0]) gen_version = result.group() - items = [x for x in re.split('(\\s)', gen_version) if x] + items = [x for x in re.split(' ', gen_version) if x] return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) else: raise ValueError("Version %s cannot be generated" % version) From 1b45d17edcc4eba4f7acd2fb3a83e45315bcb83c Mon Sep 17 00:00:00 2001 From: lara Date: Fri, 31 Jan 2025 18:32:47 +0100 Subject: [PATCH 09/25] Fix using --module-only when using different software-commit --- easybuild/easyblocks/l/lammps.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 32d910092e2..a75a5337050 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -43,7 +43,7 @@ from easybuild.framework.easyconfig import CUSTOM, MANDATORY from easybuild.tools.build_log import EasyBuildError, print_warning, print_msg from easybuild.tools.config import build_option -from easybuild.tools.filetools import copy_dir, mkdir +from easybuild.tools.filetools import copy_dir, mkdir, copy_file from easybuild.tools.modules import get_software_root, get_software_version from easybuild.tools.run import run_cmd from easybuild.tools.systemtools import AARCH64, get_cpu_architecture, get_shared_lib_ext @@ -242,7 +242,10 @@ def prepare_step(self, *args, **kwargs): # version 1.3.2 is used in the test suite to check easyblock can be initialised if self.version != '1.3.2': - self.cur_version = translate_lammps_version(self.version, path=self.start_dir) + if os.path.exists(self.start_dir) and os.listdir(self.start_dir): + self.cur_version = translate_lammps_version(self.version, path=self.start_dir) + else: + self.cur_version = translate_lammps_version(self.version, path=self.installdir+'/') else: self.cur_version = self.version self.ref_version = translate_lammps_version(ref_version) @@ -478,6 +481,11 @@ def configure_step(self, **kwargs): def install_step(self): """Install LAMMPS and examples/potentials.""" super(EB_LAMMPS, self).install_step() + # Copy LICENCE and version file so these can be used with `--module-only` + version_file = os.path.join(self.start_dir, 'src/version.h') + copy_file(version_file, os.path.join(self.installdir, 'src/version.h')) + license_file = os.path.join(self.start_dir, 'LICENSE') + copy_file(license_file, os.path.join(self.installdir, 'LICENSE')) # Copy over the examples so we can repeat the sanity check # (some symlinks may be broken) examples_dir = os.path.join(self.start_dir, 'examples') @@ -556,6 +564,8 @@ def sanity_check_step(self, *args, **kwargs): shlib_ext = get_shared_lib_ext() custom_paths = { 'files': [ + os.path.join('src', 'version.h'), + 'LICENSE', os.path.join('bin', 'lmp'), os.path.join('include', 'lammps', 'library.h'), os.path.join('lib', 'liblammps.%s' % shlib_ext), From ac72ee8cd3c98f1ddf470f8820279660f4845664 Mon Sep 17 00:00:00 2001 From: lara Date: Fri, 31 Jan 2025 18:36:41 +0100 Subject: [PATCH 10/25] make CI happy --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index a75a5337050..5b845a9b949 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -242,7 +242,7 @@ def prepare_step(self, *args, **kwargs): # version 1.3.2 is used in the test suite to check easyblock can be initialised if self.version != '1.3.2': - if os.path.exists(self.start_dir) and os.listdir(self.start_dir): + if os.path.exists(self.start_dir) and os.listdir(self.start_dir): self.cur_version = translate_lammps_version(self.version, path=self.start_dir) else: self.cur_version = translate_lammps_version(self.version, path=self.installdir+'/') From 2cf92b65a35fdea8a924bb85edc2abe65a96a81f Mon Sep 17 00:00:00 2001 From: Lara Ramona Peeters <49882639+laraPPr@users.noreply.github.com> Date: Mon, 3 Feb 2025 12:04:41 +0100 Subject: [PATCH 11/25] Update easybuild/easyblocks/l/lammps.py Co-authored-by: ocaisa --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 5b845a9b949..123a1bdda93 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -183,7 +183,7 @@ def translate_lammps_version(version, path=""): except KeyError: # avoid failing miserably under --module-only --force if os.path.exists(path) and os.listdir(path): - with open("%ssrc/version.h" % (path)) as file: + with open(os.path.join(path, 'src', 'version.h')) as file: file_contents = file.read() lines = re.split('\n', file_contents) regex = r'\d+ \S+ \d+' From 66f5f23d10106cb95d4ec4c8e0910df8a6230eaa Mon Sep 17 00:00:00 2001 From: Lara Ramona Peeters <49882639+laraPPr@users.noreply.github.com> Date: Mon, 3 Feb 2025 12:05:59 +0100 Subject: [PATCH 12/25] Update easybuild/easyblocks/l/lammps.py Co-authored-by: ocaisa --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 123a1bdda93..84122adb3d0 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -245,7 +245,7 @@ def prepare_step(self, *args, **kwargs): if os.path.exists(self.start_dir) and os.listdir(self.start_dir): self.cur_version = translate_lammps_version(self.version, path=self.start_dir) else: - self.cur_version = translate_lammps_version(self.version, path=self.installdir+'/') + self.cur_version = translate_lammps_version(self.version, path=self.installdir) else: self.cur_version = self.version self.ref_version = translate_lammps_version(ref_version) From c76d00698a2905514406ca94b6ee30d890a1ae84 Mon Sep 17 00:00:00 2001 From: Lara Ramona Peeters <49882639+laraPPr@users.noreply.github.com> Date: Mon, 3 Feb 2025 12:06:19 +0100 Subject: [PATCH 13/25] Update easybuild/easyblocks/l/lammps.py Co-authored-by: ocaisa --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 84122adb3d0..4694fd84b70 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -483,7 +483,7 @@ def install_step(self): super(EB_LAMMPS, self).install_step() # Copy LICENCE and version file so these can be used with `--module-only` version_file = os.path.join(self.start_dir, 'src/version.h') - copy_file(version_file, os.path.join(self.installdir, 'src/version.h')) + copy_file(version_file, os.path.join(self.installdir, 'src', 'version.h')) license_file = os.path.join(self.start_dir, 'LICENSE') copy_file(license_file, os.path.join(self.installdir, 'LICENSE')) # Copy over the examples so we can repeat the sanity check From 3725813434972232adde2d84c882801fae629ddf Mon Sep 17 00:00:00 2001 From: Lara Ramona Peeters <49882639+laraPPr@users.noreply.github.com> Date: Mon, 3 Feb 2025 12:06:34 +0100 Subject: [PATCH 14/25] Update easybuild/easyblocks/l/lammps.py Co-authored-by: ocaisa --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 4694fd84b70..2fbc8a3653e 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -482,7 +482,7 @@ def install_step(self): """Install LAMMPS and examples/potentials.""" super(EB_LAMMPS, self).install_step() # Copy LICENCE and version file so these can be used with `--module-only` - version_file = os.path.join(self.start_dir, 'src/version.h') + version_file = os.path.join(self.start_dir, 'src', 'version.h') copy_file(version_file, os.path.join(self.installdir, 'src', 'version.h')) license_file = os.path.join(self.start_dir, 'LICENSE') copy_file(license_file, os.path.join(self.installdir, 'LICENSE')) From fcd111e06ce6d3eff3c1059cac99d2606fe1746e Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 5 Feb 2025 10:28:17 +0100 Subject: [PATCH 15/25] small tweaks to LAMMPS easyblock, mostly code cleanup --- easybuild/easyblocks/l/lammps.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 2fbc8a3653e..6310e32f8aa 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -43,7 +43,7 @@ from easybuild.framework.easyconfig import CUSTOM, MANDATORY from easybuild.tools.build_log import EasyBuildError, print_warning, print_msg from easybuild.tools.config import build_option -from easybuild.tools.filetools import copy_dir, mkdir, copy_file +from easybuild.tools.filetools import copy_dir, copy_file, mkdir, read_file from easybuild.tools.modules import get_software_root, get_software_version from easybuild.tools.run import run_cmd from easybuild.tools.systemtools import AARCH64, get_cpu_architecture, get_shared_lib_ext @@ -183,14 +183,13 @@ def translate_lammps_version(version, path=""): except KeyError: # avoid failing miserably under --module-only --force if os.path.exists(path) and os.listdir(path): - with open(os.path.join(path, 'src', 'version.h')) as file: - file_contents = file.read() - lines = re.split('\n', file_contents) - regex = r'\d+ \S+ \d+' - result = re.search(regex, lines[0]) - gen_version = result.group() - items = [x for x in re.split(' ', gen_version) if x] - return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) + txt = read_file(os.path.join(path, 'src', 'version.h')) + result = re.search(r'(?<=LAMMPS_VERSION ")\d+ \S+ \d+', txt) + if result: + day, month, year = result.group().split(' ') + else: + raise EasyBuildError("Failed to parse LAMMPS version: '%s'", txt) + return '.'.join([year, month_map[month.upper()], '%02d' % int(day)]) else: raise ValueError("Version %s cannot be generated" % version) @@ -242,6 +241,7 @@ def prepare_step(self, *args, **kwargs): # version 1.3.2 is used in the test suite to check easyblock can be initialised if self.version != '1.3.2': + # take into account that build directory may not be available (in case of --module-only) if os.path.exists(self.start_dir) and os.listdir(self.start_dir): self.cur_version = translate_lammps_version(self.version, path=self.start_dir) else: From 1c0d6e23bf624c3d971e5a56df54d5b43f89c3b0 Mon Sep 17 00:00:00 2001 From: Sam Moors Date: Sat, 8 Feb 2025 12:47:28 +0100 Subject: [PATCH 16/25] remove version from lammpsdir --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 6310e32f8aa..b488048aac6 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -502,7 +502,7 @@ def install_step(self): mkdir(site_packages, parents=True) - self.lammpsdir = os.path.join(self.builddir, '%s-*%s' % (self.name.lower(), self.version)) + self.lammpsdir = os.path.join(self.builddir, '%s-*' % self.name.lower()) self.python_dir = os.path.join(self.lammpsdir, 'python') # The -i flag is added through a patch to the lammps source file python/install.py From 3ac58fd91055839295d99cb7e42db5e362ba91ad Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 3 Mar 2025 15:16:55 +0100 Subject: [PATCH 17/25] fix --sanity-check-only --- easybuild/easyblocks/l/lammps.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index b488048aac6..fab3ce6c2c4 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -522,6 +522,12 @@ def install_step(self): def sanity_check_step(self, *args, **kwargs): """Run custom sanity checks for LAMMPS files, dirs and commands.""" + # Set cur_version when running --sanity-check-only + try: + self.cur_version + except: + self.cur_version = translate_lammps_version(self.version, path=self.installdir) + # Output files need to go somewhere (and has to work for --module-only as well) execution_dir = tempfile.mkdtemp() From 9f3996a2ede6014495ccac7a428da0e9f4640464 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 3 Mar 2025 15:19:15 +0100 Subject: [PATCH 18/25] make the hound happy --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index fab3ce6c2c4..d6af0bd10b0 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -522,7 +522,7 @@ def install_step(self): def sanity_check_step(self, *args, **kwargs): """Run custom sanity checks for LAMMPS files, dirs and commands.""" - # Set cur_version when running --sanity-check-only + # Set cur_version when running --sanity-check-only try: self.cur_version except: From 292c98c94d460d81eb95bbdbf987cb377556d3c1 Mon Sep 17 00:00:00 2001 From: lara Date: Mon, 3 Mar 2025 15:23:39 +0100 Subject: [PATCH 19/25] make the hound even happier --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index d6af0bd10b0..65d6661887b 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -525,7 +525,7 @@ def sanity_check_step(self, *args, **kwargs): # Set cur_version when running --sanity-check-only try: self.cur_version - except: + except Exception: self.cur_version = translate_lammps_version(self.version, path=self.installdir) # Output files need to go somewhere (and has to work for --module-only as well) From 79ac0dbe0e7b55d3b30ba001296b0a36c3d4b4dd Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 May 2025 10:30:15 +0200 Subject: [PATCH 20/25] tweak translate_lammps_version --- easybuild/easyblocks/l/lammps.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 0e3b8cb9e8d..f40d249aa82 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -159,7 +159,7 @@ _log = fancylogger.getLogger('easyblocks.lammps') -def translate_lammps_version(version, path=""): +def translate_lammps_version(version, path=None): """Translate the LAMMPS version into something that can be used in a comparison""" month_map = { "JAN": '01', @@ -178,20 +178,25 @@ def translate_lammps_version(version, path=""): items = [x for x in re.split('(\\d+)', version) if x] if len(items) < 3: raise ValueError("Version %s does not have (at least) 3 elements" % version) + try: return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) except KeyError: # avoid failing miserably under --module-only --force - if os.path.exists(path) and os.listdir(path): - txt = read_file(os.path.join(path, 'src', 'version.h')) - result = re.search(r'(?<=LAMMPS_VERSION ")\d+ \S+ \d+', txt) - if result: - day, month, year = result.group().split(' ') + if path and os.path.exists(path) and os.listdir(path): + version_file = os.path.join(path, 'src', 'version.h') + if os.path.exists(version_file): + txt = read_file(os.path.join(path, 'src', 'version.h')) + result = re.search(r'(?<=LAMMPS_VERSION ")\d+ \S+ \d+', txt) + if result: + day, month, year = result.group().split(' ') + else: + raise EasyBuildError(f"Failed to parse LAMMPS version: '{txt}'") + return '.'.join([year, month_map[month.upper()], '%02d' % int(day)]) else: - raise EasyBuildError("Failed to parse LAMMPS version: '%s'", txt) - return '.'.join([year, month_map[month.upper()], '%02d' % int(day)]) + raise EasyBuildError(f"Expected to find version file at {version_file}, but it doesn't exist") else: - raise ValueError("Version %s cannot be generated" % version) + raise ValueError("LAMMPS version {version} cannot be translated") class EB_LAMMPS(CMakeMake): From 400e5343f17d62d253ccb1f3a2da77b9aa41c02c Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 May 2025 10:32:08 +0200 Subject: [PATCH 21/25] fix check whether cur_version is set in LAMMPS sanity check step --- easybuild/easyblocks/l/lammps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index f40d249aa82..b871bc5b4ac 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -212,6 +212,8 @@ def __init__(self, *args, **kwargs): cuda_toolchain = hasattr(self.toolchain, 'COMPILER_CUDA_FAMILY') self.cuda = cuda_dep or cuda_toolchain + self.cur_version = None + def update_kokkos_cpu_mapping(self): """Add new kokkos_cpu_mapping to the list based on in which version they were added to LAMMPS""" if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('31Mar2017')): @@ -560,9 +562,7 @@ def sanity_check_step(self, *args, **kwargs): """Run custom sanity checks for LAMMPS files, dirs and commands.""" # Set cur_version when running --sanity-check-only - try: - self.cur_version - except Exception: + if self.cur_version is None: self.cur_version = translate_lammps_version(self.version, path=self.installdir) # Output files need to go somewhere (and has to work for --module-only as well) From 5290d433e14beb7e49737cc3d414173293fbb8f0 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 May 2025 10:36:37 +0200 Subject: [PATCH 22/25] remove duplicate extra_options in LAMMPS easyblock --- easybuild/easyblocks/l/lammps.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index b871bc5b4ac..7a0fd7b152d 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -273,22 +273,10 @@ def prepare_step(self, *args, **kwargs): self.kokkos_cpu_mapping = copy.deepcopy(KOKKOS_CPU_MAPPING) self.update_kokkos_cpu_mapping() - @staticmethod - def extra_options(**kwargs): - """Custom easyconfig parameters for LAMMPS""" - extra_vars = CMakeMake.extra_options() - extra_vars.update({ - 'general_packages': [None, "List of general packages (without prefix PKG_).", MANDATORY], - 'kokkos': [True, "Enable kokkos build.", CUSTOM], - 'kokkos_arch': [None, "Set kokkos processor arch manually, if auto-detection doesn't work.", CUSTOM], - 'user_packages': [None, "List user packages (without prefix PKG_ or USER-PKG_).", CUSTOM], - 'sanity_check_test_inputs': [None, "List of tests for sanity-check.", CUSTOM], - }) - extra_vars['separate_build_dir'][0] = True - return extra_vars - def update_kokkos_cpu_mapping(self): - + """ + Update mapping to Kokkos CPU targets based on LAMMPS version + """ if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('31Mar2017')): self.kokkos_cpu_mapping['neoverse_n1'] = 'ARMV81' self.kokkos_cpu_mapping['neoverse_v1'] = 'ARMV81' @@ -520,17 +508,20 @@ def configure_step(self, **kwargs): def install_step(self): """Install LAMMPS and examples/potentials.""" super().install_step() - # Copy LICENCE and version file so these can be used with `--module-only` + + # Copy LICENSE and version file so these can be used with `--module-only` version_file = os.path.join(self.start_dir, 'src', 'version.h') copy_file(version_file, os.path.join(self.installdir, 'src', 'version.h')) license_file = os.path.join(self.start_dir, 'LICENSE') copy_file(license_file, os.path.join(self.installdir, 'LICENSE')) + # Copy over the examples so we can repeat the sanity check # (some symlinks may be broken) examples_dir = os.path.join(self.start_dir, 'examples') copy_dir(examples_dir, os.path.join(self.installdir, 'examples'), symlinks=True) potentials_dir = os.path.join(self.start_dir, 'potentials') copy_dir(potentials_dir, os.path.join(self.installdir, 'potentials')) + if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('2Aug2023')): # From ver 2Aug2023: # "make install in a CMake based installation will no longer install @@ -607,11 +598,11 @@ def sanity_check_step(self, *args, **kwargs): shlib_ext = get_shared_lib_ext() custom_paths = { 'files': [ - os.path.join('src', 'version.h'), 'LICENSE', os.path.join('bin', 'lmp'), os.path.join('include', 'lammps', 'library.h'), os.path.join('lib', 'liblammps.%s' % shlib_ext), + os.path.join('src', 'version.h'), ], 'dirs': [], } From e92475b5cf490aaf3fb13f16c535eb1a658b9f04 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 May 2025 10:47:09 +0200 Subject: [PATCH 23/25] don't check for LICENSE + version.h in sanity check for LAMMPS, since installation isn't broken without them --- easybuild/easyblocks/l/lammps.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 7a0fd7b152d..240a1e83cf1 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -598,11 +598,9 @@ def sanity_check_step(self, *args, **kwargs): shlib_ext = get_shared_lib_ext() custom_paths = { 'files': [ - 'LICENSE', os.path.join('bin', 'lmp'), os.path.join('include', 'lammps', 'library.h'), os.path.join('lib', 'liblammps.%s' % shlib_ext), - os.path.join('src', 'version.h'), ], 'dirs': [], } From 9448184aa79cd3c42ffb1bfbeccbec8af958d8ba Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 May 2025 10:52:12 +0200 Subject: [PATCH 24/25] fix prepare step in LAMMPS easyblock --- easybuild/easyblocks/l/lammps.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 240a1e83cf1..ec02a7d154c 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -244,7 +244,7 @@ def extra_options(**kwargs): def prepare_step(self, *args, **kwargs): """Custom prepare step for LAMMPS.""" - super(EB_LAMMPS, self).prepare_step(*args, **kwargs) + super().prepare_step(*args, **kwargs) # version 1.3.2 is used in the test suite to check easyblock can be initialised if self.version != '1.3.2': @@ -273,6 +273,10 @@ def prepare_step(self, *args, **kwargs): self.kokkos_cpu_mapping = copy.deepcopy(KOKKOS_CPU_MAPPING) self.update_kokkos_cpu_mapping() + # Unset LIBS when using both KOKKOS and CUDA - it will mix lib paths otherwise + if self.cfg['kokkos'] and self.cuda: + env.unset_env_vars(['LIBS']) + def update_kokkos_cpu_mapping(self): """ Update mapping to Kokkos CPU targets based on LAMMPS version @@ -289,14 +293,6 @@ def update_kokkos_cpu_mapping(self): self.kokkos_cpu_mapping['icelake'] = 'ICX' self.kokkos_cpu_mapping['sapphirerapids'] = 'SPR' - def prepare_step(self, *args, **kwargs): - """Custom prepare step for LAMMPS.""" - super().prepare_step(*args, **kwargs) - - # Unset LIBS when using both KOKKOS and CUDA - it will mix lib paths otherwise - if self.cfg['kokkos'] and self.cuda: - env.unset_env_vars(['LIBS']) - def configure_step(self, **kwargs): """Custom configuration procedure for LAMMPS.""" From 4a266914e10e7ff6d1f7f897fdeec3e377a1da00 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 24 May 2025 11:20:14 +0200 Subject: [PATCH 25/25] remove duplicate update_kokkos_cpu_mapping in LAMMPS easyblock + add test for translate_lammps_version function --- easybuild/easyblocks/l/lammps.py | 24 ++++-------------------- test/easyblocks/easyblock_specific.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index ec02a7d154c..b47dbd4f040 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -176,12 +176,10 @@ def translate_lammps_version(version, path=None): "DEC": '12' } items = [x for x in re.split('(\\d+)', version) if x] - if len(items) < 3: - raise ValueError("Version %s does not have (at least) 3 elements" % version) try: return '.'.join([items[2], month_map[items[1].upper()], '%02d' % int(items[0])]) - except KeyError: + except (IndexError, KeyError): # avoid failing miserably under --module-only --force if path and os.path.exists(path) and os.listdir(path): version_file = os.path.join(path, 'src', 'version.h') @@ -215,7 +213,9 @@ def __init__(self, *args, **kwargs): self.cur_version = None def update_kokkos_cpu_mapping(self): - """Add new kokkos_cpu_mapping to the list based on in which version they were added to LAMMPS""" + """ + Update mapping to Kokkos CPU targets based on LAMMPS version + """ if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('31Mar2017')): self.kokkos_cpu_mapping['neoverse_n1'] = 'ARMV81' self.kokkos_cpu_mapping['neoverse_v1'] = 'ARMV81' @@ -277,22 +277,6 @@ def prepare_step(self, *args, **kwargs): if self.cfg['kokkos'] and self.cuda: env.unset_env_vars(['LIBS']) - def update_kokkos_cpu_mapping(self): - """ - Update mapping to Kokkos CPU targets based on LAMMPS version - """ - if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('31Mar2017')): - self.kokkos_cpu_mapping['neoverse_n1'] = 'ARMV81' - self.kokkos_cpu_mapping['neoverse_v1'] = 'ARMV81' - - if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('21sep2021')): - self.kokkos_cpu_mapping['a64fx'] = 'A64FX' - self.kokkos_cpu_mapping['zen4'] = 'ZEN3' - - if LooseVersion(self.cur_version) >= LooseVersion(translate_lammps_version('2Aug2023')): - self.kokkos_cpu_mapping['icelake'] = 'ICX' - self.kokkos_cpu_mapping['sapphirerapids'] = 'SPR' - def configure_step(self, **kwargs): """Custom configuration procedure for LAMMPS.""" diff --git a/test/easyblocks/easyblock_specific.py b/test/easyblocks/easyblock_specific.py index f3cabe926da..1df35a02a37 100644 --- a/test/easyblocks/easyblock_specific.py +++ b/test/easyblocks/easyblock_specific.py @@ -40,6 +40,7 @@ import easybuild.tools.options as eboptions import easybuild.easyblocks.generic.pythonpackage as pythonpackage +import easybuild.easyblocks.l.lammps as lammps import easybuild.easyblocks.p.python as python from easybuild.base.testing import TestCase from easybuild.easyblocks.generic.cmakemake import det_cmake_version @@ -463,6 +464,28 @@ def test_symlink_dist_site_packages(self): self.assertTrue(os.path.isdir(lib64_site_path)) self.assertFalse(os.path.islink(lib64_site_path)) + def test_translate_lammps_version(self): + """Test translate_lammps_version function from LAMMPS easyblock""" + lammps_versions = { + '23Jun2022': '2022.06.23', + '2Aug2023_update2': '2023.08.02', + '29Aug2024': '2024.08.29', + '29Aug2024_update2': '2024.08.29', + '28Oct2024': '2024.10.28', + } + for key in lammps_versions: + self.assertEqual(lammps.translate_lammps_version(key), lammps_versions[key]) + + version_file = os.path.join(self.tmpdir, 'src', 'version.h') + version_txt = '\n'.join([ + '#define LAMMPS_VERSION "2 Apr 2025"', + '#define LAMMPS_UPDATE "Development"', + ]) + write_file(version_file, version_txt) + + self.assertEqual(lammps.translate_lammps_version('d3adb33f', path=self.tmpdir), '2025.04.02') + self.assertEqual(lammps.translate_lammps_version('devel', path=self.tmpdir), '2025.04.02') + def suite(): """Return all easyblock-specific tests."""