summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorZach van Rijn <me@zv.io>2022-11-27 18:33:26 -0600
committerZach van Rijn <me@zv.io>2022-11-27 18:34:46 -0600
commit05f00d96b02d16904c21b71ec3b7c1f6fe46ce13 (patch)
treedd933e0bf25b27126bc04a1d0ea3ef6795480c94 /user
parente2f47c171016f0f451253ebf2c33610f8589ee45 (diff)
downloadpackages-05f00d96b02d16904c21b71ec3b7c1f6fe46ce13.tar.gz
packages-05f00d96b02d16904c21b71ec3b7c1f6fe46ce13.tar.bz2
packages-05f00d96b02d16904c21b71ec3b7c1f6fe46ce13.tar.xz
packages-05f00d96b02d16904c21b71ec3b7c1f6fe46ce13.zip
user/protobuf: add patch for python 3.11. fixes #888.
Diffstat (limited to 'user')
-rw-r--r--user/protobuf/APKBUILD10
-rw-r--r--user/protobuf/python-311.patch134
2 files changed, 140 insertions, 4 deletions
diff --git a/user/protobuf/APKBUILD b/user/protobuf/APKBUILD
index e82d51e41..e9243288f 100644
--- a/user/protobuf/APKBUILD
+++ b/user/protobuf/APKBUILD
@@ -5,7 +5,7 @@ pkgname=protobuf
_gemname=google-protobuf
pkgver=3.20.3
_tstver=8d51dc50eb7e7698427fed81b85edad0e032112e
-pkgrel=0
+pkgrel=1
pkgdesc="Library for extensible, efficient structure packing"
url="https://github.com/google/protobuf"
arch="all"
@@ -15,13 +15,14 @@ depends_dev="zlib-dev"
makedepends="$depends_dev autoconf automake libtool ruby ruby-dev ruby-rake
ruby-rake-compiler ruby-io-console ruby-irb ruby-power_assert
ruby-rake-compiler ruby-test-unit ruby-reline ruby-rubygems-tasks
- python3 python3-dev cmake"
+ python3 python3-dev cmake"
checkdepends="ruby-json ruby-test-unit"
subpackages="ruby-$_gemname:_ruby py3-$pkgname:_python $pkgname-dev $pkgname-vim::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/$pkgname/archive/v$pkgver.tar.gz
googletest-$_tstver.tar.gz::https://github.com/google/googletest/archive/$_tstver.tar.gz
cxx14.patch
32bit.patch
+ python-311.patch
"
prepare() {
@@ -46,7 +47,7 @@ build() {
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_C_FLAGS="$CFLAGS" \
${CMAKE_CROSSOPTS} cmake
- make -j1
+ make
# Build for Ruby
cd "$builddir"/ruby
@@ -122,4 +123,5 @@ vim() {
sha512sums="01d6703bdbe769a1200ee6e4ebcdcb99688ec21f576988c60d82ec36e0822820fb245fcb4ca53293143d53e666d748b5a0c6937bc659fb3cdc4cd9b05ed12a1c protobuf-3.20.3.tar.gz
f7f804abf68af5e4e6cd767151773394fb8297d7d7fc878532ebb22b8c41d13554f68fa38a27470d458b590259a939e93cee7e5f5f6de8f1726c7ce85a606099 googletest-8d51dc50eb7e7698427fed81b85edad0e032112e.tar.gz
faf8962f0c7f1e4053b28a712b31ac9b254b17986326d2188d6edcc609f4b52f4cb85766c4bc02c6b9bc7bc30e2061f940a3089db54eb6056f729a80c1cfa891 cxx14.patch
-2dfb540395460f0ea9fad663851633b29fa368a6ec99a88a42e31d7547034191679ef868c0ec67613d070659d4e322dc942b54b21793764e3d2342927977c7eb 32bit.patch"
+2dfb540395460f0ea9fad663851633b29fa368a6ec99a88a42e31d7547034191679ef868c0ec67613d070659d4e322dc942b54b21793764e3d2342927977c7eb 32bit.patch
+acb8f0bfec92ff969699c909e509f28c1b8c95acb739ce9c3fedaa3f961e2b799190d9eeb4c6022b7cc9244aa7e6c47640cec077dff9382960ea3fc65b24e906 python-311.patch"
diff --git a/user/protobuf/python-311.patch b/user/protobuf/python-311.patch
new file mode 100644
index 000000000..f0a68dadd
--- /dev/null
+++ b/user/protobuf/python-311.patch
@@ -0,0 +1,134 @@
+https://github.com/protocolbuffers/protobuf/pull/10403
+
+From da973aff2adab60a9e516d3202c111dbdde1a50f Mon Sep 17 00:00:00 2001
+From: Alexander Shadchin <alexandr.shadchin@gmail.com>
+Date: Sun, 14 Aug 2022 21:13:49 +0300
+Subject: [PATCH] Fix build with Python 3.11
+
+The PyFrameObject structure members have been removed from the public C API.
+---
+ python/google/protobuf/pyext/descriptor.cc | 75 ++++++++++++++++++----
+ 1 file changed, 62 insertions(+), 13 deletions(-)
+
+diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc
+index fc83acf01a7..fc97b0fa6c1 100644
+--- a/python/google/protobuf/pyext/descriptor.cc
++++ b/python/google/protobuf/pyext/descriptor.cc
+@@ -58,6 +58,37 @@
+ : 0) \
+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
+
++#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
++static PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
++{
++ Py_INCREF(frame->f_code);
++ return frame->f_code;
++}
++
++static PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
++{
++ Py_XINCREF(frame->f_back);
++ return frame->f_back;
++}
++#endif
++
++#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
++static PyObject* PyFrame_GetLocals(PyFrameObject *frame)
++{
++ if (PyFrame_FastToLocalsWithError(frame) < 0) {
++ return NULL;
++ }
++ Py_INCREF(frame->f_locals);
++ return frame->f_locals;
++}
++
++static PyObject* PyFrame_GetGlobals(PyFrameObject *frame)
++{
++ Py_INCREF(frame->f_globals);
++ return frame->f_globals;
++}
++#endif
++
+ namespace google {
+ namespace protobuf {
+ namespace python {
+@@ -96,48 +127,66 @@ bool _CalledFromGeneratedFile(int stacklevel) {
+ // This check is not critical and is somewhat difficult to implement correctly
+ // in PyPy.
+ PyFrameObject* frame = PyEval_GetFrame();
++ PyCodeObject* frame_code = nullptr;
++ PyObject* frame_globals = nullptr;
++ PyObject* frame_locals = nullptr;
++ bool result = false;
++
+ if (frame == nullptr) {
+- return false;
++ goto exit;
+ }
++ Py_INCREF(frame);
+ while (stacklevel-- > 0) {
+- frame = frame->f_back;
++ PyFrameObject* next_frame = PyFrame_GetBack(frame);
++ Py_DECREF(frame);
++ frame = next_frame;
+ if (frame == nullptr) {
+- return false;
++ goto exit;
+ }
+ }
+
+- if (frame->f_code->co_filename == nullptr) {
+- return false;
++ frame_code = PyFrame_GetCode(frame);
++ if (frame_code->co_filename == nullptr) {
++ goto exit;
+ }
+ char* filename;
+ Py_ssize_t filename_size;
+- if (PyString_AsStringAndSize(frame->f_code->co_filename,
++ if (PyString_AsStringAndSize(frame_code->co_filename,
+ &filename, &filename_size) < 0) {
+ // filename is not a string.
+ PyErr_Clear();
+- return false;
++ goto exit;
+ }
+ if ((filename_size < 3) ||
+ (strcmp(&filename[filename_size - 3], ".py") != 0)) {
+ // Cython's stack does not have .py file name and is not at global module
+ // scope.
+- return true;
++ result = true;
++ goto exit;
+ }
+ if (filename_size < 7) {
+ // filename is too short.
+- return false;
++ goto exit;
+ }
+ if (strcmp(&filename[filename_size - 7], "_pb2.py") != 0) {
+ // Filename is not ending with _pb2.
+- return false;
++ goto exit;
+ }
+
+- if (frame->f_globals != frame->f_locals) {
++ frame_globals = PyFrame_GetGlobals(frame);
++ frame_locals = PyFrame_GetLocals(frame);
++ if (frame_globals != frame_locals) {
+ // Not at global module scope
+- return false;
++ goto exit;
+ }
+ #endif
+- return true;
++ result = true;
++exit:
++ Py_XDECREF(frame_globals);
++ Py_XDECREF(frame_locals);
++ Py_XDECREF(frame_code);
++ Py_XDECREF(frame);
++ return result;
+ }
+
+ // If the calling code is not a _pb2.py file, raise AttributeError.