public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Michal Schorm <mschorm@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/mysql-connector-python] rawhide: [rebase 4/4] Enable X DevAPI C extension with system protobuf 6.x
Date: Tue, 22 Sep 2026 11:55:49 GMT	[thread overview]
Message-ID: <179007814902.1.753671898119895418.rpms-mysql-connector-python-5a9a8125f689@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/mysql-connector-python
            Branch : rawhide
            Commit : 5a9a8125f6890ed63f685e94709608727ec1d590
            Author : Michal Schorm <mschorm@redhat.com>
            Date   : 2026-09-22T12:15:12+02:00
            Stats  : +103/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/mysql-connector-python/c/5a9a8125f6890ed63f685e94709608727ec1d590?branch=rawhide

            Log:
            [rebase 4/4] Enable X DevAPI C extension with system protobuf 6.x

Enable the '_mysqlxpb' C extension (with_mysqlxpb=1), which was
disabled since Fedora's protobuf was too old. Fedora 45+ ships
protobuf 6.33.x, which is sufficient.

The X Protocol is compiled into every 'mysqld' since MySQL 8.0 and
is enabled by default on port 33060. The C extension provides a
high-performance protobuf path for X DevAPI operations; without it,
'mysqlx' falls back to a slower pure-Python protobuf path.

MariaDB does not support the X Protocol, so this only benefits
users running MySQL Community Server.

Patch changes for system protobuf 6.x (4 parts):
1. Unpin 'protobuf==5.29.4' to '>=' — the wire format is stable
   across protobuf major versions, and Fedora's 6.33.x is verified
   to serialize/deserialize correctly.
2. Upgrade from C++14 to C++17 — required by protobuf 6.x abseil
   headers.
3. Wrap 'absl::string_view' returns in 'std::string()' at 5 call
   sites in 'mysqlxpb.cc' — protobuf 6.x changed descriptor
   accessor return types and the implicit conversion is gone.
4. Skip static abseil linking on Linux — system protobuf ships as
   a shared library with abseil already linked in.

Note: upstream's pre-generated '*_pb2.py' files import
'google.protobuf.internal.builder', which was rumored to be removed
in protobuf 6.x. Testing confirms the module still exists in
Fedora's protobuf 6.33.5, so no compatibility shim is needed.

Co-Authored-By: Claude AI <noreply@anthropic.com>

