Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, buildPythonPackage 4, cvxopt 5, cvxpy 6, cython 7, doCheck ? true 8, fetchFromGitHub 9, ipython 10, matplotlib 11, numpy 12, packaging 13, pytest-rerunfailures 14, pytestCheckHook 15, python 16, pythonOlder 17, scipy 18}: 19 20buildPythonPackage rec { 21 pname = "qutip"; 22 version = "4.7.1"; 23 format = "setuptools"; 24 25 disabled = pythonOlder "3.7"; 26 27 src = fetchFromGitHub { 28 owner = pname; 29 repo = pname; 30 rev = "refs/tags/v${version}"; 31 hash = "sha256-W5iqRWAB6D1Dnxz0Iyl7ZmP3yrXvLyV7BdBdIgFCiQY="; 32 }; 33 34 nativeBuildInputs = [ 35 cython 36 ]; 37 38 propagatedBuildInputs = [ 39 numpy 40 packaging 41 scipy 42 ]; 43 44 nativeCheckInputs = [ 45 pytestCheckHook 46 pytest-rerunfailures 47 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies); 48 49 # Disabling OpenMP support on Darwin. 50 setupPyGlobalFlags = lib.optionals (!stdenv.isDarwin) [ 51 "--with-openmp" 52 ]; 53 54 # QuTiP tries to access the home directory to create an rc file for us. 55 # We need to go to another directory to run the tests from there. 56 # This is due to the Cython-compiled modules not being in the correct location 57 # of the source tree. 58 preCheck = '' 59 export HOME=$(mktemp -d); 60 export OMP_NUM_THREADS=$NIX_BUILD_CORES 61 mkdir -p test && cd test 62 ''; 63 64 # For running tests, see https://qutip.org/docs/latest/installation.html#verifying-the-installation 65 checkPhase = '' 66 runHook preCheck 67 ${python.interpreter} -c "import qutip.testing; qutip.testing.run()" 68 runHook postCheck 69 ''; 70 71 pythonImportsCheck = [ 72 "qutip" 73 ]; 74 75 passthru.optional-dependencies = { 76 graphics = [ 77 matplotlib 78 ]; 79 ipython = [ 80 ipython 81 ]; 82 semidefinite = [ 83 cvxpy 84 cvxopt 85 ]; 86 }; 87 88 meta = with lib; { 89 broken = (stdenv.isLinux && stdenv.isAarch64); 90 description = "Open-source software for simulating the dynamics of closed and open quantum systems"; 91 homepage = "https://qutip.org/"; 92 license = licenses.bsd3; 93 maintainers = with maintainers; [ fabiangd ]; 94 }; 95}