From 7cd8bae799413bedeb91b39aa06e8ac80cfda3e4 Mon Sep 17 00:00:00 2001 From: Tom Payerle Date: Tue, 4 Jan 2022 03:04:46 -0500 Subject: [PATCH] namd: Fix issue when building with interface=python ^python@3.8 (#28218) Patch to add --embed flag to config-python when interface=python and using python@3.8: This is because python@3.8 changed behavior of python-config --ldflags (and --libs) such that it no longer includes -lpython unless --embed flag is used. See e.g. https://github.com/mesonbuild/meson/issues/5629 --- .../builtin/packages/namd/namd-python38.patch | 17 +++++++++++++++++ .../repos/builtin/packages/namd/package.py | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 var/spack/repos/builtin/packages/namd/namd-python38.patch diff --git a/var/spack/repos/builtin/packages/namd/namd-python38.patch b/var/spack/repos/builtin/packages/namd/namd-python38.patch new file mode 100644 index 0000000000..7e5f9e48af --- /dev/null +++ b/var/spack/repos/builtin/packages/namd/namd-python38.patch @@ -0,0 +1,17 @@ +diff -Naur spack-src/config spack-src.patched/config +--- spack-src/config 2020-08-05 13:51:21.000000000 -0400 ++++ spack-src.patched/config 2021-12-30 17:59:44.574264378 -0500 +@@ -501,7 +501,12 @@ + echo "Using $PYTHON_CONFIG to configure Python." + PYTHON_PREFIX=$($PYTHON_CONFIG --prefix) + PYTHON_INCFLAGS=$($PYTHON_CONFIG --includes) +- PYTHON_LDFLAGS=$($PYTHON_CONFIG --ldflags) ++ # Payerle 2021-12-30: python@3.8 python-config omits -lpython unless --embed given ++ # Try first with embed, and if fails, try w/out embed ++ PYTHON_LDFLAGS=$($PYTHON_CONFIG --ldflags --embed) ++ if echo "$PYTHON_LDFLAGS" | grep -q '^Usage'; then ++ PYTHON_LDFLAGS=$($PYTHON_CONFIG --ldflags) ++ fi + if ! echo "$PYTHON_LDFLAGS" | grep -q -- '-L'; then + echo "$PYTHON_CONFIG did not return a -L flag: using Anaconda?" + if [ -d "$PYTHON_PREFIX/lib" ]; then diff --git a/var/spack/repos/builtin/packages/namd/package.py b/var/spack/repos/builtin/packages/namd/package.py index 9e930b2459..c6c974f4eb 100644 --- a/var/spack/repos/builtin/packages/namd/package.py +++ b/var/spack/repos/builtin/packages/namd/package.py @@ -39,6 +39,8 @@ class Namd(MakefilePackage, CudaPackage): # allowed patch('inherited-member-2.13.patch', when='@2.13') patch('inherited-member-2.14.patch', when='@2.14') + # Handle change in python-config for python@3.8: + patch('namd-python38.patch', when='interface=python ^python@3.8:') depends_on('charmpp@6.10.1:', when="@2.14:") depends_on('charmpp@6.8.2', when="@2.13")