2020-01-21 19:29:57 +00:00
|
|
|
{ lib
|
|
|
|
, pythonOlder
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, cvxpy
|
|
|
|
, cython
|
|
|
|
, numpy
|
|
|
|
, openblas
|
|
|
|
, pybind11
|
|
|
|
, scikit-build
|
|
|
|
, spdlog
|
|
|
|
# Check Inputs
|
|
|
|
, qiskit-terra
|
|
|
|
, pytestCheckHook
|
|
|
|
, python
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "qiskit-aer";
|
2020-04-10 19:54:23 +01:00
|
|
|
version = "0.5.0";
|
2020-01-21 19:29:57 +00:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.5";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Qiskit";
|
2020-04-10 19:54:23 +01:00
|
|
|
repo = "qiskit-aer";
|
2020-01-21 19:29:57 +00:00
|
|
|
rev = version;
|
|
|
|
fetchSubmodules = true; # fetch muparserx and other required libraries
|
2020-04-10 19:54:23 +01:00
|
|
|
sha256 = "05lsirrdnnr5yqhwkgv08d9aib8xq4xpd6aq2pfqsi9qkii2fff1";
|
2020-01-21 19:29:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
scikit-build
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
openblas
|
|
|
|
spdlog
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
cvxpy
|
|
|
|
cython # generates some cython files at runtime that need to be cython-ized
|
|
|
|
numpy
|
|
|
|
pybind11
|
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
# remove dependency on PyPi cmake package, which isn't in Nixpkgs
|
2020-04-10 19:54:23 +01:00
|
|
|
substituteInPlace setup.py --replace "'cmake!=3.17,!=3.17.0'" ""
|
2020-01-21 19:29:57 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
dontUseCmakeConfigure = true;
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_TESTS=True"
|
|
|
|
"-DAER_THRUST_BACKEND=OMP"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Needed to find qiskit.providers.aer modules in cython. This exists in GitHub, don't know why it isn't copied by default
|
|
|
|
postFixup = ''
|
|
|
|
touch $out/${python.sitePackages}/qiskit/__init__.pxd
|
|
|
|
'';
|
|
|
|
|
|
|
|
# *** 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
|
|
|
|
];
|
|
|
|
checkInputs = [
|
|
|
|
qiskit-terra
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
|
|
|
dontUseSetuptoolsCheck = true; # Otherwise runs tests twice
|
|
|
|
|
|
|
|
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 test $HOME
|
|
|
|
|
|
|
|
# Add qiskit-aer compiled files to cython include search
|
|
|
|
pushd $HOME
|
|
|
|
'';
|
|
|
|
postCheck = ''
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "High performance simulators for Qiskit";
|
2020-04-10 19:54:23 +01:00
|
|
|
homepage = "https://qiskit.org/aer";
|
|
|
|
downloadPage = "https://github.com/QISKit/qiskit-aer/releases";
|
2020-01-21 19:29:57 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ drewrisinger ];
|
2020-04-06 17:03:07 +01:00
|
|
|
# Doesn't build on aarch64 (libmuparserx issue).
|
|
|
|
# Can fix by building muparserx from source (https://github.com/beltoforion/muparserx)
|
|
|
|
# or in future updates (e.g. Raspberry Pi enabled via https://github.com/Qiskit/qiskit-aer/pull/651 & https://github.com/Qiskit/qiskit-aer/pull/660)
|
|
|
|
platforms = platforms.x86_64;
|
2020-01-21 19:29:57 +00:00
|
|
|
};
|
|
|
|
}
|