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