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