nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 buildPythonPackage,
3 fetchPypi,
4 lib,
5 python,
6 setuptools,
7 protobuf,
8}:
9
10buildPythonPackage (finalAttrs: {
11 pname = "protobuf";
12 version = "6.33.5";
13 pyproject = true;
14
15 src = fetchPypi {
16 inherit (finalAttrs) pname version;
17 hash = "sha256-bdysKggfi3uWQsCUBrxqQpASj85fRxzd0WWWC7kRnlw=";
18 };
19
20 build-system = [ setuptools ];
21
22 propagatedNativeBuildInputs = [
23 protobuf
24 ];
25
26 doCheck =
27 # https://protobuf.dev/support/cross-version-runtime-guarantee/#backwards
28 # The non-python protobuf provides the protoc binary which must not be newer.
29 assert lib.versionAtLeast finalAttrs.version ("6." + protobuf.version);
30 # the pypi source archive does not ship tests
31 false;
32
33 pythonImportsCheck = [
34 "google.protobuf"
35 "google.protobuf.compiler"
36 "google.protobuf.internal"
37 "google.protobuf.pyext"
38 "google.protobuf.testdata"
39 "google.protobuf.util"
40 "google._upb._message"
41 ];
42
43 # Tries to explicitly create a namespace package with pkg_resources,
44 # which breaks everything with our PYTHONPATH setup.
45 postInstall = ''
46 rm $out/${python.sitePackages}/google/__init__.py
47 '';
48
49 meta = {
50 description = "Protocol Buffers are Google's data interchange format";
51 homepage = "https://developers.google.com/protocol-buffers/";
52 changelog = "https://github.com/protocolbuffers/protobuf/releases/v${
53 builtins.substring 2 (-1) finalAttrs.version
54 }";
55 license = lib.licenses.bsd3;
56 maintainers = with lib.maintainers; [ GaetanLepage ];
57 };
58})