precice: fix build (#378870)

This commit is contained in:
Gaétan Lepage
2025-02-04 10:31:44 +01:00
committed by GitHub
2 changed files with 40 additions and 26 deletions

View File

@@ -2,8 +2,8 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
cmake,
gcc,
boost,
eigen,
libxml2,
@@ -24,26 +24,28 @@ stdenv.mkDerivation rec {
hash = "sha256-KpmcQj8cv5V5OXCMhe2KLTsqUzKWtTeQyP+zg+Y+yd0=";
};
cmakeFlags = [
"-DPRECICE_PETScMapping=OFF"
"-DBUILD_SHARED_LIBS=ON"
"-DPYTHON_LIBRARIES=${python3.libPrefix}"
"-DPYTHON_INCLUDE_DIR=${python3}/include/${python3.libPrefix}"
patches = lib.optionals (!lib.versionOlder "3.1.2" version) [
(fetchpatch {
name = "boost-187-fixes.patch";
url = "https://github.com/precice/precice/commit/23788e9eeac49a2069e129a0cb1ac846e8cbeb9f.patch";
hash = "sha256-Z8qOGOkXoCui8Wy0H/OeE+NaTDvyRuPm2A+VJKtjH4s=";
})
];
env.NIX_CFLAGS_COMPILE = toString (
lib.optionals stdenv.hostPlatform.isDarwin [ "-D_GNU_SOURCE" ]
# libxml2-2.12 changed const qualifiers
++ [ "-fpermissive" ]
);
cmakeFlags = [
(lib.cmakeBool "PRECICE_PETScMapping" false)
(lib.cmakeBool "BUILD_SHARED_LIBS" true)
(lib.cmakeFeature "PYTHON_LIBRARIES" python3.libPrefix)
(lib.cmakeFeature "PYTHON_INCLUDE_DIR" "${python3}/include/${python3.libPrefix}")
];
nativeBuildInputs = [
cmake
gcc
pkg-config
python3
python3.pkgs.numpy
];
buildInputs = [
boost
eigen

View File

@@ -1,15 +1,18 @@
{
lib,
buildPythonPackage,
setuptools,
pip,
cython,
fetchFromGitHub,
# build-system
cython,
pip,
pkgconfig,
setuptools,
# dependencies
mpi4py,
numpy,
precice,
pkgconfig,
pythonOlder,
}:
buildPythonPackage rec {
@@ -17,8 +20,6 @@ buildPythonPackage rec {
version = "3.1.2";
pyproject = true;
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "precice";
repo = "python-bindings";
@@ -26,14 +27,24 @@ buildPythonPackage rec {
hash = "sha256-/atuMJVgvY4kgvrB+LuQZmJuSK4O8TJdguC7NCiRS2Y=";
};
nativeBuildInputs = [
setuptools
pip
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail "setuptools>=61,<72" "setuptools" \
--replace-fail "numpy<2" "numpy"
'';
build-system = [
cython
pip
pkgconfig
setuptools
];
propagatedBuildInputs = [
pythonRelaxDeps = [
"numpy"
];
dependencies = [
numpy
mpi4py
precice
@@ -44,10 +55,11 @@ buildPythonPackage rec {
# Do not use pythonImportsCheck because this will also initialize mpi which requires a network interface
meta = with lib; {
meta = {
description = "Python language bindings for preCICE";
homepage = "https://github.com/precice/python-bindings";
license = licenses.lgpl3Only;
maintainers = with maintainers; [ Scriptkiddi ];
changelog = "https://github.com/precice/python-bindings/blob/v${version}/CHANGELOG.md";
license = lib.licenses.lgpl3Only;
maintainers = with lib.maintainers; [ Scriptkiddi ];
};
}