<pre style='margin:0'>
Marius Schamschula (Schamschula) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/864275cc7bb711d5cd5eaea43e46047111861104">https://github.com/macports/macports-ports/commit/864275cc7bb711d5cd5eaea43e46047111861104</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 864275cc7bb711d5cd5eaea43e46047111861104
</span>Author: Marius Schamschula <mschamschula@gmail.com>
AuthorDate: Sat May 27 19:54:04 2023 -0500
<span style='display:block; white-space:pre;color:#404040;'> py-protobuf3: add py311 subport
</span>---
python/py-protobuf3/Portfile | 18 ++-
.../files/patch-protobuf-pyext-descriptor.cc.diff | 132 +++++++++++++++++++++
2 files changed, 145 insertions(+), 5 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/python/py-protobuf3/Portfile b/python/py-protobuf3/Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index bedecd54ee1..6ecb11558fc 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/python/py-protobuf3/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/python/py-protobuf3/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -49,7 +49,7 @@ compiler.cxx_standard \
</span> # error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
compiler.blacklist {clang < 900}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-python.versions 27 37 38 39 310
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+python.versions 27 37 38 39 310 311
</span>
if {${name} ne ${subport}} {
conflicts py${python.version}-protobuf
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -71,7 +71,18 @@ if {${name} ne ${subport}} {
</span> # tricks to force the right -stdlib setting
# and to put a needed CXX flag on the 10.6 build
# see https://trac.macports.org/ticket/56482
<span style='display:block; white-space:pre;background:#ffe0e0;'>- patchfiles-append patch-py-protobuf3-settings.diff
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patchfiles-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patch-py-protobuf3-settings.diff
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {${python.version} == 311} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patchfiles-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patch-protobuf-pyext-descriptor.cc.diff
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ build.cmd-append --cpp_implementation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ destroot.cmd-append --cpp_implementation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span>
post-patch {
set extraargs ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -89,9 +100,6 @@ if {${name} ne ${subport}} {
</span> reinplace "s|@@MACPORTS_EXTRAARG@@|${extraargs}|g" setup.py
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- build.cmd-append --cpp_implementation
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- destroot.cmd-append --cpp_implementation
</span>
test.run yes
python.test_framework
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/python/py-protobuf3/files/patch-protobuf-pyext-descriptor.cc.diff b/python/py-protobuf3/files/patch-protobuf-pyext-descriptor.cc.diff
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..fd3b523caf8
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/python/py-protobuf3/files/patch-protobuf-pyext-descriptor.cc.diff
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,132 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From da973aff2adab60a9e516d3202c111dbdde1a50f Mon Sep 17 00:00:00 2001
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+From: Alexander Shadchin <alexandr.shadchin@gmail.com>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Date: Sun, 14 Aug 2022 21:13:49 +0300
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Subject: [PATCH] Fix build with Python 3.11
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+The PyFrameObject structure members have been removed from the public C API.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+---
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ python/google/protobuf/pyext/descriptor.cc | 75 ++++++++++++++++++----
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 1 file changed, 62 insertions(+), 13 deletions(-)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+index fc83acf01a78abce470b5d34a94258ff0733a6bb..fc97b0fa6c11966f9215eecf7690f00aa7cb02c9 100644
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- google/protobuf/pyext/descriptor.cc
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ google/protobuf/pyext/descriptor.cc
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -58,6 +58,37 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ : 0) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ : PyBytes_AsStringAndSize(ob, (charpp), (sizep)))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_INCREF(frame->f_code);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return frame->f_code;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_XINCREF(frame->f_back);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return frame->f_back;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static PyObject* PyFrame_GetLocals(PyFrameObject *frame)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (PyFrame_FastToLocalsWithError(frame) < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_INCREF(frame->f_locals);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return frame->f_locals;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static PyObject* PyFrame_GetGlobals(PyFrameObject *frame)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_INCREF(frame->f_globals);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return frame->f_globals;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ namespace google {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ namespace protobuf {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ namespace python {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -96,48 +127,66 @@ bool _CalledFromGeneratedFile(int stacklevel) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // This check is not critical and is somewhat difficult to implement correctly
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // in PyPy.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PyFrameObject* frame = PyEval_GetFrame();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PyCodeObject* frame_code = nullptr;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PyObject* frame_globals = nullptr;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PyObject* frame_locals = nullptr;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ bool result = false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (frame == nullptr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_INCREF(frame);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while (stacklevel-- > 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- frame = frame->f_back;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PyFrameObject* next_frame = PyFrame_GetBack(frame);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_DECREF(frame);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ frame = next_frame;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (frame == nullptr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (frame->f_code->co_filename == nullptr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ frame_code = PyFrame_GetCode(frame);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (frame_code->co_filename == nullptr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* filename;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Py_ssize_t filename_size;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (PyString_AsStringAndSize(frame->f_code->co_filename,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (PyString_AsStringAndSize(frame_code->co_filename,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ &filename, &filename_size) < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // filename is not a string.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PyErr_Clear();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ((filename_size < 3) ||
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (strcmp(&filename[filename_size - 3], ".py") != 0)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Cython's stack does not have .py file name and is not at global module
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // scope.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (filename_size < 7) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // filename is too short.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (strcmp(&filename[filename_size - 7], "_pb2.py") != 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Filename is not ending with _pb2.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (frame->f_globals != frame->f_locals) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ frame_globals = PyFrame_GetGlobals(frame);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ frame_locals = PyFrame_GetLocals(frame);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (frame_globals != frame_locals) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // Not at global module scope
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto exit;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ result = true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++exit:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_XDECREF(frame_globals);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_XDECREF(frame_locals);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_XDECREF(frame_code);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_XDECREF(frame);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // If the calling code is not a _pb2.py file, raise AttributeError.
</span></pre><pre style='margin:0'>
</pre>