pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/www/py-uwsgi



Module Name:    pkgsrc
Committed By:   wiz
Date:           Sun Oct 29 18:18:04 UTC 2023

Modified Files:
        pkgsrc/www/py-uwsgi: distinfo options.mk
Added Files:
        pkgsrc/www/py-uwsgi/patches: patch-plugins_python_python__plugin.c
            patch-plugins_python_uwsgi__python.h

Log Message:
py-uwsgi: add Python 3.12 support

>From https://github.com/unbit/uwsgi/pull/2542


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 pkgsrc/www/py-uwsgi/distinfo
cvs rdiff -u -r1.7 -r1.8 pkgsrc/www/py-uwsgi/options.mk
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/www/py-uwsgi/patches/patch-plugins_python_python__plugin.c \
    pkgsrc/www/py-uwsgi/patches/patch-plugins_python_uwsgi__python.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/www/py-uwsgi/distinfo
diff -u pkgsrc/www/py-uwsgi/distinfo:1.44 pkgsrc/www/py-uwsgi/distinfo:1.45
--- pkgsrc/www/py-uwsgi/distinfo:1.44   Tue Aug  1 12:33:17 2023
+++ pkgsrc/www/py-uwsgi/distinfo        Sun Oct 29 18:18:03 2023
@@ -1,9 +1,11 @@
-$NetBSD: distinfo,v 1.44 2023/08/01 12:33:17 adam Exp $
+$NetBSD: distinfo,v 1.45 2023/10/29 18:18:03 wiz Exp $
 
 BLAKE2s (uwsgi-2.0.22.tar.gz) = b67f868770f3efb3d0ffeec4acdd6bda71ea746c06e49407a657bd22c3a077d5
 SHA512 (uwsgi-2.0.22.tar.gz) = 23c68336dd8bf41aa415b90d117be2b7e72773be2f3c1bac720a496f58bc56ae0ac2960c7bac4b8d73b16b459e10096dadd0e545fc3088d1979058bb275810e7
 Size (uwsgi-2.0.22.tar.gz) = 809747 bytes
 SHA1 (patch-base.ini) = 1c5d7693e6c8011e6cc34f5f5d203584c985eb30
 SHA1 (patch-core_logging.c) = e1e5f39446baecdcfc1738aa97852ad3d5ca40c7
+SHA1 (patch-plugins_python_python__plugin.c) = a536641efc3a25c7f43c37a507219fae0fe5f214
+SHA1 (patch-plugins_python_uwsgi__python.h) = 80ee323d5928c2e9ec7020d194f51676230c399d
 SHA1 (patch-uwsgi.h) = 112a325615e517f29b2420ba08f76d6a7a1bd3ef
 SHA1 (patch-uwsgiconfig.py) = 4945de7da82f3b05508e7d30ee0c3fe3144a2829

Index: pkgsrc/www/py-uwsgi/options.mk
diff -u pkgsrc/www/py-uwsgi/options.mk:1.7 pkgsrc/www/py-uwsgi/options.mk:1.8
--- pkgsrc/www/py-uwsgi/options.mk:1.7  Mon Apr 29 03:28:39 2019
+++ pkgsrc/www/py-uwsgi/options.mk      Sun Oct 29 18:18:03 2023
@@ -1,4 +1,4 @@
-# $NetBSD: options.mk,v 1.7 2019/04/29 03:28:39 dholland Exp $
+# $NetBSD: options.mk,v 1.8 2023/10/29 18:18:03 wiz Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.py-uwsgi
 PKG_SUPPORTED_OPTIONS= debug openssl pcre uuid uwsgi-sse_offload yaml
@@ -58,6 +58,7 @@ UWSGI_SSE=                    sse_offload=true
 INSTALL_ENV+=                  UWSGI_EMBED_PLUGINS=sse_offload
 
 post-extract: post-extract-sse
+.PHONY: post-extract-sse
 post-extract-sse:
        mv ${WRKDIR}/uwsgi-sse-offload-${SSE_REVISION} ${WRKSRC}/plugins/sse_offload
 .else

Added files:

