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