nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 70 lines 2.1 kB view raw
1{ lib, stdenv, fetchFromGitHub, buildPythonPackage, python, packaging, numpy 2, cython, scipy, matplotlib, pytestCheckHook, pytest-rerunfailures 3, doCheck ? false 4}: 5 6let 7 self = buildPythonPackage rec { 8 pname = "qutip"; 9 version = "4.6.3"; 10 11 src = fetchFromGitHub { 12 owner = pname; 13 repo = pname; 14 rev = "v${version}"; 15 sha256 = "sha256-11K7Tl7PE98nM2vGsa+OKIJYu0Wmv8dT700PDt9RRVk="; 16 }; 17 18 # QuTiP says it needs specific (old) Numpy versions. We overwrite them here 19 # as the tests work perfectly fine with up-to-date packages. 20 postPatch = '' 21 substituteInPlace setup.cfg --replace "numpy>=1.16.6,<1.20" "numpy>=1.16.6" 22 ''; 23 24 # Disabling OpenMP support on Darwin. 25 setupPyGlobalFlags = lib.optional (!stdenv.isDarwin) "--with-openmp"; 26 27 propagatedBuildInputs = [ 28 packaging 29 numpy 30 cython 31 scipy 32 matplotlib 33 ]; 34 35 checkInputs = [ 36 pytestCheckHook 37 pytest-rerunfailures 38 ]; 39 40 # test suite is very cpu intensive 41 inherit doCheck; 42 # - QuTiP tries to access the home directory to create an rc file for us. 43 # This of course fails and therefore, we provide a writable temp dir as HOME. 44 # - We need to go to another directory to run the tests from there. 45 # This is due to the Cython-compiled modules not being in the correct location 46 # of the source tree. 47 # - For running tests, see: 48 # https://qutip.org/docs/latest/installation.html#verifying-the-installation 49 checkPhase = '' 50 export OMP_NUM_THREADS=$NIX_BUILD_CORES 51 export HOME=$(mktemp -d) 52 mkdir -p test && cd test 53 ${python.interpreter} -c "import qutip.testing; qutip.testing.run()" 54 ''; 55 56 pythonImportsCheck = [ "qutip" ]; 57 58 passthru.tests = { 59 all-tests = self.override { doCheck = true; }; 60 }; 61 62 meta = with lib; { 63 broken = (stdenv.isLinux && stdenv.isAarch64); 64 description = "Open-source software for simulating the dynamics of closed and open quantum systems"; 65 homepage = "https://qutip.org/"; 66 license = licenses.bsd3; 67 maintainers = [ maintainers.fabiangd ]; 68 }; 69 }; 70in self