at master 2.5 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 cython, 9 oldest-supported-numpy, 10 setuptools, 11 12 # dependencies 13 numpy, 14 packaging, 15 scipy, 16 17 # tests 18 pytestCheckHook, 19 pytest-rerunfailures, 20 writableTmpDirAsHomeHook, 21 python, 22 23 # optional-dependencies 24 matplotlib, 25 ipython, 26 cvxopt, 27 cvxpy, 28}: 29 30buildPythonPackage rec { 31 pname = "qutip"; 32 version = "5.2.1"; 33 pyproject = true; 34 35 src = fetchFromGitHub { 36 owner = "qutip"; 37 repo = "qutip"; 38 tag = "v${version}"; 39 hash = "sha256-iM+RptMvLFF51v7OJPESYFB4WaYF5HxnfpqjYWAjAKU="; 40 }; 41 42 postPatch = 43 # build-time constraint, used to ensure forward and backward compat 44 '' 45 substituteInPlace pyproject.toml setup.cfg \ 46 --replace-fail "numpy>=2.0.0" "numpy" 47 ''; 48 49 build-system = [ 50 cython 51 oldest-supported-numpy 52 setuptools 53 ]; 54 55 dependencies = [ 56 numpy 57 packaging 58 scipy 59 ]; 60 61 nativeCheckInputs = [ 62 pytestCheckHook 63 pytest-rerunfailures 64 writableTmpDirAsHomeHook 65 ] 66 ++ lib.flatten (builtins.attrValues optional-dependencies); 67 68 # QuTiP tries to access the home directory to create an rc file for us. 69 # We need to go to another directory to run the tests from there. 70 # This is due to the Cython-compiled modules not being in the correct location 71 # of the source tree. 72 preCheck = '' 73 export OMP_NUM_THREADS=$NIX_BUILD_CORES 74 mkdir -p test && cd test 75 ''; 76 77 # For running tests, see https://qutip.org/docs/latest/installation.html#verifying-the-installation 78 checkPhase = '' 79 runHook preCheck 80 ${python.interpreter} -c "import qutip.testing; qutip.testing.run()" 81 runHook postCheck 82 ''; 83 84 pythonImportsCheck = [ "qutip" ]; 85 86 optional-dependencies = { 87 graphics = [ matplotlib ]; 88 ipython = [ ipython ]; 89 semidefinite = [ 90 cvxopt 91 cvxpy 92 ]; 93 }; 94 95 meta = { 96 description = "Open-source software for simulating the dynamics of closed and open quantum systems"; 97 homepage = "https://qutip.org/"; 98 changelog = "https://github.com/qutip/qutip/releases/tag/${src.tag}"; 99 license = lib.licenses.bsd3; 100 maintainers = with lib.maintainers; [ fabiangd ]; 101 badPlatforms = [ 102 # Tests fail at ~80% 103 # ../tests/test_animation.py::test_result_state Fatal Python error: Aborted 104 lib.systems.inspect.patterns.isDarwin 105 106 # Several tests fail with a segfault 107 # ../tests/test_random.py::test_rand_super_bcsz[int-CSR-choi-None-rep(1)] Fatal Python error: Aborted 108 "aarch64-linux" 109 ]; 110 }; 111}