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