Skip to content

Commit 3349639

Browse files
authored
python3Packages.firedrake: init at 2025.4.0.post0 (#406239)
2 parents ae12694 + 04dd87a commit 3349639

File tree

2 files changed

+197
-0
lines changed

2 files changed

+197
-0
lines changed
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
{
2+
lib,
3+
newScope,
4+
stdenv,
5+
buildPythonPackage,
6+
fetchFromGitHub,
7+
fetchpatch2,
8+
python,
9+
pax-utils,
10+
11+
# build-system
12+
setuptools,
13+
cython,
14+
pybind11,
15+
16+
# dependencies
17+
decorator,
18+
cachetools,
19+
mpi4py,
20+
fenics-ufl,
21+
firedrake-fiat,
22+
h5py,
23+
libsupermesh,
24+
loopy,
25+
petsc4py,
26+
numpy,
27+
packaging,
28+
pkgconfig,
29+
progress,
30+
pyadjoint-ad,
31+
pycparser,
32+
pytools,
33+
requests,
34+
rtree,
35+
scipy,
36+
sympy,
37+
islpy,
38+
matplotlib,
39+
40+
# tests
41+
pytest,
42+
mpi-pytest,
43+
mpiCheckPhaseHook,
44+
writableTmpDirAsHomeHook,
45+
46+
# passthru.tests
47+
firedrake,
48+
mpich,
49+
}:
50+
let
51+
firedrakePackages = lib.makeScope newScope (self: {
52+
inherit (petsc4py.petscPackages) mpi hdf5;
53+
mpi4py = self.callPackage mpi4py.override { };
54+
h5py = self.callPackage h5py.override { };
55+
mpi-pytest = self.callPackage mpi-pytest.override { };
56+
});
57+
in
58+
buildPythonPackage rec {
59+
pname = "firedrake";
60+
version = "2025.4.0.post0";
61+
pyproject = true;
62+
63+
src = fetchFromGitHub {
64+
owner = "firedrakeproject";
65+
repo = "firedrake";
66+
tag = version;
67+
hash = "sha256-wQOS4v/YkIwXdQq6JMvRbmyhnzvx6wj0O6aszNa5ZMw=";
68+
};
69+
70+
patches = [
71+
(fetchpatch2 {
72+
url = "https://github.com/firedrakeproject/firedrake/commit/b358e33ab12b3c4bc3819c9c6e9ed0930082b750.patch?full_index=1";
73+
hash = "sha256-y00GB8njhmHgtAVvlv8ImsJe+hMCU1QFtbB8llEhv/I=";
74+
})
75+
];
76+
77+
postPatch =
78+
''
79+
# relax build-dependency petsc4py
80+
substituteInPlace pyproject.toml --replace-fail \
81+
"petsc4py==3.23.0" "petsc4py"
82+
83+
# These scripts are used by official source distribution only,
84+
# and do not make sense in our binary distribution.
85+
sed -i '/firedrake-\(check\|status\|run-split-tests\)/d' pyproject.toml
86+
''
87+
+ lib.optionalString stdenv.hostPlatform.isLinux ''
88+
substituteInPlace firedrake/petsc.py --replace-fail \
89+
'program = ["ldd"]' \
90+
'program = ["${lib.getExe' pax-utils "lddtree"}"]'
91+
''
92+
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
93+
substituteInPlace firedrake/petsc.py --replace-fail \
94+
'program = ["otool"' \
95+
'program = ["${lib.getExe' stdenv.cc.bintools.bintools "otool"}"'
96+
'';
97+
98+
pythonRelaxDeps = [
99+
"decorator"
100+
];
101+
102+
build-system = [
103+
cython
104+
libsupermesh
105+
firedrakePackages.mpi4py
106+
numpy
107+
pkgconfig
108+
pybind11
109+
setuptools
110+
petsc4py
111+
rtree
112+
];
113+
114+
nativeBuildInputs = [
115+
firedrakePackages.mpi
116+
];
117+
118+
dependencies =
119+
[
120+
decorator
121+
cachetools
122+
firedrakePackages.mpi4py
123+
fenics-ufl
124+
firedrake-fiat
125+
firedrakePackages.h5py
126+
libsupermesh
127+
loopy
128+
petsc4py
129+
numpy
130+
packaging
131+
pkgconfig
132+
progress
133+
pyadjoint-ad
134+
pycparser
135+
pytools
136+
requests
137+
rtree
138+
scipy
139+
sympy
140+
# required by script spydump
141+
matplotlib
142+
]
143+
++ pytools.optional-dependencies.siphash
144+
++ lib.optional stdenv.hostPlatform.isDarwin islpy;
145+
146+
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
147+
install_name_tool -add_rpath ${libsupermesh}/${python.sitePackages}/libsupermesh/lib \
148+
$out/${python.sitePackages}/firedrake/cython/supermeshimpl.cpython-*-darwin.so
149+
'';
150+
151+
doCheck = true;
152+
153+
__darwinAllowLocalNetworking = true;
154+
155+
pythonImportsCheck = [ "firedrake" ];
156+
157+
nativeCheckInputs = [
158+
pytest
159+
firedrakePackages.mpi-pytest
160+
mpiCheckPhaseHook
161+
writableTmpDirAsHomeHook
162+
];
163+
164+
preCheck = ''
165+
rm -rf firedrake pyop2 tinyasm tsfc
166+
'';
167+
168+
# run official smoke tests
169+
checkPhase = ''
170+
runHook preCheck
171+
172+
make check
173+
174+
runHook postCheck
175+
'';
176+
177+
passthru = {
178+
tests = lib.optionalAttrs stdenv.hostPlatform.isLinux {
179+
mpich = firedrake.override {
180+
petsc4py = petsc4py.override { mpi = mpich; };
181+
};
182+
};
183+
};
184+
185+
meta = {
186+
homepage = "https://www.firedrakeproject.org";
187+
downloadPage = "https://github.com/firedrakeproject/firedrake";
188+
description = "Automated Finite Element System";
189+
license = with lib.licenses; [
190+
bsd3
191+
lgpl3Plus
192+
];
193+
maintainers = with lib.maintainers; [ qbisi ];
194+
};
195+
}

pkgs/top-level/python-packages.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4951,6 +4951,8 @@ self: super: with self; {
49514951

49524952
firecrawl-py = callPackage ../development/python-modules/firecrawl-py { };
49534953

4954+
firedrake = callPackage ../development/python-modules/firedrake { };
4955+
49544956
firedrake-fiat = callPackage ../development/python-modules/firedrake-fiat { };
49554957

49564958
fireflyalgorithm = callPackage ../development/python-modules/fireflyalgorithm { };

0 commit comments

Comments
 (0)