Mercurial > hgrepos > FreeBSD > ports > www > uwsginl
changeset 158:661720cf51a3
Begin flavorizing of the pypy3 plugin to also handle PyPy3.9.
BUGS: Does not work yet because the corresponding pypy_setup.py is not adjusted properly yet.
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Wed, 12 Oct 2022 17:25:50 +0200 |
| parents | 5ca2e3bea583 |
| children | 6d5943538043 |
| files | uwsginl-plugin-lang-pypy3/Makefile uwsginl-plugin-lang-pypy3/files/extra/patch-plugins_pypy_pypy__plugin.c |
| diffstat | 2 files changed, 79 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/uwsginl-plugin-lang-pypy3/Makefile Wed Oct 12 16:03:18 2022 +0200 +++ b/uwsginl-plugin-lang-pypy3/Makefile Wed Oct 12 17:25:50 2022 +0200 @@ -18,6 +18,11 @@ LICENSE_FILE= ${WRKSRC}/LICENSE LICENSE_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept +FLAVORS= pypy3 pypy38 pypy39 +FLAVOR?= ${FLAVORS:[1]} + +PKGNAMEPREFIX= ${FLAVOR}- + BUILD_DEPENDS+= ${UWSGI_NAME}==${PORTVERSION}:www/uwsginl BUILD_DEPENDS+= pypy3>=6:lang/pypy3 RUN_DEPENDS+= ${UWSGI_NAME}==${PORTVERSION}:www/uwsginl @@ -32,6 +37,22 @@ PLIST_FILES= ${PLUGIN_DIR}/${PLUGIN_FILENAME} +.if ${FLAVOR} == pypy3 +PLUGIN_NAME= pypy3 +PYPY_LDLIBRARY= libpypy3-c.so +PYPY_LIBDIR= lib_pypy +.elif ${FLAVOR} == pypy38 +PLUGIN_NAME= pypy3 +PYPY_LDLIBRARY= libpypy3-c.so +PYPY_LIBDIR= lib/pypy3.8 +.elif ${FLAVOR} == pypy39 +PLUGIN_NAME= pypy39 +PYPY_LDLIBRARY= libpypy3.9-c.so +PYPY_LIBDIR= lib/pypy3.9 +.endif + +CFLAGS+= -DPYPY_LDLIBRARY="${PYPY_LDLIBRARY}" -DPYPY_LIBDIR="${PYPY_LIBDIR}" -DPYPY_PLUGIN_NAME="${PLUGIN_NAME}" + MAKE_ENV+= UWSGI_PROFILE_OVERRIDE="plugin_build_dir=${STAGEDIR}${PREFIX}/${PLUGIN_DIR};plugin_dir=${PREFIX}/${PLUGIN_DIR}" PYTHON=${LOCALBASE}/bin/pypy3 DESCR= pkg-descr @@ -40,8 +61,6 @@ UWSGI_PATH= ${LOCALBASE}/bin/${UWSGI_NAME} PLUGIN_DIR= lib/${UWSGI_NAME}/plugins -# The name of the plugin to be created (to eventually distingush py2 and py3) -PLUGIN_NAME= pypy3 # Where to find the sources for the plugin (defaults to plugins/${PLUGIN_NAME}) PLUGIN_SOURCE= plugins/pypy # The complete basename of the plugin
--- a/uwsginl-plugin-lang-pypy3/files/extra/patch-plugins_pypy_pypy__plugin.c Wed Oct 12 16:03:18 2022 +0200 +++ b/uwsginl-plugin-lang-pypy3/files/extra/patch-plugins_pypy_pypy__plugin.c Wed Oct 12 17:25:50 2022 +0200 @@ -1,6 +1,31 @@ --- plugins/pypy/pypy_plugin.c.orig 2022-09-21 14:46:45 UTC +++ plugins/pypy/pypy_plugin.c -@@ -42,9 +42,10 @@ void (*uwsgi_pypy_hook_paste_loader)(char *); +@@ -9,6 +9,24 @@ + + #include <uwsgi.h> + ++#if !defined(PYPY_PLUGIN_NAME) ++#error PYPY_PLUGIN_NAME not defined ++#endif ++#if !defined(PYPY_LDLIBRARY) ++#error PYPY_LDLIBRARY not defined ++#endif ++#if !defined(PYPY_LIBDIR) ++#error PYPY_LIBDIR not defined ++#endif ++ ++#define STR2(__x) #__x ++ ++#define STR(__x) STR2(__x) ++ ++#define CONCAT2(__x, __y) __x##__y ++ ++#define CONCAT(__x, __y) CONCAT2(__x, __y) ++ + struct uwsgi_pypy { + void *handler; + char *lib; +@@ -42,9 +60,10 @@ void (*uwsgi_pypy_hook_paste_loader)(char *); void (*uwsgi_pypy_hook_pythonpath)(char *); void (*uwsgi_pypy_hook_request)(void *, int); void (*uwsgi_pypy_post_fork_hook)(void); @@ -8,31 +33,31 @@ extern struct uwsgi_server uwsgi; -struct uwsgi_plugin pypy_plugin; -+struct uwsgi_plugin pypy3_plugin; ++struct uwsgi_plugin CONCAT(PYPY_PLUGIN_NAME, _plugin); static int uwsgi_pypy_init() { -@@ -58,7 +59,7 @@ static int uwsgi_pypy_init() { +@@ -58,7 +77,7 @@ static int uwsgi_pypy_init() { } if (dlsym(RTLD_DEFAULT, "rpython_startup_code")) { - uwsgi_log("PyPy runtime detected, skipping libpypy-c loading\n"); -+ uwsgi_log("PyPy runtime detected, skipping libpypy3-c loading\n"); ++ uwsgi_log("PyPy runtime detected, skipping " STR(PYPY_LDLIBRARY) " loading\n"); goto ready; } else if (upypy.lib) { -@@ -68,26 +69,26 @@ static int uwsgi_pypy_init() { +@@ -68,26 +87,26 @@ static int uwsgi_pypy_init() { if (upypy.home) { // first try with /bin way: #ifdef __CYGWIN__ - char *libpath = uwsgi_concat2(upypy.home, "/bin/libpypy-c.dll"); -+ char *libpath = uwsgi_concat2(upypy.home, "/bin/libpypy3-c.so"); ++ char *libpath = uwsgi_concat2(upypy.home, "/bin/" STR(PYPY_LDLIBRARY)); #elif defined(__APPLE__) - char *libpath = uwsgi_concat2(upypy.home, "/bin/libpypy-c.dylib"); -+ char *libpath = uwsgi_concat2(upypy.home, "/bin/libpypy3-c.so"); ++ char *libpath = uwsgi_concat2(upypy.home, "/bin/" STR(PYPY_LDLIBRARY)); #else - char *libpath = uwsgi_concat2(upypy.home, "/bin/libpypy-c.so"); -+ char *libpath = uwsgi_concat2(upypy.home, "/bin/libpypy3-c.so"); ++ char *libpath = uwsgi_concat2(upypy.home, "/bin/" STR(PYPY_LDLIBRARY)); #endif if (uwsgi_file_exists(libpath)) { - upypy.handler = dlopen(libpath, RTLD_NOW | RTLD_GLOBAL); @@ -47,50 +72,59 @@ #ifdef __CYGWIN__ - char *libpath = uwsgi_concat2(upypy.home, "/libpypy-c.dll"); -+ char *libpath = uwsgi_concat2(upypy.home, "/libpypy3-c.so"); ++ char *libpath = uwsgi_concat2(upypy.home, "/" STR(PYPY_LDLIBRARY)); #elif defined(__APPLE__) - char *libpath = uwsgi_concat2(upypy.home, "/libpypy-c.dylib"); -+ char *libpath = uwsgi_concat2(upypy.home, "/libpypy3-c.dylib"); ++ char *libpath = uwsgi_concat2(upypy.home, "/" STR(PYPY_LDLIBRARY)); #else - char *libpath = uwsgi_concat2(upypy.home, "/libpypy-c.so"); -+ char *libpath = uwsgi_concat2(upypy.home, "/libpypy3-c.so"); ++ char *libpath = uwsgi_concat2(upypy.home, "/" STR(PYPY_LDLIBRARY)); #endif if (uwsgi_file_exists(libpath)) { upypy.handler = dlopen(libpath, RTLD_NOW | RTLD_GLOBAL); -@@ -98,11 +99,11 @@ static int uwsgi_pypy_init() { +@@ -98,11 +117,11 @@ static int uwsgi_pypy_init() { // fallback to standard library search path if (!upypy.handler) { #ifdef __CYGWIN__ - upypy.handler = dlopen("libpypy-c.dll", RTLD_NOW | RTLD_GLOBAL); -+ upypy.handler = dlopen("libpypy3-c.dll", RTLD_NOW | RTLD_GLOBAL); ++ upypy.handler = dlopen(STR(PYPY_LDLIBRARY), RTLD_NOW | RTLD_GLOBAL); #elif defined(__APPLE__) - upypy.handler = dlopen("libpypy-c.dylib", RTLD_NOW | RTLD_GLOBAL); -+ upypy.handler = dlopen("libpypy3-c.dylib", RTLD_NOW | RTLD_GLOBAL); ++ upypy.handler = dlopen(STR(PYPY_LDLIBRARY), RTLD_NOW | RTLD_GLOBAL); #else - upypy.handler = dlopen("libpypy-c.so", RTLD_NOW | RTLD_GLOBAL); -+ upypy.handler = dlopen("libpypy3-c.so", RTLD_NOW | RTLD_GLOBAL); ++ upypy.handler = dlopen(STR(PYPY_LDLIBRARY), RTLD_NOW | RTLD_GLOBAL); #endif } } -@@ -126,7 +127,7 @@ static int uwsgi_pypy_init() { +@@ -126,7 +145,7 @@ static int uwsgi_pypy_init() { u_pypy_init_threads = dlsym(upypy.handler, "pypy_init_threads"); if (!u_pypy_init_threads) { - uwsgi_log("!!! WARNING your libpypy-c does not export pypy_init_threads, multithreading will not work !!!\n"); -+ uwsgi_log("!!! WARNING your libpypy3-c does not export pypy_init_threads, multithreading will not work !!!\n"); ++ uwsgi_log("!!! WARNING your " STR(PYPY_LDLIBRARY) " does not export pypy_init_threads, multithreading will not work !!!\n"); } u_rpython_startup_code(); -@@ -161,7 +162,7 @@ ready: +@@ -140,7 +159,7 @@ static int uwsgi_pypy_init() { + } + + if (u_pypy_setup_home(upypy.home, 0)) { +- char *retry = uwsgi_concat2(upypy.home, "/lib_pypy"); ++ char *retry = uwsgi_concat2(upypy.home, "/" STR(PYPY_LIBDIR)); + if (uwsgi_is_dir(retry)) { + // this time we use debug + if (!u_pypy_setup_home(retry, 1)) { +@@ -161,7 +180,7 @@ ready: u_pypy_thread_attach = dlsym(upypy.handler, "pypy_thread_attach"); if (!u_pypy_thread_attach) { - uwsgi_log("!!! WARNING your libpypy-c does not export pypy_thread_attach, multithreading will not work !!!\n"); -+ uwsgi_log("!!! WARNING your libpypy3-c does not export pypy_thread_attach, multithreading will not work !!!\n"); ++ uwsgi_log("!!! WARNING your " STR(PYPY_LDLIBRARY) " does not export pypy_thread_attach, multithreading will not work !!!\n"); } if (upypy.setup) { -@@ -266,13 +267,17 @@ static void uwsgi_pypy_init_apps() { +@@ -266,13 +285,17 @@ static void uwsgi_pypy_init_apps() { } } @@ -112,18 +146,18 @@ static void uwsgi_opt_pypy_ini_paste(char *opt, char *value, void *foobar) { uwsgi_opt_load_ini(opt, value, NULL); upypy.paste = value; -@@ -372,8 +377,8 @@ static int uwsgi_pypy_mule(char *opt) { +@@ -372,8 +395,8 @@ static int uwsgi_pypy_mule(char *opt) { } -struct uwsgi_plugin pypy_plugin = { - .name = "pypy", -+struct uwsgi_plugin pypy3_plugin = { -+ .name = "pypy3", ++struct uwsgi_plugin CONCAT(PYPY_PLUGIN_NAME, _plugin) = { ++ .name = STR(PYPY_PLUGIN_NAME), .modifier1 = 0, .on_load = uwsgi_pypy_onload, .init = uwsgi_pypy_init, -@@ -388,4 +393,6 @@ struct uwsgi_plugin pypy_plugin = { +@@ -388,4 +411,6 @@ struct uwsgi_plugin pypy_plugin = { .rpc = uwsgi_pypy_rpc, .post_fork = uwsgi_pypy_post_fork, .mule = uwsgi_pypy_mule,
