1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
{
lib,
buildPythonPackage,
fetchFromGitHub,
pythonAtLeast,
# build-system
poetry-core,
# dependencies
grpclib,
python-dateutil,
typing-extensions,
# optional-dependencies
black,
jinja2,
isort,
# tests
addBinToPathHook,
cachelib,
grpcio-tools,
pydantic,
pytest-asyncio,
pytest-mock,
pytestCheckHook,
tomlkit,
python,
}:
buildPythonPackage (finalAttrs: {
pname = "betterproto";
version = "2.0.0b7";
pyproject = true;
src = fetchFromGitHub {
owner = "danielgtaylor";
repo = "python-betterproto";
tag = "v.${finalAttrs.version}";
hash = "sha256-T7QSPH8MFa1hxJOhXc3ZMM62/FxHWjCJJ59IpeM41rI=";
};
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail "poetry-core>=1.0.0,<2" "poetry-core"
'';
build-system = [ poetry-core ];
dependencies = [
grpclib
python-dateutil
typing-extensions
];
optional-dependencies.compiler = [
black
jinja2
isort
];
nativeCheckInputs = [
addBinToPathHook
cachelib
grpcio-tools
pydantic
pytest-asyncio
pytest-mock
pytestCheckHook
tomlkit
]
++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies;
pythonImportsCheck = [ "betterproto" ];
# The tests require the generation of code before execution. This requires
# the protoc-gen-python_betterproto script from the package to be on PATH.
preCheck = ''
(($(ulimit -n) < 1024)) && ulimit -n 1024
patchShebangs src/betterproto/plugin/main.py
${python.interpreter} -m tests.generate
'';
disabledTests = [
# incompatible with pytest 8:
# TypeError: exceptions must be derived from Warning, not <class 'NoneType'>
"test_message_with_deprecated_field_not_set"
"test_service_with_deprecated_method"
# Test is flaky
"test_binary_compatibility"
];
disabledTestPaths = lib.optionals (pythonAtLeast "3.14") [
# TypeError: issubclass() arg 1 must be a class
"tests/test_inputs.py::test_message_can_instantiated[namespace_builtin_types]"
"tests/test_inputs.py::test_message_equality[namespace_builtin_types]"
"tests/test_inputs.py::test_message_json[namespace_builtin_types]"
];
meta = {
description = "Code generator & library for Protobuf 3 and async gRPC";
mainProgram = "protoc-gen-python_betterproto";
longDescription = ''
This project aims to provide an improved experience when using Protobuf /
gRPC in a modern Python environment by making use of modern language
features and generating readable, understandable, idiomatic Python code.
'';
homepage = "https://github.com/danielgtaylor/python-betterproto";
changelog = "https://github.com/danielgtaylor/python-betterproto/blob/${finalAttrs.src.tag}/CHANGELOG.md";
license = lib.licenses.mit;
};
})
|