1{ lib
2, pythonOlder
3, buildPythonPackage
4, fetchFromGitHub
5, fetchpatch
6 # C Inputs
7, blas
8, catch2
9, cmake
10, cython
11, fmt
12, muparserx
13, ninja
14, nlohmann_json
15, spdlog
16 # Python Inputs
17, cvxpy
18, numpy
19, pybind11
20, scikit-build
21 # Check Inputs
22, pytestCheckHook
23, ddt
24, fixtures
25, pytest-timeout
26, qiskit-terra
27, setuptools
28, testtools
29}:
30
31buildPythonPackage rec {
32 pname = "qiskit-aer";
33 version = "0.9.1";
34 format = "pyproject";
35
36 disabled = pythonOlder "3.6";
37
38 src = fetchFromGitHub {
39 owner = "Qiskit";
40 repo = "qiskit-aer";
41 rev = version;
42 sha256 = "sha256-SAJjU2zYz6UabOPV1KI2JB7CbJfUJcjbPKbo6iiCk/g=";
43 };
44
45 postPatch = ''
46 substituteInPlace setup.py \
47 --replace "'cmake!=3.17,!=3.17.0'," "" \
48 --replace "'pybind11', min_version='2.6'" "'pybind11'" \
49 --replace "pybind11>=2.6" "pybind11" \
50 --replace "scikit-build>=0.11.0" "scikit-build" \
51 --replace "min_version='0.11.0'" ""
52 '';
53
54 nativeBuildInputs = [
55 cmake
56 ninja
57 scikit-build
58 pybind11
59 ];
60
61 buildInputs = [
62 blas
63 catch2
64 fmt
65 muparserx
66 nlohmann_json
67 spdlog
68 ];
69
70 propagatedBuildInputs = [
71 cvxpy
72 cython # generates some cython files at runtime that need to be cython-ized
73 numpy
74 ];
75
76 preBuild = ''
77 export DISABLE_CONAN=1
78 '';
79
80 dontUseCmakeConfigure = true;
81
82 # *** Testing ***
83
84 pythonImportsCheck = [
85 "qiskit.providers.aer"
86 "qiskit.providers.aer.backends.qasm_simulator"
87 "qiskit.providers.aer.backends.controller_wrappers" # Checks C++ files built correctly. Only exists if built & moved to output
88 ];
89 # Slow tests
90 disabledTests = [
91 "test_clifford" # fails on cvxpy >= 1.1.15. https://github.com/Qiskit/qiskit-aer/pull/1318. Remove in future.
92 "test_snapshot" # TODO: these ~30 tests fail on setup due to pytest fixture issues?
93 "test_initialize_2" # TODO: simulations appear incorrect, off by >10%.
94
95 # these fail for some builds. Haven't been able to reproduce error locally.
96 "test_kraus_gate_noise"
97 "test_backend_method_clifford_circuits_and_kraus_noise"
98 "test_backend_method_nonclifford_circuit_and_kraus_noise"
99 "test_kraus_noise_fusion"
100
101 # Slow tests
102 "test_paulis_1_and_2_qubits"
103 "test_3d_oscillator"
104 "_057"
105 "_136"
106 "_137"
107 "_139"
108 "_138"
109 "_140"
110 "_141"
111 "_143"
112 "_144"
113 "test_sparse_output_probabilities"
114 "test_reset_2_qubit"
115 ];
116 checkInputs = [
117 pytestCheckHook
118 ddt
119 fixtures
120 pytest-timeout
121 qiskit-terra
122 setuptools # temporary workaround for pbr missing setuptools, see https://github.com/NixOS/nixpkgs/pull/132614
123 testtools
124 ];
125 pytestFlagsArray = [
126 "--timeout=30"
127 "--durations=10"
128 ];
129
130 preCheck = ''
131 # Tests include a compiled "circuit" which is auto-built in $HOME
132 export HOME=$(mktemp -d)
133 # move tests b/c by default try to find (missing) cython-ized code in /build/source dir
134 cp -r $TMP/$sourceRoot/test $HOME
135
136 # Add qiskit-aer compiled files to cython include search
137 pushd $HOME
138 '';
139 postCheck = "popd";
140
141 meta = with lib; {
142 description = "High performance simulators for Qiskit";
143 homepage = "https://qiskit.org/aer";
144 downloadPage = "https://github.com/QISKit/qiskit-aer/releases";
145 changelog = "https://qiskit.org/documentation/release_notes.html";
146 license = licenses.asl20;
147 maintainers = with maintainers; [ drewrisinger ];
148 };
149}