Skip to content

Commit

Permalink
Provide correct Python include folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ocaisa authored Jul 22, 2022
1 parent f5a9c29 commit 616caf7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion easybuild/easyblocks/l/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ def configure_step(self, **kwargs):
python_lib_path = glob.glob(os.path.join(python_dir, 'lib*', python_lib.strip()))[0]
if not python_lib_path:
raise EasyBuildError("Could not find path to Python .so library: %s", python_lib)
# and the path to the Python include folder
cmd = 'python -c "import sysconfig; print(sysconfig.get_config_var(\'INCLUDEPY\'))"'
(python_include_dir, _) = run_cmd(cmd, log_all=True, simple=False, trace=False)
if not python_include_dir:
raise EasyBuildError("Failed to determine Python include dir: %s", python_include_dir)
python_include_dir = python_include_dir.strip()

# Whether you need one or the other of the options below depends on the version of CMake and LAMMPS
# Rather than figure this out, use both (and one will be ignored)
Expand All @@ -404,7 +410,7 @@ def configure_step(self, **kwargs):

# Older LAMMPS need more hints to get things right as they use deprecated CMake packages
self.cfg.update('configopts', '-DPYTHON_LIBRARY=%s' % python_lib_path)
self.cfg.update('configopts', '-DPYTHON_INCLUDE_DIR=%s/include' % python_dir)
self.cfg.update('configopts', '-DPYTHON_INCLUDE_DIR=%s' % python_include_dir)
else:
raise EasyBuildError("Expected to find a Python dependency as sanity check commands rely on it!")

Expand Down

0 comments on commit 616caf7

Please sign in to comment.