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