2021-09-18 20:48:54 +02:00
|
|
|
{ lib
|
2021-05-20 00:42:58 +02:00
|
|
|
, buildPythonPackage
|
|
|
|
, pythonOlder
|
|
|
|
, fetchFromGitHub
|
2021-11-12 23:25:16 +01:00
|
|
|
, fetchpatch
|
2021-10-29 21:55:22 +02:00
|
|
|
, duet
|
2021-05-20 00:42:58 +02:00
|
|
|
, matplotlib
|
|
|
|
, networkx
|
|
|
|
, numpy
|
|
|
|
, pandas
|
|
|
|
, requests
|
|
|
|
, scipy
|
|
|
|
, sortedcontainers
|
|
|
|
, sympy
|
|
|
|
, tqdm
|
|
|
|
, typing-extensions
|
|
|
|
# Contrib requirements
|
|
|
|
, withContribRequires ? false
|
|
|
|
, autoray ? null
|
|
|
|
, opt-einsum
|
|
|
|
, ply
|
|
|
|
, pylatex ? null
|
|
|
|
, pyquil ? null
|
|
|
|
, quimb ? null
|
|
|
|
# test inputs
|
|
|
|
, pytestCheckHook
|
|
|
|
, freezegun
|
|
|
|
, pytest-asyncio
|
|
|
|
}:
|
2021-09-18 20:48:54 +02:00
|
|
|
|
2021-05-20 00:42:58 +02:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cirq-core";
|
2021-10-29 21:55:22 +02:00
|
|
|
version = "0.13.1";
|
2021-05-20 00:42:58 +02:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.6";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "quantumlib";
|
|
|
|
repo = "cirq";
|
|
|
|
rev = "v${version}";
|
2021-10-29 21:55:22 +02:00
|
|
|
sha256 = "sha256-MVfJ8iEeW8gFvCNTqrWfYpNNYuDAufHgcjd7Nh3qp8U=";
|
2021-05-20 00:42:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
sourceRoot = "source/${pname}";
|
|
|
|
|
2021-11-12 23:25:16 +01:00
|
|
|
patches = [
|
|
|
|
# present in upstream master - remove after 0.13.1
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-test-tolerances.part-1.patch";
|
|
|
|
url = "https://github.com/quantumlib/Cirq/commit/eb1d9031e55d3c8801ea44abbb6a4132b2fc5126.patch";
|
|
|
|
sha256 = "0ka24v6dfxnap9p07ni32z9zccbmw0lbrp5mcknmpsl12hza98xm";
|
|
|
|
stripLen = 1;
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-test-tolerances.part-2.patch";
|
|
|
|
url = "https://github.com/quantumlib/Cirq/commit/a28d601b2bcfc393336375c53e5915fd16455395.patch";
|
|
|
|
sha256 = "0k2dqsm4ydn6556d40kc8j04jgjn59z4wqqg1jn1r916a7yxw493";
|
|
|
|
stripLen = 1;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-05-20 00:42:58 +02:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace requirements.txt \
|
|
|
|
--replace "matplotlib~=3.0" "matplotlib" \
|
|
|
|
--replace "networkx~=2.4" "networkx" \
|
2021-09-18 20:48:54 +02:00
|
|
|
--replace "numpy~=1.16" "numpy"
|
2021-05-20 00:42:58 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
2021-10-29 21:55:22 +02:00
|
|
|
duet
|
2021-05-20 00:42:58 +02:00
|
|
|
matplotlib
|
|
|
|
networkx
|
|
|
|
numpy
|
|
|
|
pandas
|
|
|
|
requests
|
|
|
|
scipy
|
|
|
|
sortedcontainers
|
|
|
|
sympy
|
|
|
|
tqdm
|
|
|
|
typing-extensions
|
|
|
|
] ++ lib.optionals withContribRequires [
|
|
|
|
autoray
|
|
|
|
opt-einsum
|
|
|
|
ply
|
|
|
|
pylatex
|
|
|
|
pyquil
|
|
|
|
quimb
|
|
|
|
];
|
|
|
|
|
|
|
|
checkInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
pytest-asyncio
|
|
|
|
freezegun
|
|
|
|
];
|
|
|
|
|
|
|
|
pytestFlagsArray = lib.optionals (!withContribRequires) [
|
|
|
|
# requires external (unpackaged) libraries, so untested.
|
|
|
|
"--ignore=cirq/contrib/"
|
|
|
|
];
|
|
|
|
disabledTests = [
|
|
|
|
"test_metadata_search_path" # tries to import flynt, which isn't in Nixpkgs
|
|
|
|
"test_benchmark_2q_xeb_fidelities" # fails due pandas MultiIndex. Maybe issue with pandas version in nix?
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with lib; {
|
2021-09-18 20:48:54 +02:00
|
|
|
description = "Framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits";
|
2021-05-20 00:42:58 +02:00
|
|
|
homepage = "https://github.com/quantumlib/cirq";
|
|
|
|
changelog = "https://github.com/quantumlib/Cirq/releases/tag/v${version}";
|
|
|
|
license = licenses.asl20;
|
2021-09-18 20:48:54 +02:00
|
|
|
maintainers = with maintainers; [ drewrisinger fab ];
|
2021-05-20 00:42:58 +02:00
|
|
|
};
|
|
|
|
}
|