10 versionMajor = lib.versions.major protobuf.version;
11 versionMinor = lib.versions.minor protobuf.version;
12 versionPatch = lib.versions.patch protobuf.version;
15 inherit (protobuf) pname src;
17 # protobuf 3.21 coresponds with its python library 4.21
19 if lib.versionAtLeast protobuf.version "3.21"
20 then "${toString (lib.toInt versionMajor + 1)}.${versionMinor}.${versionPatch}"
21 else protobuf.version;
25 sourceRoot = "source/python";
28 if [[ "$(<../version.json)" != *'"python": "'"$version"'"'* ]]; then
29 echo "Python library version mismatch. Derivation version: $version, actual: $(<../version.json)"
34 nativeBuildInputs = [ pyext ];
36 buildInputs = [ protobuf ];
38 propagatedNativeBuildInputs = [
39 # For protoc of the same version.
40 buildPackages."protobuf${lib.versions.major protobuf.version}_${lib.versions.minor protobuf.version}"
43 setupPyGlobalFlags = "--cpp_implementation";
45 pythonImportsCheck = [
47 "google.protobuf.internal._api_implementation" # Verify that --cpp_implementation worked
55 description = "Protocol Buffers are Google's data interchange format";
56 homepage = "https://developers.google.com/protocol-buffers/";
57 license = licenses.bsd3;
58 maintainers = with maintainers; [ knedlsepp ];