summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/sfepy/default.nix
blob: 3c782a874b67ffeb10859715ffc068dbe99c2cb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  writableTmpDirAsHomeHook,

  # build-system
  cmake,
  cython_0,
  ninja,
  oldest-supported-numpy,
  setuptools,
  scikit-build,

  # dependencies
  matplotlib,
  meshio,
  numpy,
  pyparsing,
  python,
  pyvista,
  scipy,
  sympy,
  tables,

  # tests
  pytest,
  openssh,
}:

buildPythonPackage rec {
  pname = "sfepy";
  version = "2024.4";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "sfepy";
    repo = "sfepy";
    tag = "release_${version}";
    hash = "sha256-3XQqPoAM1Qw/fZ649Xk+ceaeBkZ3ypI1FSRxtYbIrxw=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "ninja<=1.11.1.1" "ninja" \
      --replace-fail "numpy<2" "numpy"

    substituteInPlace sfepy/solvers/optimize.py \
      --replace-fail "nm.Inf" "nm.inf"

    substituteInPlace sfepy/examples/quantum/quantum_common.py \
      --replace-fail "NaN" "nan"

    # slow tests
    rm sfepy/tests/test_elasticity_small_strain.py
    rm sfepy/tests/test_hyperelastic_tlul.py
    rm sfepy/tests/test_io.py
    rm sfepy/tests/test_linear_solvers.py
    rm sfepy/tests/test_poly_spaces.py
    rm sfepy/tests/test_quadratures.py
    rm sfepy/tests/test_refine_hanging.py
    rm sfepy/tests/test_term_call_modes.py
    #  ValueError: invalid literal for int() with base 10: 'np.int64(3)'
    rm sfepy/tests/test_meshio.py
  '';

  nativeBuildInputs = [
    writableTmpDirAsHomeHook
  ];

  build-system = [
    cmake
    cython_0
    ninja
    oldest-supported-numpy
    setuptools
    scikit-build
  ];

  dontUseCmakeConfigure = true;

  dependencies = [
    matplotlib
    meshio
    numpy
    pyparsing
    pyvista
    scipy
    sympy
    tables
  ];

  pythonRelaxDeps = [
    "numpy"
  ];

  nativeCheckInputs = [
    pytest
    writableTmpDirAsHomeHook
  ];

  checkPhase = ''
    runHook preCheck

    export OMPI_MCA_plm_rsh_agent=${lib.getExe openssh}
    mv sfepy sfepy.hidden
    mkdir -p $HOME/.matplotlib
    echo "backend: ps" > $HOME/.matplotlib/matplotlibrc
    ${python.interpreter} -c "import sfepy; sfepy.test()"

    runHook postCheck
  '';

  meta = {
    homepage = "https://sfepy.org/";
    description = "Simple Finite Elements in Python";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ wd15 ];
  };
}