1
0

4 Commits

3 changed files with 326 additions and 22 deletions

261
espresso-cython.patch Normal file
View File

@@ -0,0 +1,261 @@
diff --git a/src/config/gen_featureconfig.py b/src/config/gen_featureconfig.py
index 59cf81068d..b8d713e947 100644
--- a/src/config/gen_featureconfig.py
+++ b/src/config/gen_featureconfig.py
@@ -1,3 +1,4 @@
+#
# Copyright (C) 2013-2022 The ESPResSo project
# Copyright (C) 2012 Olaf Lenz
#
@@ -16,9 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# This script generates the files featureconfig.h and featureconfig.c.
-#
-import time
+
import string
import inspect
import sys
@@ -32,67 +31,78 @@ if len(sys.argv) != 4:
print(f"Usage: {sys.argv[0]} DEFFILE HPPFILE CPPFILE", file=sys.stderr)
exit(2)
-deffilename, hfilename, cfilename = sys.argv[1:5]
-
-print("Reading definitions from " + deffilename + "...")
-defs = featuredefs.defs(deffilename)
-print("Done.")
-
-print("Writing " + hfilename + "...")
-hfile = open(hfilename, 'w')
-
-hfile.write("""/*
-WARNING: This file was autogenerated by
+path_def, path_hpp, path_cpp = sys.argv[1:5]
- %s on %s
+print(f"Reading definitions from {path_def}")
+defs = featuredefs.defs(path_def)
- Do not modify it or your changes will be overwritten!
- Modify features.def instead.
+disclaimer = f"""/*
+ WARNING: This file was generated automatically.
+ Do not modify it or your changes will be overwritten!
+ Modify features.def instead.
*/
-#ifndef ESPRESSO_FEATURECONFIG_HPP
-#define ESPRESSO_FEATURECONFIG_HPP
-
-#include "cmake_config.hpp"
-#include "myconfig-final.hpp"
+"""
-""" % (sys.argv[0], time.asctime()))
+print(f"Writing {path_hpp}")
+hfile = open(path_hpp, 'w')
+hfile.write(disclaimer)
+hfile.write("""
+#ifndef ESPRESSO_SRC_CONFIG_CONFIG_FEATURES_HPP
+#define ESPRESSO_SRC_CONFIG_CONFIG_FEATURES_HPP
+""")
# external features can only be set by the build
# system, so in case the user has defined some of
# them, we undef all external features and include
# the config from the build system again, to make
# sure only the detected ones are set.
-hfile.write('/* Guards for externals */')
+hfile.write("""
+/*********************************/
+/* Handle definitions from CMake */
+/*********************************/
+
+#include "cmake_config.hpp"
+#include "myconfig-final.hpp"
+""")
external_template = string.Template("""
// $feature is external
#if defined($feature)
#undef $feature
#endif
""")
-for feature in defs.externals:
+for feature in sorted(defs.externals):
hfile.write(external_template.substitute(feature=feature))
# Include definitions from CMake
hfile.write("""
-/* Definitions from CMake */
#include "cmake_config.hpp"
""")
# handle implications
-hfile.write('/* Handle implications */')
+hfile.write("""\
+/***********************/
+/* Handle implications */
+/***********************/
+""")
implication_template = string.Template("""
// $feature implies $implied
#if defined($feature) && !defined($implied)
#define $implied
#endif
""")
-for feature, implied in defs.implications:
+for feature, implied in sorted(defs.implications):
hfile.write(implication_template.substitute(
feature=feature, implied=implied))
+hfile.write("\n")
+
# output warnings if internal features are set manually
-hfile.write('/* Warn when derived switches are specified manually */')
+hfile.write("""\
+/*****************************************************/
+/* Warn when derived switches are specified manually */
+/*****************************************************/
+""")
derivation_template = string.Template("""
// $feature equals $expr
#ifdef $feature
@@ -101,58 +111,52 @@ derivation_template = string.Template("""
#define $feature
#endif
""")
-for feature, expr, cppexpr in defs.derivations:
+for feature, expr, cppexpr in sorted(defs.derivations):
hfile.write(derivation_template.substitute(
feature=feature, cppexpr=cppexpr, expr=expr))
-# write footer
-# define external FEATURES and NUM_FEATURES
hfile.write("""
-extern const char* FEATURES[];
-extern const int NUM_FEATURES;
-#endif /* of _FEATURECONFIG_HPP */""")
-hfile.close()
-print("Done.")
+extern char const *const FEATURES[];
+extern char const *const FEATURES_ALL[];
+extern unsigned int const NUM_FEATURES;
+extern unsigned int const NUM_FEATURES_ALL;
-print("Writing " + cfilename + "...")
-cfile = open(cfilename, 'w')
-
-# handle requirements
-
-cfile.write(f"""/*
-WARNING: This file was autogenerated by
+#endif
+""")
- {sys.argv[0]}
- on
- {time.asctime()}
+hfile.close()
- Do not modify it or your changes will be overwritten!
- Modify features.def instead.
-*/
+print(f"Writing {path_cpp}")
+cfile = open(path_cpp, "w")
-/* config.hpp includes config-features.hpp and myconfig.hpp */
+cfile.write(disclaimer)
+cfile.write(f"""
+#include "config-features.hpp"
#include "config.hpp"
+/***********************/
+/* Handle requirements */
+/***********************/
""")
-cfile.write('/* Handle requirements */')
-
requirement_string = """
// {feature} requires {expr}
#if defined({feature}) && !({cppexpr})
#error Feature {feature} requires {expr}
#endif
"""
-for feature, expr, cppexpr in defs.requirements:
+for feature, expr, cppexpr in sorted(defs.requirements):
cfile.write(
requirement_string.format(
feature=feature, cppexpr=cppexpr, expr=expr))
cfile.write("""
-
+/****************/
/* Feature list */
-const char* FEATURES[] = {
+/****************/
+
+char const *const FEATURES[] = {
""")
feature_string = """
@@ -161,14 +165,31 @@ feature_string = """
#endif
"""
-for feature in defs.externals.union(defs.features, defs.derived):
+for feature in sorted(defs.externals.union(defs.features, defs.derived)):
cfile.write(feature_string.format(feature=feature))
cfile.write("""
};
+unsigned int const NUM_FEATURES = sizeof(FEATURES) / sizeof(char*);
+""")
-const int NUM_FEATURES = sizeof(FEATURES)/sizeof(char*);
+cfile.write("""
+/*********************/
+/* Feature full list */
+/*********************/
+
+char const *const FEATURES_ALL[] = {\
+""")
+
+feature_string = """
+ "{feature}","""
+
+for feature in sorted(defs.allfeatures):
+ cfile.write(feature_string.format(feature=feature))
+
+cfile.write("""
+};
+unsigned int const NUM_FEATURES_ALL = sizeof(FEATURES_ALL) / sizeof(char*);
""")
cfile.close()
-print("Done.")
diff --git a/src/python/espressomd/gen_code_info.py b/src/python/espressomd/gen_code_info.py
index 4314d5e3c..2f14582b8 100644
--- a/src/python/espressomd/gen_code_info.py
+++ b/src/python/espressomd/gen_code_info.py
@@ -53,14 +53,14 @@ def features():
f = []
""")
-for feature in defs.allfeatures:
+for feature in sorted(defs.allfeatures):
cfile.write(f"\n IF {feature} == 1:\n f.append(\"{feature}\")\n")
cfile.write(f"""
return sorted(f)
def all_features():
- return {defs.allfeatures}
+ return {{{str(sorted(defs.allfeatures))[1:-1]}}}
cdef extern from "version.hpp":

View File

@@ -1,3 +1,24 @@
-------------------------------------------------------------------
Fri Mar 21 14:41:09 UTC 2025 - Bernhard Wiedemann <bwiedemann@suse.com>
- Add espresso-cython.patch to drop build date (boo#1047218)
-------------------------------------------------------------------
Thu Mar 13 15:25:08 UTC 2025 - Jean-Noel Grad <jgrad@icp.uni-stuttgart.de>
- Fix Python executable path hint
-------------------------------------------------------------------
Thu Mar 13 15:10:17 UTC 2025 - Jean-Noel Grad <jgrad@icp.uni-stuttgart.de>
- Disable HDF5 feature
-------------------------------------------------------------------
Thu Mar 13 15:04:19 UTC 2025 - Jean-Noel Grad <jgrad@icp.uni-stuttgart.de>
- Fix breaking builds
- Disable features that rely on unmet dependencies (h5py, scipy)
-------------------------------------------------------------------
Wed Sep 11 19:01:36 UTC 2024 - Jean-Noel Grad <jgrad@icp.uni-stuttgart.de>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python3-espressomd
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2014 Christoph Junghans
#
# All modifications and additions to the file contributed by third parties
@@ -18,6 +18,15 @@
# Build with OpenMPI
%if 0%{?suse_version} > 1600 && 0%{?is_opensuse}
%define is_tumbleweed 1
%define boostver %{nil}
%define pyver 3
%else
%define is_tumbleweed 0
%define boostver 1_75_0
%define pyver 311
%endif
%define mpiver openmpi4
%define pkgname espresso
%define modname %{pkgname}md
@@ -32,34 +41,31 @@ Source: https://github.com/%{modname}/%{pkgname}/releases/download/%{ver
Patch0: numpy.patch
# PATCH-FIX-UPSTREAM cmake.patch gh#espressomd/espresso#4992
Patch1: cmake.patch
# PATCH-FIX-UPSTREAM https://github.com/espressomd/espresso/commit/2111342
Patch2: espresso-cython.patch
# According to gh#espressomd/espresso#4537 32bit architectures are not supported any more
ExcludeArch: %{ix86} armv7l
BuildRequires: %{mpiver}-devel
BuildRequires: chrpath
BuildRequires: cmake
BuildRequires: fftw3-devel
BuildRequires: gcc-c++
# Currently libboost_mpi-devel and hdf5 use different mpi versions
# BuildRequires: hdf5-devel
BuildRequires: %{mpiver}-devel
BuildRequires: chrpath
BuildRequires: gsl-devel
BuildRequires: hdf5-%{mpiver}-devel
BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_mpi-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_test-devel
BuildRequires: python3-Cython < 3.0.10
BuildRequires: python3-devel
BuildRequires: python3-h5py
BuildRequires: python3-numpy-devel
BuildRequires: python3-scipy
BuildRequires: python3-setuptools
BuildRequires: libboost_filesystem%{boostver}-devel
BuildRequires: libboost_mpi%{boostver}-devel
BuildRequires: libboost_system%{boostver}-devel
BuildRequires: libboost_test%{boostver}-devel
BuildRequires: python%{pyver}-Cython < 3.0.13
BuildRequires: python%{pyver}-devel
BuildRequires: python%{pyver}-numpy-devel
BuildRequires: python%{pyver}-setuptools
%if 0%{?is_tumbleweed}
BuildRequires: python%{pyver}-scipy
%endif
BuildRequires: zlib-devel
Provides: libEspresso4 = %{version}-%{release}
Obsoletes: libEspresso4 < 4.1
Requires: python3-h5py
Requires: python3-numpy
# make sure rpm pulls in the right dependency
Requires: libhdf5-%{mpiver}
%description
ESPResSo is a highly versatile software package for performing and analyzing
@@ -73,23 +79,39 @@ systems, for example DNA and lipid membranes.
%autosetup -p1 -n %{pkgname}
# Fix shebang line for pypresso
sed -i -E '1s@^#!/usr/bin/env[[:blank:]]+sh@#!/bin/sh@' src/python/pypresso.cmakein
# skip mpiio test - it fails if inwoked with cmake, direct run with python3 -m unittest pass
# skip mpiio test - it fails if invoked with cmake, directly run with python3 -m unittest pass
sed -i '/mpiio\.py/d' testsuite/python/CMakeLists.txt
%if 0%{?is_tumbleweed} == 0
# remove tests that depend on scipy (unavailable in Leap 15.6)
sed -i '/checkpoint_test(/d' testsuite/python/CMakeLists.txt
sed -i '/ MAX_NUM_PROC 1)/d' testsuite/python/CMakeLists.txt
sed -i '/rotation\.py/d' testsuite/python/CMakeLists.txt
sed -i '/reaction_complex\.py/d' testsuite/python/CMakeLists.txt
sed -i '/canonical_ensemble\.py/d' testsuite/python/CMakeLists.txt
sed -i '/lb_pressure_tensor\.py/d' testsuite/python/CMakeLists.txt
sed -i '/analyze_acf\.py/d' testsuite/python/CMakeLists.txt
sed -i '/analyze_distribution\.py/d' testsuite/python/CMakeLists.txt
sed -i '/random_pairs\.py/d' testsuite/python/CMakeLists.txt
sed -i '/oif_volume_conservation\.py/d' testsuite/python/CMakeLists.txt
%endif
%build
source %{_libdir}/mpi/gcc/%{mpiver}/bin/mpivars.sh
# gh#espressomd/espresso#3396
%define _lto_cflags %{nil}
#force usage of shared hdf5
export HDF5_USE_SHLIB=yes
# overwrite .so linker flags on SUSE distros: drop --no-undefined
# we don't install {i,}pypresso scripts as they aren't needed when installing in /usr
%cmake \
-DCMAKE_SHARED_LINKER_FLAGS='-Wl,--as-needed -Wl,-z,now' \
-DCMAKE_SKIP_RPATH=ON \
-DWITH_HDF5=OFF \
-DLIBDIR=%{_libdir} \
%if 0%{?is_tumbleweed}
-DPYTHON_EXECUTABLE=%{_bindir}/python3 \
%else
-DPYTHON_EXECUTABLE=%{_bindir}/python3.11 \
%endif
-DPYTHON_INSTDIR=%{python3_sitearch} \
-DINSTALL_PYPRESSO=ON
%make_jobs