summary refs log tree commit diff
path: root/pkgs/development/python-modules/qutip/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/qutip/default.nix')
-rw-r--r--pkgs/development/python-modules/qutip/default.nix137
1 files changed, 79 insertions, 58 deletions
diff --git a/pkgs/development/python-modules/qutip/default.nix b/pkgs/development/python-modules/qutip/default.nix
index 75c186fc835..e99deef489f 100644
--- a/pkgs/development/python-modules/qutip/default.nix
+++ b/pkgs/development/python-modules/qutip/default.nix
@@ -1,70 +1,91 @@
-{ lib, stdenv, fetchFromGitHub, buildPythonPackage, python, packaging, numpy
-, cython, scipy, matplotlib, pytestCheckHook, pytest-rerunfailures
-, doCheck ? false
+{ lib
+, stdenv
+, buildPythonPackage
+, cvxopt
+, cvxpy
+, cython
+, doCheck ? true
+, fetchFromGitHub
+, matplotlib
+, numpy
+, packaging
+, pytest-rerunfailures
+, pytestCheckHook
+, python
+, pythonOlder
+, scipy
 }:
 
-let
-  self = buildPythonPackage rec {
-    pname = "qutip";
-    version = "4.6.3";
+buildPythonPackage rec {
+  pname = "qutip";
+  version = "4.7.0";
+  format = "setuptools";
 
-    src = fetchFromGitHub {
-      owner = pname;
-      repo = pname;
-      rev = "v${version}";
-      sha256 = "sha256-11K7Tl7PE98nM2vGsa+OKIJYu0Wmv8dT700PDt9RRVk=";
-    };
+  disabled = pythonOlder "3.7";
 
-    # 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"
-    '';
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-wGr6uTM6pFL2nvN4zdqPdEO8O3kjrRtKWx8luL1t9Sw=";
+  };
 
-    # Disabling OpenMP support on Darwin.
-    setupPyGlobalFlags = lib.optional (!stdenv.isDarwin) "--with-openmp";
+  nativeBuildInputs = [
+    cython
+  ];
 
-    propagatedBuildInputs = [
-      packaging
-      numpy
-      cython
-      scipy
-      matplotlib
-    ];
+  propagatedBuildInputs = [
+    numpy
+    packaging
+    scipy
+  ];
 
-    checkInputs = [
-      pytestCheckHook
-      pytest-rerunfailures
-    ];
+  checkInputs = [
+    pytestCheckHook
+    pytest-rerunfailures
+  ] ++ passthru.optional-dependencies.graphics;
+
+  # Disabling OpenMP support on Darwin.
+  setupPyGlobalFlags = lib.optional (!stdenv.isDarwin) [
+    "--with-openmp"
+  ];
 
-    # test suite is very cpu intensive
-    inherit doCheck;
-    # - 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()"
-    '';
+  # QuTiP tries to access the home directory to create an rc file for us.
+  # 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.
+  preCheck = ''
+    export HOME=$(mktemp -d);
+    export OMP_NUM_THREADS=$NIX_BUILD_CORES
+    mkdir -p test && cd test
+  '';
 
-    pythonImportsCheck = [ "qutip" ];
+  # For running tests, see https://qutip.org/docs/latest/installation.html#verifying-the-installation
+  checkPhase = ''
+    runHook preCheck
+    ${python.interpreter} -c "import qutip.testing; qutip.testing.run()"
+    runHook postCheck
+  '';
 
-    passthru.tests = {
-      all-tests = self.override { doCheck = true; };
-    };
+  pythonImportsCheck = [
+    "qutip"
+  ];
+
+  passthru.optional-dependencies = {
+    graphics = [
+      matplotlib
+    ];
+    semidefinite = [
+      cvxpy
+      cvxopt
+    ];
+  };
 
-    meta = with lib; {
-      broken = (stdenv.isLinux && stdenv.isAarch64);
-      description = "Open-source software for simulating the dynamics of closed and open quantum systems";
-      homepage = "https://qutip.org/";
-      license = licenses.bsd3;
-      maintainers = [ maintainers.fabiangd ];
-    };
+  meta = with lib; {
+    broken = (stdenv.isLinux && stdenv.isAarch64);
+    description = "Open-source software for simulating the dynamics of closed and open quantum systems";
+    homepage = "https://qutip.org/";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ fabiangd ];
   };
-in self
+}