public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/protobuf3] rawhide: Fix Python 3.15 KeyError from legacy nspkg.pth (rhbz#2486066)
Date: Wed, 17 Jun 2026 11:31:39 GMT	[thread overview]
Message-ID: <178169589968.1.4440729251904450658.rpms-protobuf3-93d6fed843a9@fedoraproject.org> (raw)

            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

                 reply	other threads:[~2026-06-17 11:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178169589968.1.4440729251904450658.rpms-protobuf3-93d6fed843a9@fedoraproject.org \
    --to=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox