28 withVisualization ? false,
29 # Python visualization requirements, optional
37 # Crosstalk-adaptive layout pass
38 withCrosstalkPass ? false,
50 visualizationPackages = [
59 crosstalkPackages = [ z3-solver ];
62 buildPythonPackage rec {
63 pname = "qiskit-terra";
65 format = "setuptools";
67 disabled = pythonOlder "3.7" || pythonAtLeast "3.11";
69 src = fetchFromGitHub {
72 rev = "refs/tags/${version}";
73 hash = "sha256-4/LVKDNxKsRztCtU/mMfKMVHHJqfadZXmxeOlnlz9Tc=";
80 rustPlatform.cargoSetupHook
83 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
85 cargoDeps = rustPlatform.fetchCargoTarball {
87 name = "${pname}-${version}";
88 hash = "sha256-f5VLNxv9DKwfRy5zacydfz4Zrkbiee7JecOAbVelSto=";
91 propagatedBuildInputs =
108 ++ lib.optionals withVisualization visualizationPackages
109 ++ lib.optionals withCrosstalkPass crosstalkPackages;
112 nativeCheckInputs = [
118 ] ++ lib.optionals (!withVisualization) visualizationPackages;
120 pythonImportsCheck = [
125 disabledTestPaths = [
126 "test/randomized/test_transpiler_equivalence.py" # collection requires qiskit-aer, which would cause circular dependency
127 # These tests are nondeterministic and can randomly fail.
128 # We ignore them here for deterministic building.
130 # These tests consistently fail on GitHub Actions build
131 "test/python/quantum_info/operators/test_random.py"
132 # Too many floating point arithmetic errors
133 "test/visual/mpl/circuit/test_circuit_matplotlib_drawer.py"
135 pytestFlagsArray = [ "--durations=10" ];
138 "TestUnitarySynthesisPlugin" # use unittest mocks for transpiler.run(), seems incompatible somehow w/ pytest infrastructure
139 # matplotlib tests seems to fail non-deterministically
140 "TestMatplotlibDrawer"
141 "TestGraphMatplotlibDrawer"
142 "test_copy" # assertNotIn doesn't seem to work as expected w/ pytest vs unittest
144 "test_bound_pass_manager" # AssertionError: 0 != 2
145 "test_complex_parameter_bound_to_real" # qiskit.circuit.exceptions.CircuitError: "Invalid param type <class 'complex'> for gate rx."
146 "test_expressions_of_parameter_with_constant" # Floating point arithmetic error
147 "test_handle_measurement" # AssertionError: The two circuits are not equal
150 "test_pulse_limits" # Fails on GitHub Actions, probably due to minor floating point arithmetic error.
151 "test_cx_equivalence" # Fails due to flaky test
152 "test_two_qubit_synthesis_not_pulse_optimal" # test of random circuit, seems to randomly fail depending on seed
153 "test_qv_natural" # fails due to sign error. Not sure why
155 ++ lib.optionals (lib.versionAtLeast matplotlib.version "3.4.0") [ "test_plot_circuit_layout" ]
156 # Disabling slow tests for build constraints
159 "test_controlled_random_unitary"
160 "test_controlled_standard_gates_1"
161 "test_jupyter_jobs_pbars"
162 "test_lookahead_swap_higher_depth_width_is_better"
163 "test_move_measurements"
165 "test_wait_for_final_state"
166 "test_multi_controlled_y_rotation_matrix_basic_mode"
167 "test_two_qubit_weyl_decomposition_abc"
171 "test_random_clifford_valid"
173 "test_block_collection_reduces_1q_gate"
174 "test_multi_controlled_rotation_gate_matrices"
175 "test_block_collection_runs_for_non_cx_bases"
176 "test_with_two_qubit_reduction"
177 "test_basic_aer_qasm"
179 "test_H2_hamiltonian"
180 "test_max_evals_grouped_2"
181 "test_qaoa_qc_mixer_4"
182 "test_abelian_grouper_random_2"
183 "test_pauli_two_design"
184 "test_shor_factoring"
185 "test_sample_counts_memory_ghz"
186 "test_two_qubit_weyl_decomposition_ab0"
187 "test_sample_counts_memory_superposition"
188 "test_piecewise_polynomial_function"
189 "test_piecewise_chebyshev_mutability"
190 "test_bit_conditional_no_cregbundle"
191 "test_gradient_wrapper2"
192 "test_two_qubit_weyl_decomposition_abmb"
193 "test_two_qubit_weyl_decomposition_abb"
195 "test_dag_from_networkx"
196 "test_defaults_to_dict_46"
199 # Moves tests to $PACKAGEDIR/test. They can't be run from /build because of finding
200 # cythonized modules and expecting to find some resource files in the test directory.
202 export PACKAGEDIR=$out/${python.sitePackages}
203 echo "Moving Qiskit test files to package directory"
204 cp -r $TMP/$sourceRoot/test $PACKAGEDIR
205 cp -r $TMP/$sourceRoot/examples $PACKAGEDIR
207 # run pytest from Nix's $out path
217 description = "Provides the foundations for Qiskit";
219 Allows the user to write quantum circuits easily, and takes care of the constraints of real hardware.
221 homepage = "https://qiskit.org/terra";
222 downloadPage = "https://github.com/QISKit/qiskit-terra/releases";
223 changelog = "https://qiskit.org/documentation/release_notes.html";
224 license = licenses.asl20;
225 maintainers = with maintainers; [ drewrisinger ];