---
diff --git a/mysql-connector-python-system-protobuf.patch b/mysql-connector-python-system-protobuf.patch
new file mode 100644
index 0000000..1add4f8
--- /dev/null
+++ b/mysql-connector-python-system-protobuf.patch
@@ -0,0 +1,100 @@
+# Build the X DevAPI C extension against Fedora's system protobuf 6.x
+#
+# Upstream pins protobuf==5.29.4 and ships pre-generated *_pb2.py files
+# using the protobuf 4.x code generator. Fedora has protobuf 6.33.x, which
+# differs in several ways:
+#
+# 1. The pinned version check blocks installation with system protobuf.
+#    Relax == to >= so any compatible version satisfies the requirement.
+#
+# 2. Protobuf 6.x headers require C++17 (was C++14 for 4.25.3). Without
+#    this, the _mysqlxpb C extension fails to compile.
+#
+# 3. In protobuf 6.x, descriptor accessor methods (full_name(), name())
+#    return absl::string_view instead of std::string. The implicit
+#    conversion to std::string is gone, so explicit wrapping is needed
+#    to use operator+ and .c_str().
+#
+# 4. On Linux, system protobuf ships as a shared library with abseil
+#    already linked in. The upstream build tries to statically link 40+
+#    individual abseil libraries, which fails against system .so files.
+#    Skip this on Linux — only needed on Windows with vendored static libs.
+
+--- a/mysqlx-connector-python/setup.py	2026-07-10 20:39:31.000000000 +0200
++++ b/mysqlx-connector-python/setup.py	2026-09-22 01:30:58.758599014 +0200
+@@ -158,7 +158,7 @@
+         ext_modules=EXTENSIONS,
+         cmdclass=COMMAND_CLASSES,
+         python_requires=">=3.10",
+-        install_requires=["protobuf==5.29.4"],
++        install_requires=["protobuf>=5.29.4"],
+         extras_require={
+             "dns-srv": ["dnspython==2.6.1"],
+             "compression": (
+--- a/mysqlx-connector-python/cpydist/__init__.py	2026-07-10 20:39:31.000000000 +0200
++++ b/mysqlx-connector-python/cpydist/__init__.py	2026-09-22 01:31:07.296483072 +0200
+@@ -54,7 +54,7 @@
+ 
+ # Abseil libraries to link in the later stage
+ ABSL_LIBS_EXT = "lib" if os.name == "nt" else "a"
+-ABSL_LIBS = (
++ABSL_LIBS = () if os.name != "nt" else (
+     "absl_str_format_internal",
+     "absl_strings",
+     "absl_strings_internal",
+@@ -385,8 +385,8 @@
+             ext.libraries.extend(ABSL_LIBS)
+ 
+             if os.name != "nt":
+-                # Add -std=c++14 needed for Protobuf 4.25.3
+-                ext.extra_compile_args.append("-std=c++14")
++                # Add -std=c++17 needed for Protobuf 6.x (abseil headers)
++                ext.extra_compile_args.append("-std=c++17")
+             self._run_protoc()
+ 
+             # Suppress unknown pragmas
+--- a/mysqlx-connector-python/src/mysqlxpb/mysqlxpb.cc	2026-07-10 20:39:31.000000000 +0200
++++ b/mysqlx-connector-python/src/mysqlxpb/mysqlxpb.cc	2026-09-22 01:31:23.247265391 +0200
+@@ -601,10 +601,10 @@
+   if (!obj) {
+     throw std::runtime_error(
+       "Failed to convert message field to Python object: " +
+-      field.full_name());
++      std::string(field.full_name()));
+   }
+ 
+-  PyDict_SetItemString(dict, field.name().c_str(), obj);
++  PyDict_SetItemString(dict, std::string(field.name()).c_str(), obj);
+   Py_CLEAR(obj);
+ }
+ 
+@@ -617,7 +617,7 @@
+   if (!obj) {
+     throw std::runtime_error(
+         "Failed to convert message field to Python object: " +
+-        field.full_name());
++        std::string(field.full_name()));
+   }
+ 
+   PyList_SetItem(list, index, obj);
+@@ -632,7 +632,7 @@
+ 
+   try {
+     // PyString_FromString which relies on PyUnicode_FromString returns a new reference
+-    desc_full_name = PyString_FromString(descriptor->full_name().c_str());
++    desc_full_name = PyString_FromString(std::string(descriptor->full_name()).c_str());
+ 
+     // PyDict_SetItemString does not steal a reference to val (last argument).
+     PyDict_SetItemString(dict, kMessageTypeKey, desc_full_name);
+@@ -656,7 +656,7 @@
+ 
+           for (int idx = 0; idx < listSize; ++idx)
+             PythonAddList(list, idx, message, *field);
+-          PyDict_SetItemString(dict, field->name().c_str(), list);
++          PyDict_SetItemString(dict, std::string(field->name()).c_str(), list);
+           Py_CLEAR(list);
+           break;
+         }
+     from . import (
+         mysqlx_connection_pb2,
+         mysqlx_crud_pb2,

diff --git a/mysql-connector-python.spec b/mysql-connector-python.spec
index 1b60a0b..32163e1 100644
--- a/mysql-connector-python.spec
+++ b/mysql-connector-python.spec
@@ -12,7 +12,7 @@ ExcludeArch: %{ix86}
 %global with_tests   %{?_with_tests:1}%{!?_with_tests:0}
 
 # Build the X DevAPI C extension (_mysqlxpb) with system protobuf
-%global with_mysqlxpb 0
+%global with_mysqlxpb 1
 
 Name:           mysql-connector-python
 Version:        26.7.0
@@ -33,6 +33,8 @@ Patch0:         %{name}-rpath.patch
 Patch1:         %{name}-docs-import.patch
 # Guard removed ssl.PROTOCOL_TLSv1* constants with hasattr() (Python 3.15, PEP 644)
 Patch2:         %{name}-python315-ssl.patch
+# Adapt mysqlx C extension and protobuf bindings for system protobuf 6.x
+Patch3:         %{name}-system-protobuf.patch
 
 BuildRequires:  gcc-c++
 BuildRequires:  make

                 reply	other threads:[~2026-09-22 11:55 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=179007814902.1.753671898119895418.rpms-mysql-connector-python-5a9a8125f689@fedoraproject.org \
    --to=mschorm@redhat.com \
    --cc=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