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

View File

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