From 16b4c7f0adbf63a69554e3954c2bf443e932b090 Mon Sep 17 00:00:00 2001 From: oxalica Date: Sat, 5 Nov 2022 19:27:27 +0800 Subject: [PATCH] python3Packages.protobuf: fix derivation version --- .../python-modules/protobuf/default.nix | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/protobuf/default.nix b/pkgs/development/python-modules/protobuf/default.nix index cc7ea3c7bdc3..7034ef322ab5 100644 --- a/pkgs/development/python-modules/protobuf/default.nix +++ b/pkgs/development/python-modules/protobuf/default.nix @@ -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 ];