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