From 404254c829ff2e2e87acd5943ce178ec7d753ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20G=2E=20Dr=C3=B6ge?= Date: Mon, 1 Nov 2021 16:47:37 +0100 Subject: [PATCH] python3Packages.qutip: init at 4.6.2 --- .../python-modules/qutip/default.nix | 57 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 59 insertions(+) create mode 100644 pkgs/development/python-modules/qutip/default.nix diff --git a/pkgs/development/python-modules/qutip/default.nix b/pkgs/development/python-modules/qutip/default.nix new file mode 100644 index 000000000000..38cf79e19049 --- /dev/null +++ b/pkgs/development/python-modules/qutip/default.nix @@ -0,0 +1,57 @@ +{ lib, stdenv, fetchFromGitHub, buildPythonPackage, python, packaging, numpy +, cython, scipy, matplotlib, pytestCheckHook, pytest-rerunfailures }: + +buildPythonPackage rec { + pname = "qutip"; + version = "4.6.2"; + + src = fetchFromGitHub { + owner = pname; + repo = pname; + rev = "v${version}"; + sha256 = "04g7ixq1yrrid4lliqbcamnzyw5r0fjbl8ipklps234hvsjfwmxb"; + }; + + # QuTiP says it needs specific (old) Numpy versions. We overwrite them here + # as the tests work perfectly fine with up-to-date packages. + postPatch = '' + substituteInPlace setup.cfg --replace "numpy>=1.16.6,<1.20" "numpy>=1.16.6" + ''; + + # Disabling OpenMP support on Darwin. + setupPyGlobalFlags = lib.optional (!stdenv.isDarwin) "--with-openmp"; + + propagatedBuildInputs = [ + packaging + numpy + cython + scipy + matplotlib + ]; + + checkInputs = [ + pytestCheckHook + pytest-rerunfailures + ]; + + # - QuTiP tries to access the home directory to create an rc file for us. + # This of course fails and therefore, we provide a writable temp dir as HOME. + # - We need to go to another directory to run the tests from there. + # This is due to the Cython-compiled modules not being in the correct location + # of the source tree. + # - For running tests, see: + # https://qutip.org/docs/latest/installation.html#verifying-the-installation + checkPhase = '' + export OMP_NUM_THREADS=$NIX_BUILD_CORES + export HOME=$(mktemp -d) + mkdir -p test && cd test + ${python.interpreter} -c "import qutip.testing; qutip.testing.run()" + ''; + + meta = with lib; { + description = "Open-source software for simulating the dynamics of closed and open quantum systems"; + homepage = "https://qutip.org/"; + license = licenses.bsd3; + maintainers = [ maintainers.fabiangd ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 9b14f94f6a79..0dc13e907c64 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7896,6 +7896,8 @@ in { queuelib = callPackage ../development/python-modules/queuelib { }; + qutip = callPackage ../development/python-modules/qutip { }; + qmk-dotty-dict = callPackage ../development/python-modules/qmk-dotty-dict { }; r2pipe = callPackage ../development/python-modules/r2pipe { };