Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv 2, lib 3, pythonOlder 4, buildPythonPackage 5, fetchFromGitHub 6, fetchpatch 7 # C Inputs 8, blas 9, catch2 10, cmake 11, cython 12, fmt 13, muparserx 14, ninja 15, nlohmann_json 16, spdlog 17 # Python Inputs 18, cvxpy 19, numpy 20, pybind11 21, scikit-build 22 # Check Inputs 23, pytestCheckHook 24, ddt 25, fixtures 26, pytest-timeout 27, qiskit-terra 28, setuptools 29, testtools 30}: 31 32buildPythonPackage rec { 33 pname = "qiskit-aer"; 34 version = "0.11.2"; 35 format = "pyproject"; 36 37 disabled = pythonOlder "3.6"; 38 39 src = fetchFromGitHub { 40 owner = "Qiskit"; 41 repo = "qiskit-aer"; 42 rev = "refs/tags/${version}"; 43 hash = "sha256-ew9ucqOWDztjB+hJTh9WkJiutVBJyVQobtEcWeUwEcw="; 44 }; 45 46 postPatch = '' 47 substituteInPlace setup.py \ 48 --replace "'cmake!=3.17,!=3.17.0'," "" \ 49 --replace "'pybind11', min_version='2.6'" "'pybind11'" \ 50 --replace "pybind11>=2.6" "pybind11" \ 51 --replace "scikit-build>=0.11.0" "scikit-build" \ 52 --replace "min_version='0.11.0'" "" 53 ''; 54 55 nativeBuildInputs = [ 56 cmake 57 ninja 58 scikit-build 59 ]; 60 61 buildInputs = [ 62 blas 63 catch2 64 nlohmann_json 65 fmt 66 muparserx 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 pybind11 75 ]; 76 77 preBuild = '' 78 export DISABLE_CONAN=1 79 ''; 80 81 dontUseCmakeConfigure = true; 82 83 # *** Testing *** 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 90 disabledTests = [ 91 # these tests don't work with cvxpy >= 1.1.15 92 "test_clifford" 93 "test_approx_random" 94 "test_snapshot" # TODO: these ~30 tests fail on setup due to pytest fixture issues? 95 "test_initialize_2" # TODO: simulations appear incorrect, off by >10%. 96 "test_pauli_error_2q_gate_from_string_1qonly" 97 98 # these fail for some builds. Haven't been able to reproduce error locally. 99 "test_kraus_gate_noise" 100 "test_backend_method_clifford_circuits_and_kraus_noise" 101 "test_backend_method_nonclifford_circuit_and_kraus_noise" 102 "test_kraus_noise_fusion" 103 104 # Slow tests 105 "test_paulis_1_and_2_qubits" 106 "test_3d_oscillator" 107 "_057" 108 "_136" 109 "_137" 110 "_139" 111 "_138" 112 "_140" 113 "_141" 114 "_143" 115 "_144" 116 "test_sparse_output_probabilities" 117 "test_reset_2_qubit" 118 119 # Fails with 0.10.4 120 "test_extended_stabilizer_sparse_output_probs" 121 ]; 122 123 nativeCheckInputs = [ 124 pytestCheckHook 125 ddt 126 fixtures 127 pytest-timeout 128 qiskit-terra 129 testtools 130 ]; 131 132 pytestFlagsArray = [ 133 "--timeout=30" 134 "--durations=10" 135 ]; 136 137 preCheck = '' 138 # Tests include a compiled "circuit" which is auto-built in $HOME 139 export HOME=$(mktemp -d) 140 # move tests b/c by default try to find (missing) cython-ized code in /build/source dir 141 cp -r $TMP/$sourceRoot/test $HOME 142 143 # Add qiskit-aer compiled files to cython include search 144 pushd $HOME 145 ''; 146 147 postCheck = "popd"; 148 149 meta = with lib; { 150 broken = (stdenv.isLinux && stdenv.isAarch64); 151 description = "High performance simulators for Qiskit"; 152 homepage = "https://qiskit.org/aer"; 153 downloadPage = "https://github.com/QISKit/qiskit-aer/releases"; 154 changelog = "https://qiskit.org/documentation/release_notes.html"; 155 license = licenses.asl20; 156 maintainers = with maintainers; [ drewrisinger ]; 157 }; 158}