python3Packages.protobuf4: fix for setuptools >= 81

`pkg_resources` was finally removed, use `packaging` for parsing version strings instead

this is the recommended approach from setuptools' docs: https://setuptools.pypa.io/en/latest/deprecated/pkg_resources.html
This commit is contained in:
Willy
2026-07-22 23:31:43 +02:00
parent 3d42c0a0ac
commit b2e5b60488

View File

@@ -6,6 +6,7 @@
lib,
stdenv,
numpy,
packaging,
protobuf,
pytestCheckHook,
pythonAtLeast,
@@ -68,9 +69,18 @@ buildPythonPackage {
+ ''
substituteInPlace google/protobuf/internal/json_format_test.py \
--replace-warn assertRaisesRegexp assertRaisesRegex
''
# setuptools 81 dropped pkg_resources, parse versions via packaging module
+ ''
substituteInPlace setup.py \
--replace-fail "import pkg_resources" "import packaging.version" \
--replace-fail "pkg_resources.parse_version" "packaging.version.parse"
'';
nativeBuildInputs = lib.optional isPyPy tzdata;
nativeBuildInputs = [
packaging
]
++ lib.optional isPyPy tzdata;
buildInputs = [ protobuf ];