From 748140e97d5431569a0358876a14723a6b093713 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 14 Jul 2023 15:44:21 +0200 Subject: [PATCH] python3-protobuf: update to 4.23.4. --- srcpkgs/python3-protobuf/patches/cpp17.patch | 11 ++ .../patches/python-3.11.patch | 132 ------------------ srcpkgs/python3-protobuf/template | 16 +-- 3 files changed, 19 insertions(+), 140 deletions(-) create mode 100644 srcpkgs/python3-protobuf/patches/cpp17.patch delete mode 100644 srcpkgs/python3-protobuf/patches/python-3.11.patch diff --git a/srcpkgs/python3-protobuf/patches/cpp17.patch b/srcpkgs/python3-protobuf/patches/cpp17.patch new file mode 100644 index 00000000000000..97b81e1bfa5ad6 --- /dev/null +++ b/srcpkgs/python3-protobuf/patches/cpp17.patch @@ -0,0 +1,11 @@ +--- a/python/setup.py 2023-07-05 23:53:30.000000000 +0200 ++++ - 2023-07-14 16:19:35.949677747 +0200 +@@ -370,7 +370,7 @@ + extra_compile_args.append('-Wno-invalid-offsetof') + extra_compile_args.append('-Wno-sign-compare') + extra_compile_args.append('-Wno-unused-variable') +- extra_compile_args.append('-std=c++14') ++ extra_compile_args.append('-std=c++17') + + if sys.platform == 'darwin': + extra_compile_args.append('-Wno-shorten-64-to-32') diff --git a/srcpkgs/python3-protobuf/patches/python-3.11.patch b/srcpkgs/python3-protobuf/patches/python-3.11.patch deleted file mode 100644 index f6ed1b07835791..00000000000000 --- a/srcpkgs/python3-protobuf/patches/python-3.11.patch +++ /dev/null @@ -1,132 +0,0 @@ -From da973aff2adab60a9e516d3202c111dbdde1a50f Mon Sep 17 00:00:00 2001 -From: Alexander Shadchin -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. ---- - google/protobuf/pyext/descriptor.cc | 75 ++++++++++++++++++---- - 1 file changed, 62 insertions(+), 13 deletions(-) - -diff --git a/google/protobuf/pyext/descriptor.cc b/google/protobuf/pyext/descriptor.cc -index fc83acf01a..fc97b0fa6c 100644 ---- a/google/protobuf/pyext/descriptor.cc -+++ b/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. diff --git a/srcpkgs/python3-protobuf/template b/srcpkgs/python3-protobuf/template index e965c4432162e9..b0620d715ca4cd 100644 --- a/srcpkgs/python3-protobuf/template +++ b/srcpkgs/python3-protobuf/template @@ -1,16 +1,20 @@ # Template file for 'python3-protobuf' pkgname=python3-protobuf -version=4.21.12 +version=4.23.4 revision=1 build_style=python3-module -hostmakedepends="python3-setuptools python3-wheel" +build_wrksrc=python +hostmakedepends="python3-setuptools python3-wheel protobuf" depends="python3-setuptools python3-six" +checkdepends="python3-numpy" short_desc="Python3 bindings for Google Protocol Buffers" maintainer="Andrew J. Hesford " license="BSD-3-Clause" homepage="https://developers.google.com/protocol-buffers/" -distfiles="${PYPI_SITE}/p/protobuf/protobuf-${version}.tar.gz" -checksum=7cd532c4566d0e6feafecc1059d04c7915aec8e182d1cf7adee8b24ef1e2e6ab +# PyPi release does not have bits for cppext +distfiles="https://github.com/protocolbuffers/protobuf/releases/download/v${version#*.}/protobuf-${version#*.}.tar.gz" +checksum=a700a49470d301f1190a487a923b5095bf60f08f4ae4cac9f5f7c36883d17971 +make_check=no # ImportError: cannot import name 'unittest_retention_pb2' from 'google.protobuf' build_options="cppext" build_options_default="cppext" @@ -22,10 +26,6 @@ if [ "$build_option_cppext" ]; then makedepends+=" python3-devel protobuf-devel" fi -do_check() { - echo "skipping check: package ships with no tests" -} - post_install() { sed -n 1,29p google/protobuf/__init__.py >LICENSE vlicense LICENSE