2020-04-17 01:18:12 +02:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2020-01-17 03:28:43 +01:00
|
|
|
, buildPythonPackage
|
|
|
|
, pythonOlder
|
|
|
|
, fetchFromGitHub
|
2020-05-12 01:00:17 +02:00
|
|
|
, fetchpatch
|
|
|
|
, freezegun
|
|
|
|
, google_api_core
|
2020-01-17 03:28:43 +01:00
|
|
|
, matplotlib
|
|
|
|
, networkx
|
|
|
|
, numpy
|
|
|
|
, pandas
|
|
|
|
, pythonProtobuf # pythonPackages.protobuf
|
|
|
|
, requests
|
|
|
|
, scipy
|
|
|
|
, sortedcontainers
|
|
|
|
, sympy
|
|
|
|
, typing-extensions
|
|
|
|
# test inputs
|
|
|
|
, pytestCheckHook
|
2020-05-12 01:00:17 +02:00
|
|
|
, pytest-asyncio
|
2020-01-17 03:28:43 +01:00
|
|
|
, pytest-benchmark
|
|
|
|
, ply
|
|
|
|
, pydot
|
|
|
|
, pyyaml
|
|
|
|
, pygraphviz
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cirq";
|
2020-05-12 01:00:17 +02:00
|
|
|
version = "0.8.0";
|
2020-01-17 03:28:43 +01:00
|
|
|
|
|
|
|
disabled = pythonOlder "3.5";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "quantumlib";
|
|
|
|
repo = "cirq";
|
|
|
|
rev = "v${version}";
|
2020-05-12 01:00:17 +02:00
|
|
|
sha256 = "01nnv7r595sp60wvp7750lfdjwdsi4q0r4lmaj6li09zsdw0r4b3";
|
2020-01-17 03:28:43 +01:00
|
|
|
};
|
|
|
|
|
2020-05-12 01:00:17 +02:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
# Fixes serialization issues on certain versions of protobuf & numpy.
|
|
|
|
name = "cirq-pr-2986-protobuf-bools.patch";
|
|
|
|
url = "https://github.com/quantumlib/Cirq/commit/78ddfb574c0f3936f713613bf4ba102163efb7b3.patch";
|
|
|
|
sha256 = "0hmad9ndsqf5ci7shvd924d2rv4k9pzx2r2cl1bm5w91arzz9m18";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-01-17 03:28:43 +01:00
|
|
|
# Cirq locks protobuf==3.8.0, but tested working with default pythonPackages.protobuf (3.7). This avoids overrides/pythonPackages.protobuf conflicts
|
2020-04-17 01:18:12 +02:00
|
|
|
postPatch = ''
|
2020-05-12 01:00:17 +02:00
|
|
|
substituteInPlace requirements.txt \
|
|
|
|
--replace "networkx~=2.4" "networkx" \
|
|
|
|
--replace "protobuf==3.8.0" "protobuf" \
|
|
|
|
--replace "freezegun~=0.3.15" "freezegun"
|
2020-01-17 03:28:43 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
2020-05-12 01:00:17 +02:00
|
|
|
freezegun
|
|
|
|
google_api_core
|
2020-01-17 03:28:43 +01:00
|
|
|
numpy
|
|
|
|
matplotlib
|
|
|
|
networkx
|
|
|
|
pandas
|
|
|
|
pythonProtobuf
|
|
|
|
requests
|
|
|
|
scipy
|
|
|
|
sortedcontainers
|
|
|
|
sympy
|
|
|
|
typing-extensions
|
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
# pythonImportsCheck = [ "cirq" "cirq.Ciruit" ]; # cirq's importlib hook doesn't work here
|
|
|
|
dontUseSetuptoolsCheck = true;
|
|
|
|
checkInputs = [
|
|
|
|
pytestCheckHook
|
2020-05-12 01:00:17 +02:00
|
|
|
pytest-asyncio
|
2020-01-17 03:28:43 +01:00
|
|
|
pytest-benchmark
|
|
|
|
ply
|
|
|
|
pydot
|
|
|
|
pyyaml
|
|
|
|
pygraphviz
|
|
|
|
];
|
2020-05-12 01:00:17 +02:00
|
|
|
|
2020-01-17 03:28:43 +01:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"--ignore=dev_tools" # Only needed when developing new code, which is out-of-scope
|
|
|
|
];
|
2020-04-17 01:18:12 +02:00
|
|
|
disabledTests = [
|
2020-05-12 01:00:17 +02:00
|
|
|
"test_serialize_sympy_constants" # fails due to small error in pi (~10e-7)
|
2020-04-17 01:18:12 +02:00
|
|
|
"test_convert_to_ion_gates" # fails due to rounding error, 0.75 != 0.750...2
|
2020-05-12 01:00:17 +02:00
|
|
|
|
|
|
|
# Newly disabled tests on cirq 0.8
|
|
|
|
# TODO: test & figure out why failing
|
|
|
|
"engine_job_test"
|
|
|
|
"test_health"
|
|
|
|
"test_run_delegation"
|
2020-04-17 01:18:12 +02:00
|
|
|
] ++ lib.optionals stdenv.isAarch64 [
|
|
|
|
# Seem to fail due to math issues on aarch64?
|
|
|
|
"expectation_from_wavefunction"
|
|
|
|
"test_single_qubit_op_to_framed_phase_form_output_on_example_case"
|
|
|
|
];
|
2020-01-17 03:28:43 +01:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.";
|
2020-03-20 13:36:23 +01:00
|
|
|
homepage = "https://github.com/quantumlib/cirq";
|
2020-01-17 03:28:43 +01:00
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ drewrisinger ];
|
|
|
|
};
|
|
|
|
}
|