python3Packages.protobuf: fix derivation version

This commit is contained in:
oxalica
2022-11-05 19:34:02 +08:00
parent 46cbaad44f
commit 16b4c7f0ad
@@ -6,15 +6,29 @@
, 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 version;
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 = ''
while [ ! -d python ]; do
cd *
done
cd python
if [[ "$(<../version.json)" != *'"python": "'"$version"'"'* ]]; then
echo "Python library version mismatch. Derivation version: $version, actual: $(<../version.json)"
exit 1
fi
'';
nativeBuildInputs = [ pyext ];