1{ lib 2, buildPythonPackage 3, pythonOlder 4, fetchFromGitHub 5, fetchpatch 6, duet 7, matplotlib 8, networkx 9, numpy 10, pandas 11, requests 12, scipy 13, sortedcontainers 14, sympy 15, tqdm 16, typing-extensions 17 # Contrib requirements 18, withContribRequires ? false 19, autoray ? null 20, opt-einsum 21, ply 22, pylatex ? null 23, pyquil ? null 24, quimb ? null 25 # test inputs 26, pytestCheckHook 27, freezegun 28, pytest-asyncio 29}: 30 31buildPythonPackage rec { 32 pname = "cirq-core"; 33 version = "0.13.1"; 34 35 disabled = pythonOlder "3.6"; 36 37 src = fetchFromGitHub { 38 owner = "quantumlib"; 39 repo = "cirq"; 40 rev = "v${version}"; 41 sha256 = "sha256-MVfJ8iEeW8gFvCNTqrWfYpNNYuDAufHgcjd7Nh3qp8U="; 42 }; 43 44 sourceRoot = "source/${pname}"; 45 46 patches = [ 47 # present in upstream master - remove after 0.13.1 48 (fetchpatch { 49 name = "fix-test-tolerances.part-1.patch"; 50 url = "https://github.com/quantumlib/Cirq/commit/eb1d9031e55d3c8801ea44abbb6a4132b2fc5126.patch"; 51 sha256 = "0ka24v6dfxnap9p07ni32z9zccbmw0lbrp5mcknmpsl12hza98xm"; 52 stripLen = 1; 53 }) 54 (fetchpatch { 55 name = "fix-test-tolerances.part-2.patch"; 56 url = "https://github.com/quantumlib/Cirq/commit/a28d601b2bcfc393336375c53e5915fd16455395.patch"; 57 sha256 = "0k2dqsm4ydn6556d40kc8j04jgjn59z4wqqg1jn1r916a7yxw493"; 58 stripLen = 1; 59 }) 60 ]; 61 62 postPatch = '' 63 substituteInPlace requirements.txt \ 64 --replace "matplotlib~=3.0" "matplotlib" \ 65 --replace "networkx~=2.4" "networkx" \ 66 --replace "numpy~=1.16" "numpy" 67 ''; 68 69 propagatedBuildInputs = [ 70 duet 71 matplotlib 72 networkx 73 numpy 74 pandas 75 requests 76 scipy 77 sortedcontainers 78 sympy 79 tqdm 80 typing-extensions 81 ] ++ lib.optionals withContribRequires [ 82 autoray 83 opt-einsum 84 ply 85 pylatex 86 pyquil 87 quimb 88 ]; 89 90 checkInputs = [ 91 pytestCheckHook 92 pytest-asyncio 93 freezegun 94 ]; 95 96 pytestFlagsArray = lib.optionals (!withContribRequires) [ 97 # requires external (unpackaged) libraries, so untested. 98 "--ignore=cirq/contrib/" 99 ]; 100 disabledTests = [ 101 "test_metadata_search_path" # tries to import flynt, which isn't in Nixpkgs 102 "test_benchmark_2q_xeb_fidelities" # fails due pandas MultiIndex. Maybe issue with pandas version in nix? 103 ]; 104 105 meta = with lib; { 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/v${version}"; 109 license = licenses.asl20; 110 maintainers = with maintainers; [ drewrisinger fab ]; 111 }; 112}