pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/www unit-python: add Python 3.11 support using upstrea...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/14e835e06046
branches:  trunk
changeset: 389567:14e835e06046
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Tue Dec 06 08:54:23 2022 +0000

description:
unit-python: add Python 3.11 support using upstream patch

Bump PKGREVISION.

diffstat:

 www/unit-python/Makefile                        |    6 +-
 www/unit/distinfo                               |    3 +-
 www/unit/patches/patch-src_python_nxt__python.c |  100 ++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 5 deletions(-)

diffs (140 lines):

diff -r 53c419e5a3c8 -r 14e835e06046 www/unit-python/Makefile
--- a/www/unit-python/Makefile  Tue Dec 06 08:21:34 2022 +0000
+++ b/www/unit-python/Makefile  Tue Dec 06 08:54:23 2022 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2022/11/15 12:47:59 wiz Exp $
+# $NetBSD: Makefile,v 1.6 2022/12/06 08:54:23 wiz Exp $
 
 PKGNAME=       unit-${LANG}${PYVERSSUFFIX}-${UNIT_VERSION}
+PKGREVISION=   1
 COMMENT=       Python module for NGINX Unit
 
 LANG=          python
@@ -8,9 +9,6 @@
 
 MAINTAINER=    osa%NetBSD.org@localhost
 
-# https://github.com/nginx/unit/issues/710
-PYTHON_VERSIONS_INCOMPATIBLE=  311
-
 post-configure:
        ${RUN} cd ${WRKSRC} && ${SETENV} ${_CONFIGURE_SCRIPT_ENV}               \
                ${CONFIG_SHELL} ${CONFIG_SHELL_FLAGS} ${CONFIGURE_SCRIPT}       \
diff -r 53c419e5a3c8 -r 14e835e06046 www/unit/distinfo
--- a/www/unit/distinfo Tue Dec 06 08:21:34 2022 +0000
+++ b/www/unit/distinfo Tue Dec 06 08:54:23 2022 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.10 2022/09/14 05:31:41 osa Exp $
+$NetBSD: distinfo,v 1.11 2022/12/06 08:54:23 wiz Exp $
 
 BLAKE2s (unit-1.28.0.tar.gz) = fe95e41bc6876ae30070ef0a1cba33181df6813bc69d3a246c71c25ff6193d2a
 SHA512 (unit-1.28.0.tar.gz) = 7d2033be3d8e9d15db21b5431348be73a10fbc19bcab7e83d3c5a770e11e23a53967afe051ec53e236896ac9e021d9146501bc32b87254f9b25778b4bc5d1cbe
@@ -10,3 +10,4 @@
 SHA1 (patch-src_nxt__php__sapi.c) = 2d5e557ff2066bec78f5bfbca6a64688f60da01b
 SHA1 (patch-src_nxt__unix.h) = c0db5bc4d9c45a3ead48627567284d8b3041b0a0
 SHA1 (patch-src_nxt__websocket__header.h) = 1b50405b187cc8a662372a1c20ab7737278135ae
+SHA1 (patch-src_python_nxt__python.c) = 18b638d2e2f155e7f2839309552d34772f0f5162
diff -r 53c419e5a3c8 -r 14e835e06046 www/unit/patches/patch-src_python_nxt__python.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/www/unit/patches/patch-src_python_nxt__python.c   Tue Dec 06 08:54:23 2022 +0000
@@ -0,0 +1,100 @@
+$NetBSD: patch-src_python_nxt__python.c,v 1.1 2022/12/06 08:54:23 wiz Exp $
+
+Python 3.11 support.
+https://github.com/nginx/unit/commit/491d0f700f5690eba0f1fcf2124f3a37ef73eb1a
+
+--- src/python/nxt_python.c.orig       2022-09-12 23:26:26.000000000 +0000
++++ src/python/nxt_python.c
+@@ -22,6 +22,10 @@ typedef struct {
+ } nxt_py_thread_info_t;
+ 
+ 
++#if PY_MAJOR_VERSION == 3
++static nxt_int_t nxt_python3_init_config(nxt_int_t pep405);
++#endif
++
+ static nxt_int_t nxt_python_start(nxt_task_t *task,
+     nxt_process_data_t *data);
+ static nxt_int_t nxt_python_set_target(nxt_task_t *task,
+@@ -64,6 +68,63 @@ static nxt_py_thread_info_t  *nxt_py_thr
+ static nxt_python_proto_t    nxt_py_proto;
+ 
+ 
++#if PY_VERSION_HEX >= NXT_PYTHON_VER(3, 8)
++
++static nxt_int_t
++nxt_python3_init_config(nxt_int_t pep405)
++{
++    PyStatus  status;
++    PyConfig  config;
++
++    PyConfig_InitIsolatedConfig(&config);
++
++    if (pep405) {
++        status = PyConfig_SetString(&config, &config.program_name,
++                                    nxt_py_home);
++        if (PyStatus_Exception(status)) {
++            goto pyinit_exception;
++        }
++
++    } else {
++        status =PyConfig_SetString(&config, &config.home, nxt_py_home);
++        if (PyStatus_Exception(status)) {
++            goto pyinit_exception;
++        }
++    }
++
++    status = Py_InitializeFromConfig(&config);
++    if (PyStatus_Exception(status)) {
++        goto pyinit_exception;
++    }
++    PyConfig_Clear(&config);
++
++    return NXT_OK;
++
++pyinit_exception:
++
++    PyConfig_Clear(&config);
++
++    return NXT_ERROR;
++}
++
++#elif PY_MAJOR_VERSION == 3
++
++static nxt_int_t
++nxt_python3_init_config(nxt_int_t pep405)
++{
++    if (pep405) {
++        Py_SetProgramName(nxt_py_home);
++
++    } else {
++        Py_SetPythonHome(nxt_py_home);
++    }
++
++    return NXT_OK;
++}
++
++#endif
++
++
+ static nxt_int_t
+ nxt_python_start(nxt_task_t *task, nxt_process_data_t *data)
+ {
+@@ -127,11 +188,15 @@ nxt_python_start(nxt_task_t *task, nxt_p
+         if (pep405) {
+             mbstowcs(nxt_py_home, c->home, len);
+             mbstowcs(nxt_py_home + len, bin_python, sizeof(bin_python));
+-            Py_SetProgramName(nxt_py_home);
+ 
+         } else {
+             mbstowcs(nxt_py_home, c->home, len + 1);
+-            Py_SetPythonHome(nxt_py_home);
++        }
++
++        ret = nxt_python3_init_config(pep405);
++        if (nxt_slow_path(ret == NXT_ERROR)) {
++            nxt_alert(task, "Failed to initialise config");
++            return NXT_ERROR;
+         }
+ 
+ #else



Home | Main Index | Thread Index | Old Index