Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at litex 2.7 kB view raw
1{ lib 2, stdenv 3, buildPythonPackage 4, pythonAtLeast 5, pythonOlder 6, fetchFromGitHub 7, fetchpatch 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.1.0"; 36 format = "setuptools"; 37 38 # Upstream package is broken on Python 3.11 https://github.com/quantumlib/Cirq/issues/6018 39 disabled = pythonOlder "3.7" || pythonAtLeast "3.11"; 40 41 src = fetchFromGitHub { 42 owner = "quantumlib"; 43 repo = "cirq"; 44 rev = "refs/tags/v${version}"; 45 hash = "sha256-5j4hbG95KRfRQTyyZgoNp/eHIcy0FphyEhbYnzyUMO4="; 46 }; 47 48 sourceRoot = "source/${pname}"; 49 50 patches = [ 51 # https://github.com/quantumlib/Cirq/pull/5991 52 (fetchpatch { 53 url = "https://build.opensuse.org/public/source/openSUSE:Factory/python-cirq/cirq-pr5991-np1.24.patch?rev=8"; 54 stripLen = 1; 55 hash = "sha256-d2FpaxM1PsPWT9ZM9v2gVrnLCy9zmvkkyAVgo85eL3U="; 56 }) 57 ]; 58 59 postPatch = '' 60 substituteInPlace requirements.txt \ 61 --replace "matplotlib~=3.0" "matplotlib" \ 62 --replace "networkx~=2.4" "networkx" \ 63 --replace "numpy>=1.16,<1.24" "numpy" 64 ''; 65 66 propagatedBuildInputs = [ 67 duet 68 matplotlib 69 networkx 70 numpy 71 pandas 72 requests 73 scipy 74 sortedcontainers 75 sympy 76 tqdm 77 typing-extensions 78 ] ++ lib.optionals withContribRequires [ 79 autoray 80 opt-einsum 81 ply 82 pylatex 83 pyquil 84 quimb 85 ]; 86 87 nativeCheckInputs = [ 88 pytestCheckHook 89 pytest-asyncio 90 freezegun 91 ]; 92 93 disabledTestPaths = lib.optionals (!withContribRequires) [ 94 # Requires external (unpackaged) libraries, so untested 95 "cirq/contrib/" 96 # No need to test the version number 97 "cirq/_version_test.py" 98 ]; 99 100 disabledTests = [ 101 # Tries to import flynt, which isn't in Nixpkgs 102 "test_metadata_search_path" 103 # Fails due pandas MultiIndex. Maybe issue with pandas version in nix? 104 "test_benchmark_2q_xeb_fidelities" 105 # https://github.com/quantumlib/Cirq/pull/5991 106 "test_json_and_repr_data" 107 ]; 108 109 meta = with lib; { 110 description = "Framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits"; 111 homepage = "https://github.com/quantumlib/cirq"; 112 changelog = "https://github.com/quantumlib/Cirq/releases/tag/v${version}"; 113 license = licenses.asl20; 114 maintainers = with maintainers; [ drewrisinger fab ]; 115 broken = (stdenv.isLinux && stdenv.isAarch64); 116 }; 117}