1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 attrs,
8 duet,
9 matplotlib,
10 networkx,
11 numpy,
12 pandas,
13 requests,
14 scipy,
15 sortedcontainers,
16 sympy,
17 tqdm,
18 typing-extensions,
19 # Contrib requirements
20 withContribRequires ? false,
21 autoray ? null,
22 opt-einsum,
23 ply,
24 pylatex ? null,
25 pyquil ? null,
26 quimb ? null,
27 # test inputs
28 pytestCheckHook,
29 freezegun,
30 pytest-asyncio,
31}:
32
33buildPythonPackage rec {
34 pname = "cirq-core";
35 version = "1.4.0";
36 format = "setuptools";
37
38 disabled = pythonOlder "3.9";
39
40 src = fetchFromGitHub {
41 owner = "quantumlib";
42 repo = "cirq";
43 rev = "refs/tags/v${version}";
44 hash = "sha256-KHwVq0qVtc8E9i2lugILYNwk9awq952w0x4DM+HG7Pg=";
45 };
46
47 sourceRoot = "${src.name}/${pname}";
48
49 postPatch = ''
50 substituteInPlace requirements.txt \
51 --replace "matplotlib~=3.0" "matplotlib"
52 '';
53
54 propagatedBuildInputs =
55 [
56 attrs
57 duet
58 matplotlib
59 networkx
60 numpy
61 pandas
62 requests
63 scipy
64 sortedcontainers
65 sympy
66 tqdm
67 typing-extensions
68 ]
69 ++ lib.optionals withContribRequires [
70 autoray
71 opt-einsum
72 ply
73 pylatex
74 pyquil
75 quimb
76 ];
77
78 nativeCheckInputs = [
79 pytestCheckHook
80 pytest-asyncio
81 freezegun
82 ];
83
84 disabledTestPaths = lib.optionals (!withContribRequires) [
85 # Requires external (unpackaged) libraries, so untested
86 "cirq/contrib/"
87 # No need to test the version number
88 "cirq/_version_test.py"
89 ];
90
91 disabledTests = lib.optionals stdenv.isAarch64 [
92 # https://github.com/quantumlib/Cirq/issues/5924
93 "test_prepare_two_qubit_state_using_sqrt_iswap"
94 ];
95
96 meta = with lib; {
97 description = "Framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits";
98 homepage = "https://github.com/quantumlib/cirq";
99 changelog = "https://github.com/quantumlib/Cirq/releases/tag/v${version}";
100 license = licenses.asl20;
101 maintainers = with maintainers; [
102 drewrisinger
103 fab
104 ];
105 };
106}