diff options
author | wiz <wiz@pkgsrc.org> | 2022-12-06 08:54:23 +0000 |
---|---|---|
committer | wiz <wiz@pkgsrc.org> | 2022-12-06 08:54:23 +0000 |
commit | bfc37dbd993a33565fe29dd18054ef86361eeeb7 (patch) | |
tree | 6da19af12fcc42de3d2e7a570de8ee08a50ca0ed /www | |
parent | aa89878cd8c7f8e7bebf407e3f8d9f11a5110b2a (diff) | |
download | pkgsrc-bfc37dbd993a33565fe29dd18054ef86361eeeb7.tar.gz |
unit-python: add Python 3.11 support using upstream patch
Bump PKGREVISION.
Diffstat (limited to 'www')
-rw-r--r-- | www/unit-python/Makefile | 6 | ||||
-rw-r--r-- | www/unit/distinfo | 3 | ||||
-rw-r--r-- | www/unit/patches/patch-src_python_nxt__python.c | 100 |
3 files changed, 104 insertions, 5 deletions
diff --git a/www/unit-python/Makefile b/www/unit-python/Makefile index 0573b7016af..a9b63f6181a 100644 --- a/www/unit-python/Makefile +++ b/www/unit-python/Makefile @@ -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 @@ MODNAME= ${LANG} MAINTAINER= osa@NetBSD.org -# 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 --git a/www/unit/distinfo b/www/unit/distinfo index 38cc7212fdb..77909f7f493 100644 --- a/www/unit/distinfo +++ b/www/unit/distinfo @@ -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__kqueue__engine.c) = c341425f4b21d4cff6e003958f88a04b53dc4ee 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 --git a/www/unit/patches/patch-src_python_nxt__python.c b/www/unit/patches/patch-src_python_nxt__python.c new file mode 100644 index 00000000000..a85fb5204f7 --- /dev/null +++ b/www/unit/patches/patch-src_python_nxt__python.c @@ -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 |