2021-01-05 12:25:54 +01:00
|
|
|
{ buildPackages
|
2021-01-24 01:29:22 +01:00
|
|
|
, lib
|
2021-01-05 12:25:54 +01:00
|
|
|
, buildPythonPackage
|
|
|
|
, protobuf
|
2022-10-06 11:21:59 +02:00
|
|
|
, isPyPy
|
2021-01-05 12:25:54 +01:00
|
|
|
}:
|
2017-01-23 14:25:19 +01:00
|
|
|
|
2022-11-05 19:27:27 +08:00
|
|
|
let
|
|
|
|
versionMajor = lib.versions.major protobuf.version;
|
|
|
|
versionMinor = lib.versions.minor protobuf.version;
|
|
|
|
versionPatch = lib.versions.patch protobuf.version;
|
|
|
|
in
|
2019-08-13 21:52:01 +00:00
|
|
|
buildPythonPackage {
|
2022-11-05 19:27:27 +08:00
|
|
|
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;
|
|
|
|
|
2022-10-06 11:21:59 +02:00
|
|
|
disabled = isPyPy;
|
2018-11-24 18:09:52 -05:00
|
|
|
|
2022-11-05 19:27:27 +08:00
|
|
|
sourceRoot = "source/python";
|
|
|
|
|
2017-01-23 14:25:19 +01:00
|
|
|
prePatch = ''
|
2022-11-05 19:27:27 +08:00
|
|
|
if [[ "$(<../version.json)" != *'"python": "'"$version"'"'* ]]; then
|
|
|
|
echo "Python library version mismatch. Derivation version: $version, actual: $(<../version.json)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-01-23 14:25:19 +01:00
|
|
|
'';
|
|
|
|
|
2022-10-06 11:21:59 +02:00
|
|
|
buildInputs = [ protobuf ];
|
|
|
|
|
|
|
|
propagatedNativeBuildInputs = [
|
|
|
|
# For protoc of the same version.
|
|
|
|
buildPackages."protobuf${lib.versions.major protobuf.version}_${lib.versions.minor protobuf.version}"
|
|
|
|
];
|
|
|
|
|
2022-12-09 00:26:13 +02:00
|
|
|
setupPyGlobalFlags = [ "--cpp_implementation" ];
|
2017-01-23 14:25:19 +01:00
|
|
|
|
2021-12-07 18:46:18 -05:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"google.protobuf"
|
2021-11-22 17:19:45 +01:00
|
|
|
"google.protobuf.internal._api_implementation" # Verify that --cpp_implementation worked
|
|
|
|
];
|
2017-01-23 14:25:19 +01:00
|
|
|
|
2022-10-06 11:21:59 +02:00
|
|
|
passthru = {
|
|
|
|
inherit protobuf;
|
|
|
|
};
|
|
|
|
|
2021-01-24 01:29:22 +01:00
|
|
|
meta = with lib; {
|
2017-01-23 14:25:19 +01:00
|
|
|
description = "Protocol Buffers are Google's data interchange format";
|
2020-03-31 21:11:51 -04:00
|
|
|
homepage = "https://developers.google.com/protocol-buffers/";
|
2019-09-12 16:43:15 -07:00
|
|
|
license = licenses.bsd3;
|
2021-12-13 21:43:42 +01:00
|
|
|
maintainers = with maintainers; [ knedlsepp ];
|
2017-01-23 14:25:19 +01:00
|
|
|
};
|
|
|
|
}
|