2020-01-21 18:23:08 +00:00
|
|
|
{ lib
|
|
|
|
, pythonOlder
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2020-06-22 21:10:11 +00:00
|
|
|
, cvxpy
|
2020-01-21 18:23:08 +00:00
|
|
|
, dlx
|
|
|
|
, docplex
|
|
|
|
, fastdtw
|
|
|
|
, h5py
|
|
|
|
, networkx
|
|
|
|
, numpy
|
|
|
|
, psutil
|
|
|
|
, qiskit-ignis
|
|
|
|
, qiskit-terra
|
|
|
|
, quandl
|
2021-05-14 18:46:36 +00:00
|
|
|
, scikit-learn
|
2020-08-10 22:42:50 +00:00
|
|
|
, yfinance
|
2020-11-04 17:45:41 +00:00
|
|
|
# Optional inputs
|
|
|
|
, withTorch ? false
|
|
|
|
, pytorch
|
|
|
|
, withPyscf ? false
|
|
|
|
, pyscf ? null
|
|
|
|
, withScikitQuant ? false
|
|
|
|
, scikit-quant ? null
|
|
|
|
, withCplex ? false
|
|
|
|
, cplex ? null
|
2020-01-21 18:23:08 +00:00
|
|
|
# Check Inputs
|
2020-05-11 21:48:09 +00:00
|
|
|
, ddt
|
2020-01-21 18:23:08 +00:00
|
|
|
, pytestCheckHook
|
2020-11-04 18:03:00 +00:00
|
|
|
, pytest-timeout
|
2020-01-21 18:23:08 +00:00
|
|
|
, qiskit-aer
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "qiskit-aqua";
|
2021-04-27 18:29:50 +00:00
|
|
|
version = "0.9.1";
|
2020-01-21 18:23:08 +00:00
|
|
|
|
2020-11-04 17:45:41 +00:00
|
|
|
disabled = pythonOlder "3.6";
|
2020-01-21 18:23:08 +00:00
|
|
|
|
|
|
|
# Pypi's tarball doesn't contain tests
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Qiskit";
|
|
|
|
repo = "qiskit-aqua";
|
|
|
|
rev = version;
|
2021-04-27 18:29:50 +00:00
|
|
|
hash = "sha256-fptyqPrkUgl3UjtlEmDYORdX/SsONxWozQGEs/EahmU=";
|
2020-01-21 18:23:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Optional packages: pyscf (see below NOTE) & pytorch. Can install via pip/nix if needed.
|
|
|
|
propagatedBuildInputs = [
|
2020-06-22 21:10:11 +00:00
|
|
|
cvxpy
|
2020-01-21 18:23:08 +00:00
|
|
|
docplex
|
|
|
|
dlx # Python Dancing Links package
|
|
|
|
fastdtw
|
|
|
|
h5py
|
|
|
|
networkx
|
|
|
|
numpy
|
|
|
|
psutil
|
|
|
|
qiskit-terra
|
|
|
|
qiskit-ignis
|
|
|
|
quandl
|
2021-05-14 18:46:36 +00:00
|
|
|
scikit-learn
|
2020-08-10 22:42:50 +00:00
|
|
|
yfinance
|
2020-11-04 17:45:41 +00:00
|
|
|
] ++ lib.optionals (withTorch) [ pytorch ]
|
|
|
|
++ lib.optionals (withPyscf) [ pyscf ]
|
|
|
|
++ lib.optionals (withScikitQuant) [ scikit-quant ]
|
|
|
|
++ lib.optionals (withCplex) [ cplex ];
|
2020-01-21 18:23:08 +00:00
|
|
|
|
|
|
|
# *** NOTE ***
|
|
|
|
# We make pyscf optional in this package, due to difficulties packaging it in Nix (test failures, complicated flags, etc).
|
|
|
|
# See nixpkgs#78772, nixpkgs#83447. You are welcome to try to package it yourself,
|
|
|
|
# or use the Nix User Repository version (https://github.com/drewrisinger/nur-packages).
|
|
|
|
# It can also be installed at runtime from the pip wheel.
|
|
|
|
# We disable appropriate tests below to allow building without pyscf installed
|
|
|
|
|
|
|
|
postPatch = ''
|
2021-04-06 15:10:29 +00:00
|
|
|
# Because this is a legacy/final release, the maintainers restricted the maximum
|
|
|
|
# versions of all dependencies to the latest current version. That will not
|
|
|
|
# work with nixpkgs' rolling release/update system.
|
|
|
|
# Unlock all versions for compatibility
|
|
|
|
substituteInPlace setup.py --replace "<=" ">="
|
|
|
|
sed -i 's/\(\w\+-*\w*\).*/\1/' requirements.txt
|
|
|
|
substituteInPlace requirements.txt --replace "dataclasses" ""
|
2020-01-21 18:23:08 +00:00
|
|
|
|
|
|
|
# Add ImportWarning when running qiskit.chemistry (pyscf is a chemistry package) that pyscf is not included
|
2020-05-11 21:48:09 +00:00
|
|
|
echo -e "\nimport warnings\ntry: import pyscf;\nexcept ImportError:\n " \
|
2020-01-21 18:23:08 +00:00
|
|
|
"warnings.warn('pyscf is not supported on Nixpkgs so some qiskit features will fail." \
|
|
|
|
"You must install it yourself via pip or add it to your environment from the Nix User Repository." \
|
|
|
|
"See https://github.com/NixOS/nixpkgs/pull/83447 for details', ImportWarning)\n" \
|
|
|
|
>> qiskit/chemistry/__init__.py
|
2020-05-11 21:48:09 +00:00
|
|
|
|
|
|
|
# Add ImportWarning when running qiskit.optimization that cplex (optimization package) is not included
|
|
|
|
echo -e "\nimport warnings\ntry: import cplex;\nexcept ImportError:\n " \
|
|
|
|
"warnings.warn('cplex is not supported on Nixpkgs so some qiskit features will fail." \
|
|
|
|
"You must install it yourself via pip or add it to your environment from the Nix User Repository." \
|
|
|
|
"', ImportWarning)\n" \
|
|
|
|
>> qiskit/optimization/__init__.py
|
2020-01-21 18:23:08 +00:00
|
|
|
'';
|
|
|
|
|
2020-11-04 17:45:41 +00:00
|
|
|
checkInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
ddt
|
2020-11-04 18:03:00 +00:00
|
|
|
pytest-timeout
|
2020-11-04 17:45:41 +00:00
|
|
|
qiskit-aer
|
|
|
|
];
|
2020-01-21 18:23:08 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"qiskit.aqua"
|
|
|
|
"qiskit.aqua.algorithms"
|
|
|
|
"qiskit.chemistry"
|
|
|
|
"qiskit.finance"
|
|
|
|
"qiskit.ml"
|
|
|
|
"qiskit.optimization"
|
|
|
|
];
|
2020-11-04 18:03:00 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"--timeout=30"
|
|
|
|
"--durations=10"
|
|
|
|
] ++ lib.optionals (!withPyscf) [
|
2020-01-21 18:23:08 +00:00
|
|
|
"--ignore=test/chemistry/test_qeom_ee.py"
|
|
|
|
"--ignore=test/chemistry/test_qeom_vqe.py"
|
|
|
|
"--ignore=test/chemistry/test_vqe_uccsd_adapt.py"
|
2020-11-04 17:45:41 +00:00
|
|
|
"--ignore=test/chemistry/test_bopes_sampler.py"
|
2020-01-21 18:23:08 +00:00
|
|
|
];
|
|
|
|
disabledTests = [
|
2020-08-10 22:42:50 +00:00
|
|
|
# Online tests
|
|
|
|
"test_exchangedata"
|
|
|
|
"test_yahoo"
|
2020-06-22 21:10:11 +00:00
|
|
|
|
2020-04-06 22:26:08 +00:00
|
|
|
# Disabling slow tests > 10 seconds
|
2020-05-11 21:48:09 +00:00
|
|
|
"TestVQE"
|
2020-11-04 17:45:41 +00:00
|
|
|
"TestOOVQE"
|
2020-05-11 21:48:09 +00:00
|
|
|
"TestVQC"
|
|
|
|
"TestQSVM"
|
2020-11-04 17:45:41 +00:00
|
|
|
"TestOptimizerAQGD"
|
2020-04-06 22:26:08 +00:00
|
|
|
"test_graph_partition_vqe"
|
2020-05-11 21:48:09 +00:00
|
|
|
"TestLookupRotation"
|
|
|
|
"_vqe"
|
|
|
|
"TestHHL"
|
|
|
|
"TestQGAN"
|
|
|
|
"test_evaluate_qasm_mode"
|
2020-04-06 22:26:08 +00:00
|
|
|
"test_measurement_error_mitigation_auto_refresh"
|
|
|
|
"test_wikipedia"
|
2020-05-11 21:48:09 +00:00
|
|
|
"test_shor_factoring_1__15___qasm_simulator____3__5__"
|
|
|
|
"test_readme_sample"
|
|
|
|
"test_ecev"
|
|
|
|
"test_expected_value"
|
|
|
|
"test_qubo_gas_int_paper_example"
|
|
|
|
"test_shor_no_factors_1_5"
|
|
|
|
"test_shor_no_factors_2_7"
|
|
|
|
"test_evolve_2___suzuki___1__3_"
|
2020-06-22 21:10:11 +00:00
|
|
|
"test_delta"
|
2020-05-11 21:48:09 +00:00
|
|
|
"test_swaprz"
|
|
|
|
"test_deprecated_algo_result"
|
2020-06-22 21:10:11 +00:00
|
|
|
"test_unsorted_grouping"
|
|
|
|
"test_ad_hoc_data"
|
|
|
|
"test_nft"
|
|
|
|
"test_oh"
|
|
|
|
"test_confidence_intervals_00001"
|
|
|
|
"test_eoh"
|
2020-08-10 22:42:50 +00:00
|
|
|
"test_qasm_5"
|
2020-11-04 17:45:41 +00:00
|
|
|
"test_uccsd_hf"
|
2021-04-27 18:29:50 +00:00
|
|
|
] ++ lib.optionals (!withPyscf) [
|
|
|
|
"test_validate" # test/chemistry/test_inputparser.py
|
2020-01-21 18:23:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "An extensible library of quantum computing algorithms";
|
|
|
|
homepage = "https://github.com/QISKit/qiskit-aqua";
|
2020-08-10 22:42:50 +00:00
|
|
|
changelog = "https://qiskit.org/documentation/release_notes.html";
|
2020-01-21 18:23:08 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ drewrisinger ];
|
|
|
|
};
|
|
|
|
}
|