2022-06-26 10:26:21 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, cvxopt
|
|
|
|
, cvxpy
|
|
|
|
, cython
|
|
|
|
, fetchFromGitHub
|
2023-01-20 10:41:00 +00:00
|
|
|
, ipython
|
2022-06-26 10:26:21 +00:00
|
|
|
, matplotlib
|
|
|
|
, numpy
|
|
|
|
, packaging
|
|
|
|
, pytest-rerunfailures
|
|
|
|
, pytestCheckHook
|
|
|
|
, python
|
|
|
|
, pythonOlder
|
|
|
|
, scipy
|
2022-04-15 01:41:22 +00:00
|
|
|
}:
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "qutip";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "4.7.2";
|
2022-06-26 10:26:21 +00:00
|
|
|
format = "setuptools";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2022-12-28 21:21:41 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-qItj+MSiFKBgRiz/1+AWsmMzdaQs6rFT1FWWHbReudY=";
|
2022-06-26 10:26:21 +00:00
|
|
|
};
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cython
|
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
|
|
|
packaging
|
|
|
|
scipy
|
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-06-26 10:26:21 +00:00
|
|
|
pytestCheckHook
|
|
|
|
pytest-rerunfailures
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
|
2022-06-26 10:26:21 +00:00
|
|
|
|
|
|
|
# Disabling OpenMP support on Darwin.
|
2022-10-30 15:09:59 +00:00
|
|
|
setupPyGlobalFlags = lib.optionals (!stdenv.isDarwin) [
|
2022-06-26 10:26:21 +00:00
|
|
|
"--with-openmp"
|
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
# 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
|
|
|
|
'';
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
# 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
|
|
|
|
'';
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"qutip"
|
|
|
|
];
|
|
|
|
|
|
|
|
passthru.optional-dependencies = {
|
|
|
|
graphics = [
|
|
|
|
matplotlib
|
|
|
|
];
|
2023-01-20 10:41:00 +00:00
|
|
|
ipython = [
|
|
|
|
ipython
|
|
|
|
];
|
2022-06-26 10:26:21 +00:00
|
|
|
semidefinite = [
|
|
|
|
cvxpy
|
|
|
|
cvxopt
|
|
|
|
];
|
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Open-source software for simulating the dynamics of closed and open quantum systems";
|
|
|
|
homepage = "https://qutip.org/";
|
2023-07-15 17:15:38 +00:00
|
|
|
changelog = "https://github.com/qutip/qutip/releases/tag/v${version}";
|
2022-06-26 10:26:21 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ fabiangd ];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2022-06-26 10:26:21 +00:00
|
|
|
}
|