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