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.4";
16 pyproject = true;
17
18 disabled = pythonOlder "3.8";
19
20 src = fetchPypi {
21 inherit pname version;
22 hash = "sha256-aUa6Q3e1RwvWN0NPqbJtWW3o/yzJxUc0g7gUGKUlOXo=";
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.fetchCargoVendor {
43 inherit pname version src;
44 hash = "sha256-cEpvkSqe/wRCxEajmM148jbo6a346x2t81pMRpKEJyE=";
45 };
46
47 nativeCheckInputs = [
48 hypothesis
49 pytestCheckHook
50 psutil
51 cbor2
52 ];
53
54 disabledTests = [
55 # flaky
56 "test_memory_usage"
57 ];
58
59 pythonImportsCheck = [ "pycddl" ];
60
61 meta = with lib; {
62 description = "Python bindings for the Rust cddl crate";
63 homepage = "https://gitlab.com/tahoe-lafs/pycddl";
64 changelog = "https://gitlab.com/tahoe-lafs/pycddl/-/tree/v${version}#release-notes";
65 license = licenses.mit;
66 maintainers = [ maintainers.exarkun ];
67 };
68}