evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / development / python-modules / qutip / default.nix
blob4907fd55075942dddd166993776a89f3f732333f
2   lib,
3   buildPythonPackage,
4   cvxopt,
5   cvxpy,
6   cython_0,
7   fetchFromGitHub,
8   ipython,
9   matplotlib,
10   numpy,
11   oldest-supported-numpy,
12   packaging,
13   pytest-rerunfailures,
14   pytestCheckHook,
15   python,
16   pythonOlder,
17   scipy,
18   setuptools,
21 buildPythonPackage rec {
22   pname = "qutip";
23   version = "5.0.4";
24   pyproject = true;
26   disabled = pythonOlder "3.7";
28   src = fetchFromGitHub {
29     owner = pname;
30     repo = pname;
31     rev = "refs/tags/v${version}";
32     hash = "sha256-KT5Mk0w6EKTUZzGRnQ6XQPZfH5ZXVuiD+EwSflNqHNo=";
33   };
35   postPatch = ''
36     # build-time constriant, used to ensure forward and backward compat
37     substituteInPlace pyproject.toml setup.cfg \
38       --replace-fail "numpy>=2.0.0" "numpy"
39   '';
41   nativeBuildInputs = [
42     cython_0
43     setuptools
44     oldest-supported-numpy
45   ];
47   propagatedBuildInputs = [
48     numpy
49     packaging
50     scipy
51   ];
53   nativeCheckInputs = [
54     pytestCheckHook
55     pytest-rerunfailures
56   ] ++ lib.flatten (builtins.attrValues optional-dependencies);
58   # QuTiP tries to access the home directory to create an rc file for us.
59   # We need to go to another directory to run the tests from there.
60   # This is due to the Cython-compiled modules not being in the correct location
61   # of the source tree.
62   preCheck = ''
63     export HOME=$(mktemp -d);
64     export OMP_NUM_THREADS=$NIX_BUILD_CORES
65     mkdir -p test && cd test
66   '';
68   # For running tests, see https://qutip.org/docs/latest/installation.html#verifying-the-installation
69   checkPhase = ''
70     runHook preCheck
71     ${python.interpreter} -c "import qutip.testing; qutip.testing.run()"
72     runHook postCheck
73   '';
75   pythonImportsCheck = [ "qutip" ];
77   optional-dependencies = {
78     graphics = [ matplotlib ];
79     ipython = [ ipython ];
80     semidefinite = [
81       cvxpy
82       cvxopt
83     ];
84   };
86   meta = with lib; {
87     description = "Open-source software for simulating the dynamics of closed and open quantum systems";
88     homepage = "https://qutip.org/";
89     changelog = "https://github.com/qutip/qutip/releases/tag/v${version}";
90     license = licenses.bsd3;
91     maintainers = with maintainers; [ fabiangd ];
92   };