1{ buildPythonPackage
2, fetchFromGitHub
3, lib
4, pythonOlder
5, poetry-core
6, grpclib
7, python-dateutil
8, black
9, jinja2
10, isort
11, python
12, pytestCheckHook
13, pytest-asyncio
14, pytest-mock
15, tomlkit
16, grpcio-tools
17}:
18
19buildPythonPackage rec {
20 pname = "betterproto";
21 version = "2.0.0b5";
22 format = "pyproject";
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "danielgtaylor";
27 repo = "python-betterproto";
28 rev = "v${version}";
29 hash = "sha256-XyXdpo3Yo4aO1favMWC7i9utz4fNDbKbsnYXJW0b7Gc=";
30 };
31
32 nativeBuildInputs = [ poetry-core ];
33
34 propagatedBuildInputs = [
35 grpclib
36 python-dateutil
37 ];
38
39 passthru.optional-dependencies.compiler = [
40 black
41 jinja2
42 isort
43 ];
44
45 pythonImportsCheck = [ "betterproto" ];
46
47 nativeCheckInputs = [
48 pytestCheckHook
49 pytest-asyncio
50 pytest-mock
51 tomlkit
52 grpcio-tools
53 ] ++ passthru.optional-dependencies.compiler;
54
55 # The tests require the generation of code before execution. This requires
56 # the protoc-gen-python_betterproto script from the package to be on PATH.
57 preCheck = ''
58 export PATH=$PATH:$out/bin
59 ${python.interpreter} -m tests.generate
60 '';
61
62 meta = with lib; {
63 description = "Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC";
64 longDescription = ''
65 This project aims to provide an improved experience when using Protobuf /
66 gRPC in a modern Python environment by making use of modern language
67 features and generating readable, understandable, idiomatic Python code.
68 '';
69 homepage = "https://github.com/danielgtaylor/python-betterproto";
70 license = licenses.mit;
71 maintainers = with maintainers; [ nikstur ];
72 };
73}