1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 rustPlatform,
8 numpy,
9 pytestCheckHook,
10 syrupy,
11 libiconv,
12}:
13
14buildPythonPackage rec {
15 pname = "quil";
16 version = "0.7.1";
17 pyproject = true;
18
19 disabled = pythonOlder "3.8";
20
21 src = fetchFromGitHub {
22 owner = "rigetti";
23 repo = "quil-rs";
24 rev = "quil-py/v${version}";
25 hash = "sha256-GFePbCJnVbzL4cpQ7fy1tk2l7NhAyTVW63lVYTv0/Oo=";
26 };
27
28 cargoDeps = rustPlatform.fetchCargoTarball {
29 name = "${pname}-${version}";
30 inherit src;
31 hash = "sha256-catUGCFbkvov1z52f6eyxogflu61VcjIItgEVEWzkpY=";
32 };
33
34 buildAndTestSubdir = "quil-py";
35
36 preConfigure = ''
37 cargo metadata --offline
38 '';
39
40 build-system = [
41 rustPlatform.cargoSetupHook
42 rustPlatform.maturinBuildHook
43 ];
44
45 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
46
47 dependencies = [ numpy ];
48
49 pythonImportsCheck = [ "numpy" ];
50
51 nativeCheckInputs = [
52 pytestCheckHook
53 syrupy
54 ];
55
56 disabledTests = [
57 # Syrupy snapshot needs to be regenerated
58 "test_filter_instructions"
59 ];
60
61 meta = {
62 changelog = "https://github.com/rigetti/quil-rs/blob/${src.rev}/quil-py/CHANGELOG.md";
63 description = "Python package for building and parsing Quil programs";
64 homepage = "https://github.com/rigetti/quil-rs/tree/main/quil-py";
65 license = lib.licenses.asl20;
66 maintainers = with lib.maintainers; [ dotlambda ];
67 };
68}