Package: src:protobuf
Version: 3.21.12-16
User: [email protected]
Usertags: python3.15
Tags: patch, ftbfs, forky, sid
Severity: serious

Hi!

While rebuilding the python related packages against the Python 3.15rc2
version we found that protobuf now fails to build from source due to
using pkg_resources [1].

I've used an upstream patch that relies on pkginfo and added patch that
uses packaging for parse_version. The last one should probably be
sent upstream.

I've applied the fix in the sandbox [2] to verify that it builds
successfully, please consider applying this patch together with the one
I reported in #1145000, to support the upcoming 3.15 version.

Happy hacking,

[1]: https://debusine.debian.net/debian/r-python-python3.15/artifact/4341761/
[2]: https://debusine.debian.net/debian/r-python-python3.15/

--
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
Description: Drop top-level pkg_resources import in setup.py
 In Python 3.15 / setuptools 84+, pkg_resources is no longer provided.
 Move the parse_version import inside the macOS-only branch where it is used
 and fall back to packaging.version.
Author: Maximiliano Curia <[email protected]>

Index: protobuf/python/setup.py
===================================================================
--- protobuf.orig/python/setup.py
+++ protobuf/python/setup.py
@@ -8,7 +8,6 @@ from distutils import util
 import fnmatch
 import glob
 import os
-import pkg_resources
 import re
 import subprocess
 import sys
@@ -270,8 +269,12 @@ if __name__ == '__main__':
     # deployment target of macOS 10.9 or later, or iOS 7 or later.
     if sys.platform == 'darwin':
       mac_target = str(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'))
-      if mac_target and (pkg_resources.parse_version(mac_target) <
-                         pkg_resources.parse_version('10.9.0')):
+      try:
+        from packaging.version import parse as parse_version
+      except ImportError:
+        from pkg_resources import parse_version
+      if mac_target and (parse_version(mac_target) <
+                         parse_version('10.9.0')):
         os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.9'
         os.environ['_PYTHON_HOST_PLATFORM'] = re.sub(
             r'macosx-[0-9]+\.[0-9]+-(.+)', r'macosx-10.9-\1',
From 8351926380c7cc91aae6df5695c91426e209f958 Mon Sep 17 00:00:00 2001
From: Ge Yunxi <[email protected]>
Date: Fri, 11 Jul 2025 11:04:58 -0700
Subject: drop-deprecated-pkg-resources-declare (#22442)

# Description
As of setuptools 81, pkg_resources.declare_namespace has been marked as deprecated (scheduled to be removed after 2025-11-30) so I remove it from init.py

# Environment:
a virtual machine of arch riscv64

# procedure
I got this problem when running a test that applied this package.
```
src/certbot_dns_google/_internal/tests/dns_google_test.py:9: in <module>
    from google.auth import exceptions as googleauth_exceptions
/usr/lib/python3.13/site-packages/google/__init__.py:2: in <module>
    __import__('pkg_resources').declare_namespace(__name__)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pkg_resources/__init__.py:98: in <module>
    warnings.warn(
E   UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
```
[certbot-dns-google-4.1.1-1-riscv64-check.log](https://github.com/user-attachments/files/20976539/certbot-dns-google-4.1.1-1-riscv64-check.log)

Closes #22442

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/22442 from gyx47:patch-1 6aef5c9df150cce444910d224fe90b2a514c7868
PiperOrigin-RevId: 782041935
---
 python/google/__init__.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/python/google/__init__.py b/python/google/__init__.py
index 5585614122..b36383a610 100644
--- a/python/google/__init__.py
+++ b/python/google/__init__.py
@@ -1,4 +1,3 @@
-try:
-  __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
-  __path__ = __import__('pkgutil').extend_path(__path__, __name__)
+from pkgutil import extend_path
+
+__path__ = extend_path(__path__, __name__)
-- 

Reply via email to