1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 torch, 6 ninja, 7 scipy, 8 which, 9 pybind11, 10 pytest-xdist, 11 pytestCheckHook, 12}: 13 14let 15 linePatch = '' 16 import os 17 os.environ['PATH'] = os.environ['PATH'] + ':${ninja}/bin' 18 ''; 19in 20buildPythonPackage rec { 21 pname = "deepwave"; 22 version = "0.0.18"; 23 format = "pyproject"; 24 25 src = fetchFromGitHub { 26 owner = "ar4"; 27 repo = "deepwave"; 28 rev = "v${version}"; 29 hash = "sha256-DOOy+B12jgwJzQ90qzX50OFxYLPRcVdVYSE5gi3pqDM="; 30 }; 31 32 # unable to find ninja although it is available, most likely because it looks for its pip version 33 postPatch = '' 34 substituteInPlace setup.cfg --replace "ninja" "" 35 36 # Adding ninja to the path forcibly 37 mv src/deepwave/__init__.py tmp 38 echo "${linePatch}" > src/deepwave/__init__.py 39 cat tmp >> src/deepwave/__init__.py 40 rm tmp 41 ''; 42 43 # The source files are compiled at runtime and cached at the 44 # $HOME/.cache folder, so for the check phase it is needed to 45 # have a temporary home. This is also the reason ninja is not 46 # needed at the nativeBuildInputs, since it will only be used 47 # at runtime. 48 preBuild = '' 49 export HOME=$(mktemp -d) 50 ''; 51 52 propagatedBuildInputs = [ 53 torch 54 pybind11 55 ]; 56 57 nativeCheckInputs = [ 58 which 59 scipy 60 pytest-xdist 61 pytestCheckHook 62 ]; 63 64 pythonImportsCheck = [ "deepwave" ]; 65 66 meta = with lib; { 67 description = "Wave propagation modules for PyTorch"; 68 homepage = "https://github.com/ar4/deepwave"; 69 license = licenses.mit; 70 platforms = intersectLists platforms.x86_64 platforms.linux; 71 maintainers = with maintainers; [ atila ]; 72 }; 73}