1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9
10 # dependencies
11 attrs,
12 duet,
13 matplotlib,
14 networkx,
15 numpy,
16 pandas,
17 requests,
18 scipy,
19 sortedcontainers,
20 sympy,
21 tqdm,
22 typing-extensions,
23 autoray ? null,
24 opt-einsum,
25 ply,
26 pylatex ? null,
27 pyquil ? null,
28 quimb ? null,
29
30 # tests
31 freezegun,
32 pytest-asyncio,
33 pytestCheckHook,
34
35 withContribRequires ? false,
36}:
37
38buildPythonPackage rec {
39 pname = "cirq-core";
40 version = "1.6.1";
41 pyproject = true;
42
43 src = fetchFromGitHub {
44 owner = "quantumlib";
45 repo = "cirq";
46 tag = "v${version}";
47 hash = "sha256-M+ojGXJOnrBipjSA9hd3++yTS70kCjPru9FG/rm7zI8=";
48 };
49
50 sourceRoot = "${src.name}/${pname}";
51
52 pythonRelaxDeps = [ "matplotlib" ];
53
54 build-system = [ setuptools ];
55
56 dependencies = [
57 attrs
58 duet
59 matplotlib
60 networkx
61 numpy
62 pandas
63 requests
64 scipy
65 sortedcontainers
66 sympy
67 tqdm
68 typing-extensions
69 ]
70 ++ lib.optionals withContribRequires [
71 autoray
72 opt-einsum
73 ply
74 pylatex
75 pyquil
76 quimb
77 ];
78
79 nativeCheckInputs = [
80 freezegun
81 pytest-asyncio
82 pytestCheckHook
83 ];
84
85 disabledTestPaths = lib.optionals (!withContribRequires) [
86 # Requires external (unpackaged) libraries, so untested
87 "cirq/contrib/"
88 # No need to test the version number
89 "cirq/_version_test.py"
90 ];
91
92 disabledTests = [
93 # Assertion error
94 "test_parameterized_cphase"
95 ]
96 ++ lib.optionals stdenv.hostPlatform.isAarch64 [
97 # https://github.com/quantumlib/Cirq/issues/5924
98 "test_prepare_two_qubit_state_using_sqrt_iswap"
99 ]
100 ++ lib.optionals stdenv.hostPlatform.isDarwin [
101 # test_scalar_division[scalar9-terms9-terms_expected9] result differs in the final digit
102 "test_scalar_division"
103 ];
104
105 meta = {
106 description = "Framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits";
107 homepage = "https://github.com/quantumlib/cirq";
108 changelog = "https://github.com/quantumlib/Cirq/releases/tag/${src.tag}";
109 license = lib.licenses.asl20;
110 maintainers = with lib.maintainers; [
111 drewrisinger
112 fab
113 ];
114 };
115}