25 , withVisualization ? false
26 # Python visualization requirements, optional
34 # Crosstalk-adaptive layout pass
35 , withCrosstalkPass ? false
47 visualizationPackages = [
56 crosstalkPackages = [ z3 ];
59 buildPythonPackage rec {
60 pname = "qiskit-terra";
63 disabled = pythonOlder "3.7";
65 src = fetchFromGitHub {
68 rev = "refs/tags/${version}";
69 hash = "sha256-4/LVKDNxKsRztCtU/mMfKMVHHJqfadZXmxeOlnlz9Tc=";
72 nativeBuildInputs = [ setuptools-rust rustc cargo rustPlatform.cargoSetupHook ];
74 cargoDeps = rustPlatform.fetchCargoTarball {
76 name = "${pname}-${version}";
77 hash = "sha256-SXC0UqWjWqLlZvKCRBylSX73r4Vale130KzS0zM8gjQ=";
80 propagatedBuildInputs = [
95 ] ++ lib.optionals withVisualization visualizationPackages
96 ++ lib.optionals withCrosstalkPass crosstalkPackages;
105 ] ++ lib.optionals (!withVisualization) visualizationPackages;
107 pythonImportsCheck = [
112 disabledTestPaths = [
113 "test/randomized/test_transpiler_equivalence.py" # collection requires qiskit-aer, which would cause circular dependency
114 # These tests are nondeterministic and can randomly fail.
115 # We ignore them here for deterministic building.
117 # These tests consistently fail on GitHub Actions build
118 "test/python/quantum_info/operators/test_random.py"
120 pytestFlagsArray = [ "--durations=10" ];
122 "TestUnitarySynthesisPlugin" # use unittest mocks for transpiler.run(), seems incompatible somehow w/ pytest infrastructure
123 # matplotlib tests seems to fail non-deterministically
124 "TestMatplotlibDrawer"
125 "TestGraphMatplotlibDrawer"
126 "test_copy" # assertNotIn doesn't seem to work as expected w/ pytest vs unittest
129 "test_pulse_limits" # Fails on GitHub Actions, probably due to minor floating point arithmetic error.
130 "test_cx_equivalence" # Fails due to flaky test
131 "test_two_qubit_synthesis_not_pulse_optimal" # test of random circuit, seems to randomly fail depending on seed
132 "test_qv_natural" # fails due to sign error. Not sure why
133 ] ++ lib.optionals (lib.versionAtLeast matplotlib.version "3.4.0") [
134 "test_plot_circuit_layout"
136 # Disabling slow tests for build constraints
139 "test_controlled_random_unitary"
140 "test_controlled_standard_gates_1"
141 "test_jupyter_jobs_pbars"
142 "test_lookahead_swap_higher_depth_width_is_better"
143 "test_move_measurements"
145 "test_wait_for_final_state"
146 "test_multi_controlled_y_rotation_matrix_basic_mode"
147 "test_two_qubit_weyl_decomposition_abc"
151 "test_random_clifford_valid"
153 "test_block_collection_reduces_1q_gate"
154 "test_multi_controlled_rotation_gate_matrices"
155 "test_block_collection_runs_for_non_cx_bases"
156 "test_with_two_qubit_reduction"
157 "test_basic_aer_qasm"
159 "test_H2_hamiltonian"
160 "test_max_evals_grouped_2"
161 "test_qaoa_qc_mixer_4"
162 "test_abelian_grouper_random_2"
163 "test_pauli_two_design"
164 "test_shor_factoring"
165 "test_sample_counts_memory_ghz"
166 "test_two_qubit_weyl_decomposition_ab0"
167 "test_sample_counts_memory_superposition"
168 "test_piecewise_polynomial_function"
169 "test_piecewise_chebyshev_mutability"
170 "test_bit_conditional_no_cregbundle"
171 "test_gradient_wrapper2"
172 "test_two_qubit_weyl_decomposition_abmb"
173 "test_two_qubit_weyl_decomposition_abb"
175 "test_dag_from_networkx"
176 "test_defaults_to_dict_46"
179 # Moves tests to $PACKAGEDIR/test. They can't be run from /build because of finding
180 # cythonized modules and expecting to find some resource files in the test directory.
182 export PACKAGEDIR=$out/${python.sitePackages}
183 echo "Moving Qiskit test files to package directory"
184 cp -r $TMP/$sourceRoot/test $PACKAGEDIR
185 cp -r $TMP/$sourceRoot/examples $PACKAGEDIR
187 # run pytest from Nix's $out path
198 broken = true; # tests segfault python
199 description = "Provides the foundations for Qiskit.";
201 Allows the user to write quantum circuits easily, and takes care of the constraints of real hardware.
203 homepage = "https://qiskit.org/terra";
204 downloadPage = "https://github.com/QISKit/qiskit-terra/releases";
205 changelog = "https://qiskit.org/documentation/release_notes.html";
206 license = licenses.asl20;
207 maintainers = with maintainers; [ drewrisinger ];