From 7d88dc9151d2aeabb4b5c8cdf41abcdecfb984ab Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 7 Mar 2026 12:41:48 +0000 Subject: [PATCH 1/2] protobuf_25: fix GCC 15 compatibility Tracking: https://github.com/NixOS/nixpkgs/issues/475479 --- pkgs/development/libraries/protobuf/generic.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/libraries/protobuf/generic.nix b/pkgs/development/libraries/protobuf/generic.nix index 3488b63b1cf2..75e7b2dc660a 100644 --- a/pkgs/development/libraries/protobuf/generic.nix +++ b/pkgs/development/libraries/protobuf/generic.nix @@ -85,6 +85,10 @@ stdenv.mkDerivation (finalAttrs: { --replace-fail \ '#define UPB_LINKARR_SENTINEL UPB_RETAIN __attribute__((weak, used))' \ '#define UPB_LINKARR_SENTINEL __attribute__((weak, used))' + '' + # Fix gcc15 build failures due to missing + + lib.optionalString ((lib.versions.major version) == "25") '' + sed -i '1i #include ' third_party/utf8_range/utf8_validity.cc ''; preHook = '' From 8f514e00bd813add4ef1b2dd5836825b1b304f92 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 7 Mar 2026 13:37:34 +0000 Subject: [PATCH 2/2] python3Packages.protobuf4: cleanup, skip failing tests --- .../development/python-modules/protobuf/4.nix | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/pkgs/development/python-modules/protobuf/4.nix b/pkgs/development/python-modules/protobuf/4.nix index 29879ae3c9d8..9e88591bb108 100644 --- a/pkgs/development/python-modules/protobuf/4.nix +++ b/pkgs/development/python-modules/protobuf/4.nix @@ -51,23 +51,24 @@ buildPythonPackage { fi ''; - # Remove the line in setup.py that forces compiling with C++14. Upstream's - # CMake build has been updated to support compiling with other versions of - # C++, but the Python build has not. Without this, we observe compile-time - # errors using GCC. - # - # Fedora appears to do the same, per this comment: - # - # https://github.com/protocolbuffers/protobuf/issues/12104#issuecomment-1542543967 - # - postPatch = '' - sed -i "/extra_compile_args.append('-std=c++14')/d" setup.py - + postPatch = + # Remove the line in setup.py that forces compiling with C++14. Upstream's + # CMake build has been updated to support compiling with other versions of + # C++, but the Python build has not. Without this, we observe compile-time + # errors using GCC. + # + # Fedora appears to do the same, per this comment: + # + # https://github.com/protocolbuffers/protobuf/issues/12104#issuecomment-1542543967 + '' + sed -i "/extra_compile_args.append('-std=c++14')/d" setup.py + '' # The former function has been renamed into the latter in Python 3.12. # Does not apply to all protobuf versions, hence --replace-warn. - substituteInPlace google/protobuf/internal/json_format_test.py \ - --replace-warn assertRaisesRegexp assertRaisesRegex - ''; + + '' + substituteInPlace google/protobuf/internal/json_format_test.py \ + --replace-warn assertRaisesRegexp assertRaisesRegex + ''; nativeBuildInputs = lib.optional isPyPy tzdata; @@ -85,21 +86,29 @@ buildPythonPackage { ] ++ lib.optionals (lib.versionAtLeast protobuf.version "22") [ numpy ]; - disabledTests = - lib.optionals isPyPy [ - # error message differs - "testInvalidTimestamp" - # requires tracemalloc which pypy does not implement - # https://foss.heptapod.net/pypy/pypy/-/issues/3048 - "testUnknownFieldsNoMemoryLeak" - # assertion is not raised for some reason - "testStrictUtf8Check" - ] - ++ lib.optionals stdenv.hostPlatform.is32bit [ - # OverflowError: timestamp out of range for platform time_t - "testTimezoneAwareDatetimeConversionWhereTimestampLosesPrecision" - "testTimezoneNaiveDatetimeConversionWhereTimestampLosesPrecision" - ]; + disabledTests = [ + # TypeError: np.False_ has type , + # but expected one of: (, ) + "NumpyBoolProtoTest" + ] + ++ lib.optionals isPyPy [ + # error message differs + "testInvalidTimestamp" + # requires tracemalloc which pypy does not implement + # https://foss.heptapod.net/pypy/pypy/-/issues/3048 + "testUnknownFieldsNoMemoryLeak" + # assertion is not raised for some reason + "testStrictUtf8Check" + ] + ++ lib.optionals stdenv.hostPlatform.is32bit [ + # OverflowError: timestamp out of range for platform time_t + "testTimezoneAwareDatetimeConversionWhereTimestampLosesPrecision" + "testTimezoneNaiveDatetimeConversionWhereTimestampLosesPrecision" + ] + ++ lib.optionals (pythonAtLeast "3.14") [ + # AssertionError: "year (0 )?is out of range" does not match "year must be in 1..9999, not 0" + "testInvalidTimestamp" + ]; disabledTestPaths = lib.optionals (lib.versionAtLeast protobuf.version "23") [ @@ -115,6 +124,9 @@ buildPythonPackage { ] ++ lib.optionals (lib.versionAtLeast protobuf.version "25") [ "minimal_test.py" # ModuleNotFoundError: No module named 'google3' + + # ImportError: cannot import name 'self_recursive_pb2' from 'google.protobuf.internal' + "google/protobuf/internal/message_test.py" ]; pythonImportsCheck = [