at master 3.9 kB view raw
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 47 firedrake, 48 mpich, 49 nix-update-script, 50}: 51let 52 firedrakePackages = lib.makeScope newScope (self: { 53 inherit (petsc4py.petscPackages) mpi hdf5; 54 mpi4py = self.callPackage mpi4py.override { }; 55 h5py = self.callPackage h5py.override { }; 56 mpi-pytest = self.callPackage mpi-pytest.override { }; 57 }); 58in 59buildPythonPackage rec { 60 pname = "firedrake"; 61 version = "2025.4.2"; 62 pyproject = true; 63 64 src = fetchFromGitHub { 65 owner = "firedrakeproject"; 66 repo = "firedrake"; 67 tag = version; 68 hash = "sha256-bAGmXoHPAdMYJMMQYVq98LYro1Vd+o9pfvXC3BsQUf0="; 69 }; 70 71 postPatch = 72 # relax build-dependency petsc4py 73 '' 74 substituteInPlace pyproject.toml --replace-fail \ 75 "petsc4py==3.23.4" "petsc4py" 76 '' 77 + lib.optionalString stdenv.hostPlatform.isLinux '' 78 substituteInPlace firedrake/petsc.py --replace-fail \ 79 'program = ["ldd"]' \ 80 'program = ["${lib.getExe' pax-utils "lddtree"}"]' 81 '' 82 + lib.optionalString stdenv.hostPlatform.isDarwin '' 83 substituteInPlace firedrake/petsc.py --replace-fail \ 84 'program = ["otool"' \ 85 'program = ["${lib.getExe' stdenv.cc.bintools.bintools "otool"}"' 86 ''; 87 88 pythonRelaxDeps = [ 89 "decorator" 90 "slepc4py" 91 ]; 92 93 build-system = [ 94 cython 95 libsupermesh 96 firedrakePackages.mpi4py 97 numpy 98 pkgconfig 99 pybind11 100 setuptools 101 petsc4py 102 rtree 103 ]; 104 105 nativeBuildInputs = [ 106 firedrakePackages.mpi 107 ]; 108 109 dependencies = [ 110 decorator 111 cachetools 112 firedrakePackages.mpi4py 113 fenics-ufl 114 firedrake-fiat 115 firedrakePackages.h5py 116 libsupermesh 117 loopy 118 petsc4py 119 numpy 120 packaging 121 pkgconfig 122 progress 123 pyadjoint-ad 124 pycparser 125 pytools 126 requests 127 rtree 128 scipy 129 sympy 130 # required by script spydump 131 matplotlib 132 ] 133 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 134 islpy 135 ]; 136 137 postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' 138 install_name_tool -add_rpath ${libsupermesh}/${python.sitePackages}/libsupermesh/lib \ 139 $out/${python.sitePackages}/firedrake/cython/supermeshimpl.cpython-*-darwin.so 140 ''; 141 142 doCheck = true; 143 144 __darwinAllowLocalNetworking = true; 145 146 pythonImportsCheck = [ "firedrake" ]; 147 148 nativeCheckInputs = [ 149 pytest 150 firedrakePackages.mpi-pytest 151 mpiCheckPhaseHook 152 writableTmpDirAsHomeHook 153 ]; 154 155 # These scripts are used by official sdist/editable_wheel only 156 postInstall = '' 157 rm $out/bin/firedrake-{check,status,run-split-tests} 158 ''; 159 160 preCheck = '' 161 rm -rf firedrake pyop2 tinyasm tsfc 162 ''; 163 164 # run official smoke tests 165 checkPhase = '' 166 runHook preCheck 167 168 make check 169 170 runHook postCheck 171 ''; 172 173 passthru = { 174 # python updater script sets the wrong tag 175 skipBulkUpdate = true; 176 177 updateScript = nix-update-script { 178 extraArgs = [ 179 "--version-regex" 180 "([0-9.]+)" 181 ]; 182 }; 183 184 tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { 185 mpich = firedrake.override { 186 petsc4py = petsc4py.override { mpi = mpich; }; 187 }; 188 }; 189 }; 190 191 meta = { 192 homepage = "https://www.firedrakeproject.org"; 193 downloadPage = "https://github.com/firedrakeproject/firedrake"; 194 description = "Automated Finite Element System"; 195 license = with lib.licenses; [ 196 bsd3 197 lgpl3Plus 198 ]; 199 maintainers = with lib.maintainers; [ qbisi ]; 200 }; 201}