1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 writableTmpDirAsHomeHook,
6
7 # build-system
8 cmake,
9 cython_0,
10 ninja,
11 oldest-supported-numpy,
12 setuptools,
13 scikit-build,
14
15 # dependencies
16 matplotlib,
17 meshio,
18 numpy,
19 pyparsing,
20 python,
21 pyvista,
22 scipy,
23 sympy,
24 tables,
25
26 # tests
27 pytest,
28 openssh,
29}:
30
31buildPythonPackage rec {
32 pname = "sfepy";
33 version = "2024.4";
34 pyproject = true;
35
36 src = fetchFromGitHub {
37 owner = "sfepy";
38 repo = "sfepy";
39 tag = "release_${version}";
40 hash = "sha256-3XQqPoAM1Qw/fZ649Xk+ceaeBkZ3ypI1FSRxtYbIrxw=";
41 };
42
43 postPatch = ''
44 substituteInPlace pyproject.toml \
45 --replace-fail "ninja<=1.11.1.1" "ninja" \
46 --replace-fail "numpy<2" "numpy"
47
48 substituteInPlace sfepy/solvers/optimize.py \
49 --replace-fail "nm.Inf" "nm.inf"
50
51 substituteInPlace sfepy/examples/quantum/quantum_common.py \
52 --replace-fail "NaN" "nan"
53
54 # slow tests
55 rm sfepy/tests/test_elasticity_small_strain.py
56 rm sfepy/tests/test_hyperelastic_tlul.py
57 rm sfepy/tests/test_io.py
58 rm sfepy/tests/test_linear_solvers.py
59 rm sfepy/tests/test_poly_spaces.py
60 rm sfepy/tests/test_quadratures.py
61 rm sfepy/tests/test_refine_hanging.py
62 rm sfepy/tests/test_term_call_modes.py
63 # ValueError: invalid literal for int() with base 10: 'np.int64(3)'
64 rm sfepy/tests/test_meshio.py
65 '';
66
67 nativeBuildInputs = [
68 writableTmpDirAsHomeHook
69 ];
70
71 build-system = [
72 cmake
73 cython_0
74 ninja
75 oldest-supported-numpy
76 setuptools
77 scikit-build
78 ];
79
80 dontUseCmakeConfigure = true;
81
82 dependencies = [
83 matplotlib
84 meshio
85 numpy
86 pyparsing
87 pyvista
88 scipy
89 sympy
90 tables
91 ];
92
93 pythonRelaxDeps = [
94 "numpy"
95 ];
96
97 nativeCheckInputs = [
98 pytest
99 writableTmpDirAsHomeHook
100 ];
101
102 checkPhase = ''
103 runHook preCheck
104
105 export OMPI_MCA_plm_rsh_agent=${lib.getExe openssh}
106 mv sfepy sfepy.hidden
107 mkdir -p $HOME/.matplotlib
108 echo "backend: ps" > $HOME/.matplotlib/matplotlibrc
109 ${python.interpreter} -c "import sfepy; sfepy.test()"
110
111 runHook postCheck
112 '';
113
114 meta = {
115 homepage = "https://sfepy.org/";
116 description = "Simple Finite Elements in Python";
117 license = lib.licenses.bsd3;
118 maintainers = with lib.maintainers; [ wd15 ];
119 };
120}