1{ 2 lib, 3 stdenv, 4 toPythonModule, 5 fetchFromGitHub, 6 buildPythonPackage, 7 8 # build-system 9 scikit-build-core, 10 nanobind, 11 12 # nativeBuildInputs 13 cmake, 14 ninja, 15 pkg-config, 16 17 # buildInputs 18 dolfinx, 19 20 # dependency 21 numpy, 22 cffi, 23 mpi4py, 24 petsc4py, 25 slepc4py, 26 adios2, 27 kahip, 28 fenics-ffcx, 29 fenics-basix, 30 fenics-ufl, 31 32 # nativeCheckInputs 33 scipy, 34 matplotlib, 35 pytest-xdist, 36 pytestCheckHook, 37 writableTmpDirAsHomeHook, 38 mpiCheckPhaseHook, 39 40 # custom options 41 withParmetis ? false, 42 43 # passthru.tests 44 fenics-dolfinx, 45 mpich, 46}: 47 48let 49 fenicsPackages = petsc4py.petscPackages.overrideScope ( 50 final: prev: { 51 slepc = final.callPackage slepc4py.override { }; 52 adios2 = final.callPackage adios2.override { }; 53 kahip = final.callPackage kahip.override { }; 54 dolfinx = final.callPackage dolfinx.override { inherit withParmetis; }; 55 } 56 ); 57in 58buildPythonPackage rec { 59 inherit (dolfinx) 60 version 61 src 62 ; 63 pname = "fenics-dolfinx"; 64 pyproject = true; 65 66 pythonRelaxDeps = [ 67 "cffi" 68 "fenics-ufl" 69 ]; 70 71 preConfigure = '' 72 cd python 73 ''; 74 75 dontUseCmakeConfigure = true; 76 77 build-system = [ 78 scikit-build-core 79 nanobind 80 ]; 81 82 nativeBuildInputs = [ 83 cmake 84 ninja 85 pkg-config 86 fenicsPackages.mpi 87 ]; 88 89 buildInputs = [ 90 fenicsPackages.dolfinx 91 ]; 92 93 dependencies = [ 94 numpy 95 cffi 96 fenics-basix 97 fenics-ffcx 98 fenics-ufl 99 petsc4py 100 fenicsPackages.slepc 101 fenicsPackages.adios2 102 fenicsPackages.kahip 103 (mpi4py.override { inherit (fenicsPackages) mpi; }) 104 ]; 105 106 doCheck = true; 107 108 nativeCheckInputs = [ 109 scipy 110 matplotlib 111 pytest-xdist 112 pytestCheckHook 113 writableTmpDirAsHomeHook 114 mpiCheckPhaseHook 115 ]; 116 117 preCheck = '' 118 rm -rf dolfinx 119 ''; 120 121 pythonImportsCheck = [ 122 "dolfinx" 123 ]; 124 125 disabledTests = [ 126 # require cffi<1.17 127 "test_cffi_expression" 128 "test_hexahedron_mesh" 129 ]; 130 131 passthru = { 132 tests = 133 { 134 complex = fenics-dolfinx.override { 135 petsc4py = petsc4py.override { scalarType = "complex"; }; 136 }; 137 } 138 // lib.optionalAttrs stdenv.hostPlatform.isLinux { 139 mpich = fenics-dolfinx.override { 140 petsc4py = petsc4py.override { mpi = mpich; }; 141 }; 142 }; 143 }; 144 145 meta = { 146 homepage = "https://fenicsproject.org"; 147 downloadPage = "https://github.com/fenics/dolfinx"; 148 description = "Computational environment of FEniCSx and implements the FEniCS Problem Solving Environment in C++ and Python"; 149 changelog = "https://github.com/fenics/dolfinx/releases/tag/${src.tag}"; 150 license = with lib.licenses; [ 151 bsd2 152 lgpl3Plus 153 ]; 154 platforms = lib.platforms.unix; 155 maintainers = with lib.maintainers; [ qbisi ]; 156 }; 157}