1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
{ stdenv
, lib
, pythonOlder
, buildPythonPackage
, fetchFromGitHub
, rustPlatform
# Python requirements
, dill
, numpy
, networkx
, ply
, psutil
, python-constraint
, python-dateutil
, retworkx
, scipy
, scikit-quant ? null
, setuptools-rust
, stevedore
, symengine
, sympy
, tweedledum
, withVisualization ? false
# Python visualization requirements, optional
, ipywidgets
, matplotlib
, pillow
, pydot
, pygments
, pylatexenc
, seaborn
# Crosstalk-adaptive layout pass
, withCrosstalkPass ? false
, z3
# test requirements
, ddt
, hypothesis
, nbformat
, nbconvert
, pytestCheckHook
, python
}:
let
visualizationPackages = [
ipywidgets
matplotlib
pillow
pydot
pygments
pylatexenc
seaborn
];
crosstalkPackages = [ z3 ];
in
buildPythonPackage rec {
pname = "qiskit-terra";
version = "0.21.0";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "qiskit";
repo = pname;
rev = version;
hash = "sha256-imktzBpgP+lq6FsVWIUK82+t76gKTgt53kPfKOnsseQ=";
};
nativeBuildInputs = [ setuptools-rust ] ++ (with rustPlatform; [ rust.rustc rust.cargo cargoSetupHook ]);
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
name = "${pname}-${version}";
hash = "sha256-SXC0UqWjWqLlZvKCRBylSX73r4Vale130KzS0zM8gjQ=";
};
propagatedBuildInputs = [
dill
numpy
networkx
ply
psutil
python-constraint
python-dateutil
retworkx
scipy
scikit-quant
stevedore
symengine
sympy
tweedledum
] ++ lib.optionals withVisualization visualizationPackages
++ lib.optionals withCrosstalkPass crosstalkPackages;
# *** Tests ***
checkInputs = [
pytestCheckHook
ddt
hypothesis
nbformat
nbconvert
] ++ lib.optionals (!withVisualization) visualizationPackages;
pythonImportsCheck = [
"qiskit"
"qiskit.pulse"
];
disabledTestPaths = [
"test/randomized/test_transpiler_equivalence.py" # collection requires qiskit-aer, which would cause circular dependency
# These tests are nondeterministic and can randomly fail.
# We ignore them here for deterministic building.
"test/randomized/"
# These tests consistently fail on GitHub Actions build
"test/python/quantum_info/operators/test_random.py"
];
pytestFlagsArray = [ "--durations=10" ];
disabledTests = [
"TestUnitarySynthesisPlugin" # use unittest mocks for transpiler.run(), seems incompatible somehow w/ pytest infrastructure
# matplotlib tests seems to fail non-deterministically
"TestMatplotlibDrawer"
"TestGraphMatplotlibDrawer"
"test_copy" # assertNotIn doesn't seem to work as expected w/ pytest vs unittest
# Flaky tests
"test_pulse_limits" # Fails on GitHub Actions, probably due to minor floating point arithmetic error.
"test_cx_equivalence" # Fails due to flaky test
"test_two_qubit_synthesis_not_pulse_optimal" # test of random circuit, seems to randomly fail depending on seed
"test_qv_natural" # fails due to sign error. Not sure why
] ++ lib.optionals (lib.versionAtLeast matplotlib.version "3.4.0") [
"test_plot_circuit_layout"
]
# Disabling slow tests for build constraints
++ [
"test_all_examples"
"test_controlled_random_unitary"
"test_controlled_standard_gates_1"
"test_jupyter_jobs_pbars"
"test_lookahead_swap_higher_depth_width_is_better"
"test_move_measurements"
"test_job_monitor"
"test_wait_for_final_state"
"test_multi_controlled_y_rotation_matrix_basic_mode"
"test_two_qubit_weyl_decomposition_abc"
"test_isometry"
"test_parallel"
"test_random_state"
"test_random_clifford_valid"
"test_to_matrix"
"test_block_collection_reduces_1q_gate"
"test_multi_controlled_rotation_gate_matrices"
"test_block_collection_runs_for_non_cx_bases"
"test_with_two_qubit_reduction"
"test_basic_aer_qasm"
"test_hhl"
"test_H2_hamiltonian"
"test_max_evals_grouped_2"
"test_qaoa_qc_mixer_4"
"test_abelian_grouper_random_2"
"test_pauli_two_design"
"test_shor_factoring"
"test_sample_counts_memory_ghz"
"test_two_qubit_weyl_decomposition_ab0"
"test_sample_counts_memory_superposition"
"test_piecewise_polynomial_function"
"test_piecewise_chebyshev_mutability"
"test_bit_conditional_no_cregbundle"
"test_gradient_wrapper2"
"test_two_qubit_weyl_decomposition_abmb"
"test_two_qubit_weyl_decomposition_abb"
"test_vqe_qasm"
"test_dag_from_networkx"
"test_defaults_to_dict_46"
];
# Moves tests to $PACKAGEDIR/test. They can't be run from /build because of finding
# cythonized modules and expecting to find some resource files in the test directory.
preCheck = ''
export PACKAGEDIR=$out/${python.sitePackages}
echo "Moving Qiskit test files to package directory"
cp -r $TMP/$sourceRoot/test $PACKAGEDIR
cp -r $TMP/$sourceRoot/examples $PACKAGEDIR
# run pytest from Nix's $out path
pushd $PACKAGEDIR
'';
postCheck = ''
rm -r test
rm -r examples
popd
'';
meta = with lib; {
broken = true; # tests segfault python
description = "Provides the foundations for Qiskit.";
longDescription = ''
Allows the user to write quantum circuits easily, and takes care of the constraints of real hardware.
'';
homepage = "https://qiskit.org/terra";
downloadPage = "https://github.com/QISKit/qiskit-terra/releases";
changelog = "https://qiskit.org/documentation/release_notes.html";
license = licenses.asl20;
maintainers = with maintainers; [ drewrisinger ];
};
}
|