about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/betterproto/default.nix
blob: f5cc7d9253eaeac9490620d43028e1633dfab378 (plain) (blame)
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
{ buildPythonPackage
, fetchFromGitHub
, lib
, pythonOlder
, poetry-core
, grpclib
, python-dateutil
, black
, jinja2
, isort
, python
, pydantic
, pytestCheckHook
, pytest-asyncio
, pytest-mock
, typing-extensions
, tomlkit
, grpcio-tools
}:

buildPythonPackage rec {
  pname = "betterproto";
  version = "2.0.0b6";
  pyproject = true;

  disabled = pythonOlder "3.9";

  src = fetchFromGitHub {
    owner = "danielgtaylor";
    repo = "python-betterproto";
    rev = "refs/tags/v.${version}";
    hash = "sha256-ZuVq4WERXsRFUPNNTNp/eisWX1MyI7UtwqEI8X93wYI=";
  };

  nativeBuildInputs = [
    poetry-core
  ];

  propagatedBuildInputs = [
    grpclib
    python-dateutil
    typing-extensions
  ];

  passthru.optional-dependencies.compiler = [
    black
    jinja2
    isort
  ];

  nativeCheckInputs = [
    grpcio-tools
    pydantic
    pytest-asyncio
    pytest-mock
    pytestCheckHook
    tomlkit
  ] ++ lib.flatten (builtins.attrValues 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 = ''
    export PATH=$PATH:$out/bin
    patchShebangs src/betterproto/plugin/main.py
    ${python.interpreter} -m tests.generate
  '';

  disabledTestPaths = [
    # https://github.com/danielgtaylor/python-betterproto/issues/530
    "tests/inputs/oneof/test_oneof.py"
  ];

  disabledTests = [
    "test_pydantic_no_value"
  ];

  meta = with lib; {
    description = "Code generator & library for Protobuf 3 and async gRPC";
    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/v.${version}/CHANGELOG.md";
    license = licenses.mit;
    maintainers = with maintainers; [ nikstur ];
  };
}