public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/protobuf3] rawhide: Fix Python 3.15 KeyError from legacy nspkg.pth (rhbz#2486066)
@ 2026-06-17 11:31 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-06-17 11:31 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/protobuf3
            Branch : rawhide
            Commit : 93d6fed843a9ccd4c19f2eecd0e47bcdcfa9c3ea
            Author : Miroslav Suchý <msuchy@redhat.com>
            Date   : 2026-06-17T13:19:58+02:00
            Stats  : +36/-5 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/protobuf3/c/93d6fed843a9ccd4c19f2eecd0e47bcdcfa9c3ea?branch=rawhide

            Log:
            Fix Python 3.15 KeyError from legacy nspkg.pth (rhbz#2486066)

Switch from legacy namespace_packages to PEP 420 native namespace
packages. The old *-nspkg.pth file used sys._getframe(1).f_locals['sitedir']
which broke in Python 3.15 (PEP 829 rewrote site.py internals).

Key decisions:
- Replace find_packages() with find_namespace_packages()
- Drop namespace_packages=['google'] from setup()
- Remove google/__init__.py in %prep for implicit namespace

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>

---
diff --git a/protobuf-3.19.6-native-namespace.patch b/protobuf-3.19.6-native-namespace.patch
new file mode 100644
index 0000000..5a842fc
--- /dev/null
+++ b/protobuf-3.19.6-native-namespace.patch
@@ -0,0 +1,29 @@
+diff -up a/python/setup.py b/python/setup.py
+--- a/python/setup.py	2022-09-29 13:38:53.000000000 -0400
++++ b/python/setup.py	2026-06-08 12:00:00.000000000 -0400
+@@ -14,7 +14,7 @@ import platform
+
+ # We must use setuptools, not distutils, because we need to use the
+ # namespace_packages option for the "google" package.
+-from setuptools import setup, Extension, find_packages
++from setuptools import setup, Extension, find_namespace_packages
+
+ from distutils.command.build_ext import build_ext as _build_ext
+ from distutils.command.build_py import build_py as _build_py
+@@ -308,11 +308,14 @@ if __name__ == '__main__':
+           "Programming Language :: Python :: 3.9",
+           "Programming Language :: Python :: 3.10",
+       ],
+-      namespace_packages=['google'],
+-      packages=find_packages(
++      packages=find_namespace_packages(
+           exclude=[
++              'docs',
++              'docs.*',
+               'import_test_package',
++              'import_test_package.*',
+               'protobuf_distutils',
++              'protobuf_distutils.*',
+           ],),
+       test_suite='google.protobuf.internal',
+       cmdclass={

diff --git a/protobuf3.spec b/protobuf3.spec
index 725279b..3869f41 100644
--- a/protobuf3.spec
+++ b/protobuf3.spec
@@ -91,6 +91,9 @@ Patch4:         protobuf-3.19.4-python3.11.patch
 Patch6:         protobuf-3.19.6-gcc15.patch
 # pkg_resources dropped from latest setuptools, only needed on Mac OS
 Patch7:         protobuf-3.19.6-pkg_resources.patch
+# Switch from legacy namespace_packages to PEP 420 native namespace packages
+# to fix KeyError on Python 3.15 (https://bugzilla.redhat.com/show_bug.cgi?id=2486066)
+Patch8:         protobuf-3.19.6-native-namespace.patch
 
 
 # A bundled copy of jsoncpp is included in the conformance tests, but the
@@ -286,6 +289,10 @@ MinGW Windows protobuf library tools.
 %patch 4 -p1 -b .python311
 %patch 6 -p1 -b .gcc15
 %patch 7 -p1 -b .pkg_resources
+%patch 8 -p1 -b .native_namespace
+
+# Remove google/__init__.py to use implicit (PEP 420) namespace packages
+rm python/google/__init__.py
 
 # Copy in the needed gtest/gmock implementations.
 %setup -q -T -D -b 3 -n protobuf-%{version}%{?rcver}
@@ -411,11 +418,6 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
 
 %if %{with python}
 %files -n python3-protobuf3 -f %{pyproject_files}
-%if %{with python_cpp}
-%{python3_sitearch}/protobuf-%{version}%{?rcver}-py3.*-nspkg.pth
-%else
-%{python3_sitelib}/protobuf-%{version}%{?rcver}-py3.*-nspkg.pth
-%endif
 %license LICENSE
 %doc python/README.md
 %doc examples/add_person.py examples/list_people.py examples/addressbook.proto

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-17 11:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 11:31 [rpms/protobuf3] rawhide: Fix Python 3.15 KeyError from legacy nspkg.pth (rhbz#2486066) 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox