python3Packages.qiskit-aer: fix build

This commit is contained in:
kilianar
2025-11-25 14:17:27 +01:00
parent 27d5c0175f
commit 40fb3af3c3
@@ -3,154 +3,83 @@
pythonOlder,
buildPythonPackage,
fetchFromGitHub,
# C Inputs
blas,
catch2,
cmake,
cython,
fmt,
muparserx,
ninja,
nlohmann_json,
spdlog,
# Python Inputs
cvxpy,
numpy,
pybind11,
scikit-build,
# Check Inputs
pytestCheckHook,
ddt,
fixtures,
pytest-timeout,
qiskit,
testtools,
psutil,
scipy,
python-dateutil,
}:
buildPythonPackage rec {
pname = "qiskit-aer";
version = "0.17.1";
format = "pyproject";
disabled = pythonOlder "3.6";
version = "0.17.2";
pyproject = true;
src = fetchFromGitHub {
owner = "Qiskit";
repo = "qiskit-aer";
tag = version;
hash = "sha256-jvapuARJUHgAKFUzGb5MUft01LNefVIXtStJqFnCo90=";
hash = "sha256-aVmGoLMnDjV3iB9s4tvcL62zKvH/p70mqeGsxHzi3nc=";
};
dontUseCmakeConfigure = true;
# build fails even if setting DISABLE_CONAN flag
postPatch = ''
substituteInPlace setup.py \
--replace "'cmake!=3.17,!=3.17.0'," "" \
--replace "'pybind11', min_version='2.6'" "'pybind11'" \
--replace "pybind11>=2.6" "pybind11" \
--replace "scikit-build>=0.11.0" "scikit-build" \
--replace "min_version='0.11.0'" ""
sed -i -e '/conan/d' pyproject.toml
'';
nativeBuildInputs = [
cmake
ninja
];
build-system = [
pybind11
scikit-build
];
dependencies = [
scipy
numpy
psutil
python-dateutil
qiskit
];
buildInputs = [
blas
catch2
nlohmann_json
fmt
muparserx
spdlog
];
propagatedBuildInputs = [
cvxpy
cython # generates some cython files at runtime that need to be cython-ized
numpy
pybind11
];
preBuild = ''
export DISABLE_CONAN=1
export DISABLE_CONAN=ON
'';
dontUseCmakeConfigure = true;
# *** Testing ***
pythonImportsCheck = [
"qiskit.providers.aer"
"qiskit.providers.aer.backends.qasm_simulator"
"qiskit.providers.aer.backends.controller_wrappers" # Checks C++ files built correctly. Only exists if built & moved to output
"qiskit_aer"
"qiskit_aer.primitives"
"qiskit_aer.noise"
"qiskit_aer.library"
"qiskit_aer.backends.controller_wrappers"
];
disabledTests = [
# these tests don't work with cvxpy >= 1.1.15
"test_clifford"
"test_approx_random"
"test_snapshot" # TODO: these ~30 tests fail on setup due to pytest fixture issues?
"test_initialize_2" # TODO: simulations appear incorrect, off by >10%.
"test_pauli_error_2q_gate_from_string_1qonly"
doCheck = false;
# these fail for some builds. Haven't been able to reproduce error locally.
"test_kraus_gate_noise"
"test_backend_method_clifford_circuits_and_kraus_noise"
"test_backend_method_nonclifford_circuit_and_kraus_noise"
"test_kraus_noise_fusion"
# Slow tests
"test_paulis_1_and_2_qubits"
"test_3d_oscillator"
"_057"
"_136"
"_137"
"_139"
"_138"
"_140"
"_141"
"_143"
"_144"
"test_sparse_output_probabilities"
"test_reset_2_qubit"
# Fails with 0.10.4
"test_extended_stabilizer_sparse_output_probs"
];
nativeCheckInputs = [
pytestCheckHook
ddt
fixtures
pytest-timeout
qiskit
testtools
];
pytestFlags = [
"--timeout=30"
"--durations=10"
];
preCheck = ''
# Tests include a compiled "circuit" which is auto-built in $HOME
export HOME=$(mktemp -d)
# move tests b/c by default try to find (missing) cython-ized code in /build/source dir
cp -r $TMP/$sourceRoot/test $HOME
# Add qiskit-aer compiled files to cython include search
pushd $HOME
'';
postCheck = "popd";
meta = with lib; {
broken = true;
meta = {
description = "High performance simulators for Qiskit";
homepage = "https://qiskit.org/aer";
homepage = "https://qiskit.github.io/qiskit-aer/";
downloadPage = "https://github.com/QISKit/qiskit-aer/releases";
changelog = "https://qiskit.org/documentation/release_notes.html";
license = licenses.asl20;
changelog = "https://qiskit.github.io/qiskit-aer/release_notes.html";
license = lib.licenses.asl20;
maintainers = [ ];
};
}