depot/third_party/nixpkgs/pkgs/development/python-modules/protobuf/default.nix
Default email a66bca1520 Project import generated by Copybara.
GitOrigin-RevId: 40f79f003b6377bd2f4ed4027dde1f8f922995dd
2022-12-17 11:02:37 +01:00

57 lines
1.5 KiB
Nix

{ buildPackages
, lib
, buildPythonPackage
, protobuf
, isPyPy
}:
let
versionMajor = lib.versions.major protobuf.version;
versionMinor = lib.versions.minor protobuf.version;
versionPatch = lib.versions.patch protobuf.version;
in
buildPythonPackage {
inherit (protobuf) pname src;
# protobuf 3.21 coresponds with its python library 4.21
version =
if lib.versionAtLeast protobuf.version "3.21"
then "${toString (lib.toInt versionMajor + 1)}.${versionMinor}.${versionPatch}"
else protobuf.version;
disabled = isPyPy;
sourceRoot = "source/python";
prePatch = ''
if [[ "$(<../version.json)" != *'"python": "'"$version"'"'* ]]; then
echo "Python library version mismatch. Derivation version: $version, actual: $(<../version.json)"
exit 1
fi
'';
buildInputs = [ protobuf ];
propagatedNativeBuildInputs = [
# For protoc of the same version.
buildPackages."protobuf${lib.versions.major protobuf.version}_${lib.versions.minor protobuf.version}"
];
setupPyGlobalFlags = [ "--cpp_implementation" ];
pythonImportsCheck = [
"google.protobuf"
"google.protobuf.internal._api_implementation" # Verify that --cpp_implementation worked
];
passthru = {
inherit protobuf;
};
meta = with lib; {
description = "Protocol Buffers are Google's data interchange format";
homepage = "https://developers.google.com/protocol-buffers/";
license = licenses.bsd3;
maintainers = with maintainers; [ knedlsepp ];
};
}