Index: pkgsrc/www/py-uwsgi/patches/patch-plugins_python_python__plugin.c
diff -u /dev/null pkgsrc/www/py-uwsgi/patches/patch-plugins_python_python__plugin.c:1.1
--- /dev/null   Sun Oct 29 18:18:04 2023
+++ pkgsrc/www/py-uwsgi/patches/patch-plugins_python_python__plugin.c   Sun Oct 29 18:18:03 2023
@@ -0,0 +1,161 @@
+$NetBSD: patch-plugins_python_python__plugin.c,v 1.1 2023/10/29 18:18:03 wiz Exp $
+
+Python 3.12 support
+https://github.com/unbit/uwsgi/pull/2542
+
+--- plugins/python/python_plugin.c.orig        2023-07-27 15:34:12.000000000 +0000
++++ plugins/python/python_plugin.c
+@@ -197,6 +197,21 @@ void uwsgi_python_pthread_child(void) {
+ PyMethodDef uwsgi_spit_method[] = { {"uwsgi_spit", py_uwsgi_spit, METH_VARARGS, ""} };
+ PyMethodDef uwsgi_write_method[] = { {"uwsgi_write", py_uwsgi_write, METH_VARARGS, ""} };
+ 
++PyDoc_STRVAR(uwsgi_py_doc, "uWSGI api module.");
++
++#ifdef PYTHREE
++static PyModuleDef uwsgi_module3 = {
++      PyModuleDef_HEAD_INIT,
++      "uwsgi",
++      uwsgi_py_doc,
++      -1,
++      NULL,
++};
++PyObject *init_uwsgi3(void) {
++      return PyModule_Create(&uwsgi_module3);
++}
++#endif
++
+ int uwsgi_python_init() {
+ 
+       char *pyversion = strchr(Py_GetVersion(), '\n');
+@@ -261,6 +276,9 @@ pep405:
+       wchar_t *pname = uwsgi_calloc(sizeof(wchar_t) * (strlen(program_name)+1));
+       mbstowcs(pname, program_name, strlen(program_name)+1);
+       Py_SetProgramName(pname);
++#ifdef UWSGI_PY312
++      PyImport_AppendInittab("uwsgi", init_uwsgi3);
++#endif
+ #else
+       Py_SetProgramName(program_name);
+ #endif
+@@ -623,21 +641,6 @@ next:
+ 
+ 
+ 
+-PyDoc_STRVAR(uwsgi_py_doc, "uWSGI api module.");
+-
+-#ifdef PYTHREE
+-static PyModuleDef uwsgi_module3 = {
+-      PyModuleDef_HEAD_INIT,
+-      "uwsgi",
+-      uwsgi_py_doc,
+-      -1,
+-      NULL,
+-};
+-PyObject *init_uwsgi3(void) {
+-      return PyModule_Create(&uwsgi_module3);
+-}
+-#endif
+-
+ void init_uwsgi_embedded_module() {
+       PyObject *new_uwsgi_module, *zero;
+       int i;
+@@ -658,7 +661,9 @@ void init_uwsgi_embedded_module() {
+ 
+ 
+ #ifdef PYTHREE
++#ifndef UWSGI_PY312
+       PyImport_AppendInittab("uwsgi", init_uwsgi3);
++#endif
+       new_uwsgi_module = PyImport_AddModule("uwsgi");
+ #else
+       new_uwsgi_module = Py_InitModule3("uwsgi", NULL, uwsgi_py_doc);
+@@ -1161,7 +1166,10 @@ void uwsgi_python_init_apps() {
+ 
+       // prepare for stack suspend/resume
+       if (uwsgi.async > 1) {
+-#ifdef UWSGI_PY311
++#ifdef UWSGI_PY312
++               up.current_c_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
++               up.current_py_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
++#elif defined UWSGI_PY311
+               up.current_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
+ #else
+               up.current_recursion_depth = uwsgi_malloc(sizeof(int)*uwsgi.async);
+@@ -1324,7 +1332,12 @@ void uwsgi_python_pre_uwsgi_fork() {
+               // Acquire the gil and import lock before forking in order to avoid
+               // deadlocks in workers
+               UWSGI_GET_GIL
++#if defined UWSGI_PY312
++              PyInterpreterState *interp = PyInterpreterState_Get();
++              _PyImport_AcquireLock(interp);
++#else
+               _PyImport_AcquireLock();
++#endif
+       }
+ }
+ 
+@@ -1336,7 +1349,12 @@ void uwsgi_python_post_uwsgi_fork(int st
+       if (uwsgi.has_threads) {
+               if (step == 0) {
+                       // Release locks within master process
++#if defined UWSGI_PY312
++                      PyInterpreterState *interp = PyInterpreterState_Get();
++                      _PyImport_ReleaseLock(interp);
++#else
+                       _PyImport_ReleaseLock();
++#endif
+                       UWSGI_RELEASE_GIL
+               }
+               else {
+@@ -1592,7 +1610,11 @@ void uwsgi_python_suspend(struct wsgi_re
+       PyGILState_Release(pgst);
+ 
+       if (wsgi_req) {
+-#ifdef UWSGI_PY311
++#ifdef UWSGI_PY312
++              up.current_c_recursion_remaining[wsgi_req->async_id] = tstate->c_recursion_remaining;
++              up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
++              up.current_frame[wsgi_req->async_id] = tstate->cframe;
++#elif defined UWSGI_PY311
+               up.current_recursion_remaining[wsgi_req->async_id] = tstate->recursion_remaining;
+               up.current_frame[wsgi_req->async_id] = tstate->cframe;
+ #else
+@@ -1601,7 +1623,11 @@ void uwsgi_python_suspend(struct wsgi_re
+ #endif
+       }
+       else {
+-#ifdef UWSGI_PY311
++#ifdef UWSGI_PY312
++              up.current_main_c_recursion_remaining = tstate->c_recursion_remaining;
++              up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
++              up.current_main_frame = tstate->cframe;
++#elif defined UWSGI_PY311
+               up.current_main_recursion_remaining = tstate->recursion_remaining;
+               up.current_main_frame = tstate->cframe;
+ #else
+@@ -1835,7 +1861,11 @@ void uwsgi_python_resume(struct wsgi_req
+       PyGILState_Release(pgst);
+ 
+       if (wsgi_req) {
+-#ifdef UWSGI_PY311
++#ifdef UWSGI_PY312
++              tstate->c_recursion_remaining = up.current_c_recursion_remaining[wsgi_req->async_id];
++              tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
++              tstate->cframe = up.current_frame[wsgi_req->async_id];
++#elif defined UWSGI_PY311
+               tstate->recursion_remaining = up.current_recursion_remaining[wsgi_req->async_id];
+               tstate->cframe = up.current_frame[wsgi_req->async_id];
+ #else
+@@ -1844,7 +1874,11 @@ void uwsgi_python_resume(struct wsgi_req
+ #endif
+       }
+       else {
+-#ifdef UWSGI_PY311
++#ifdef UWSGI_PY312
++              tstate->c_recursion_remaining = up.current_main_c_recursion_remaining;
++              tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
++              tstate->cframe = up.current_main_frame;
++#elif defined UWSGI_PY311
+               tstate->recursion_remaining = up.current_main_recursion_remaining;
+               tstate->cframe = up.current_main_frame;
+ #else
Index: pkgsrc/www/py-uwsgi/patches/patch-plugins_python_uwsgi__python.h
diff -u /dev/null pkgsrc/www/py-uwsgi/patches/patch-plugins_python_uwsgi__python.h:1.1
--- /dev/null   Sun Oct 29 18:18:04 2023
+++ pkgsrc/www/py-uwsgi/patches/patch-plugins_python_uwsgi__python.h    Sun Oct 29 18:18:03 2023
@@ -0,0 +1,35 @@
+$NetBSD: patch-plugins_python_uwsgi__python.h,v 1.1 2023/10/29 18:18:03 wiz Exp $
+
+Python 3.12 support
+https://github.com/unbit/uwsgi/pull/2542
+
+--- plugins/python/uwsgi_python.h.orig 2023-07-27 15:34:12.000000000 +0000
++++ plugins/python/uwsgi_python.h
+@@ -21,6 +21,10 @@
+ #  define UWSGI_PY311
+ #endif
+ 
++#if (PY_VERSION_HEX >= 0x030c0000)
++#  define UWSGI_PY312
++#endif
++
+ #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7
+ #define HAS_NOT_PyMemoryView_FromBuffer
+ #endif
+@@ -168,7 +172,15 @@ struct uwsgi_python {
+ 
+       char *callable;
+ 
+-#ifdef UWSGI_PY311
++#ifdef UWSGI_PY312
++      int *current_c_recursion_remaining;
++      int *current_py_recursion_remaining;
++      _PyCFrame **current_frame;
++
++      int current_main_c_recursion_remaining;
++      int current_main_py_recursion_remaining;
++      _PyCFrame *current_main_frame;
++#elif defined UWSGI_PY311
+       int *current_recursion_remaining;
+       _PyCFrame **current_frame;
+ 



Home | Main Index | Thread Index | Old Index