1{
2 lib,
3 pythonOlder,
4 fetchPypi,
5 buildPythonPackage,
6 rustPlatform,
7 pytestCheckHook,
8 psutil,
9 cbor2,
10 hypothesis,
11}:
12
13buildPythonPackage rec {
14 pname = "pycddl";
15 version = "0.6.1";
16 format = "pyproject";
17
18 disabled = pythonOlder "3.7";
19
20 src = fetchPypi {
21 inherit pname version;
22 hash = "sha256-63fe8UJXEH6t4l7ujV8JDvlGb7q3kL6fHHATFdklzFc=";
23 };
24
25 nativeBuildInputs = with rustPlatform; [
26 maturinBuildHook
27 cargoSetupHook
28 ];
29
30 postPatch = ''
31 # We don't place pytest-benchmark in the closure because we have no
32 # intention of running the benchmarks. Make sure pip doesn't fail as a
33 # result of it being missing by removing it from the requirements list.
34 sed -i -e /pytest-benchmark/d requirements-dev.txt
35
36 # Now that we've gotten rid of pytest-benchmark we need to get rid of the
37 # benchmarks too, otherwise they fail at import time due to the missing
38 # dependency.
39 rm tests/test_benchmarks.py
40 '';
41
42 cargoDeps = rustPlatform.fetchCargoTarball {
43 inherit src;
44 name = "${pname}-${version}";
45 hash = "sha256-ssDEKRd3Y9/10oXBZHCxvlRkl9KMh3pGYbCkM4rXThQ=";
46 };
47
48 nativeCheckInputs = [
49 hypothesis
50 pytestCheckHook
51 psutil
52 cbor2
53 ];
54
55 disabledTests =[
56 # flaky
57 "test_memory_usage"
58 ];
59
60 pythonImportsCheck = [ "pycddl" ];
61
62 meta = with lib; {
63 description = "Python bindings for the Rust cddl crate";
64 homepage = "https://gitlab.com/tahoe-lafs/pycddl";
65 changelog = "https://gitlab.com/tahoe-lafs/pycddl/-/tree/v${version}#release-notes";
66 license = licenses.mit;
67 maintainers = [ maintainers.exarkun ];
68 };
69}