From d94f6db506d8de2d21328845698359b8f6ad8135 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Tue, 25 Jul 2023 17:43:50 +0200 Subject: [PATCH 1/8] core/lock: silence glibc warnings against pthread robust mutex functions Since glibc 2.34 we are gettings warnings that pthread_mutexattr_setrobust_np and pthread_mutex_consistent_np are deprecated. Problem is that we are checking PTHREAD_MUTEX_ROBUST with the preprocessor but it doesn't work because it's an enum :) So in the end we are using the _np versions of the functions even if the standard ones are available. Since this stuff is implemented on linux libc since 2010-2011 and 2016 in freebsd assume it's here. --- core/lock.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core/lock.c b/core/lock.c index 686e3b106a..eb0de35cfc 100644 --- a/core/lock.c +++ b/core/lock.c @@ -91,11 +91,6 @@ struct uwsgi_lock_item *uwsgi_lock_fast_init(char *id) { } #ifdef EOWNERDEAD -#ifndef PTHREAD_MUTEX_ROBUST -#define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP -#define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np -#define pthread_mutex_consistent pthread_mutex_consistent_np -#endif if (uwsgi_pthread_robust_mutexes_enabled) { int ret; if ((ret = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) != 0) { From 152123d1dbd3727793a9852149c5d255bdcf52ec Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 28 Jul 2023 09:40:59 +0200 Subject: [PATCH 2/8] RELEASE: fix typo in tags pushing --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 5d3b0106ca..0e112d57b4 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -16,7 +16,7 @@ Please remember to substitute XY with proper version. ``` git tag 2.0.XY -git push ---tags origin HEAD +git push --tags origin HEAD git archive HEAD --prefix uwsgi-2.0.XY/ -o uwsgi-2.0.XY.tar.gz ``` From 8924b79a9f1dc503431bad9048e964f5afb5d837 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 28 Jul 2023 22:15:17 +0200 Subject: [PATCH 3/8] plugins/jvm: fixup jvm library path detection Fix #2552 --- plugins/jvm/uwsgiplugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jvm/uwsgiplugin.py b/plugins/jvm/uwsgiplugin.py index 4a99386ab3..f3c369abf6 100644 --- a/plugins/jvm/uwsgiplugin.py +++ b/plugins/jvm/uwsgiplugin.py @@ -36,7 +36,7 @@ for jvm in known_jvms: if os.path.exists(jvm + '/include'): JVM_INCPATH = ["-I%s/include/" % jvm, "-I%s/include/%s" % (jvm, operating_system)] - if os.path.exists("%s/jre"): + if os.path.exists("%s/jre" % jvm): JVM_LIBPATH = ["-L%s/jre/lib/%s/server" % (jvm, arch)] else: JVM_LIBPATH = ["-L%s/lib/server" % (jvm,)] From 21366abc98e8e15c4586d054a880587bee511d2f Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sat, 26 Aug 2023 17:20:45 +0200 Subject: [PATCH 4/8] RELEASE: add to update the Download uwsgi-docs page after release --- RELEASE.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE.md b/RELEASE.md index 0e112d57b4..5ceb7a7e29 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -25,3 +25,6 @@ Then the tarball must be uploaded to pypi with: ``` python3 -m twine upload uwsgi-2.0.XY.tar.gz ``` + +Once the file is uploaded the `Download.rst` page of [uwsgi-docs repository](https://github.com/unbit/uwsgi-docs) +should be updated. From 064984116e86ac0a5d5d3805765395b661fc4455 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 4 Sep 2023 13:10:52 +0200 Subject: [PATCH 5/8] ini_entries is read-only PHP 8.3 --- plugins/php/php_plugin.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/php/php_plugin.c b/plugins/php/php_plugin.c index b3efa006ac..d9b615bac9 100644 --- a/plugins/php/php_plugin.c +++ b/plugins/php/php_plugin.c @@ -27,6 +27,7 @@ struct uwsgi_php { char *fallback; char *fallback2; char *fallback_qs; + char *ini_entries; size_t ini_size; int dump_config; char *server_software; @@ -232,21 +233,22 @@ static sapi_module_struct uwsgi_sapi_module; void uwsgi_php_append_config(char *filename) { size_t file_size = 0; - char *file_content = uwsgi_open_and_read(filename, &file_size, 1, NULL); - uwsgi_sapi_module.ini_entries = realloc(uwsgi_sapi_module.ini_entries, uphp.ini_size + file_size); - memcpy(uwsgi_sapi_module.ini_entries + uphp.ini_size, file_content, file_size); + char *file_content = uwsgi_open_and_read(filename, &file_size, 1, NULL); + uphp.ini_entries = realloc(uphp.ini_entries, uphp.ini_size + file_size); + memcpy(uphp.ini_entries + uphp.ini_size, file_content, file_size); uphp.ini_size += file_size-1; free(file_content); + uwsgi_sapi_module.ini_entries = uphp.ini_entries; } void uwsgi_php_set(char *opt) { - uwsgi_sapi_module.ini_entries = realloc(uwsgi_sapi_module.ini_entries, uphp.ini_size + strlen(opt)+2); - memcpy(uwsgi_sapi_module.ini_entries + uphp.ini_size, opt, strlen(opt)); - + uphp.ini_entries = realloc(uphp.ini_entries, uphp.ini_size + strlen(opt)+2); + memcpy(uphp.ini_entries + uphp.ini_size, opt, strlen(opt)); uphp.ini_size += strlen(opt)+1; - uwsgi_sapi_module.ini_entries[uphp.ini_size-1] = '\n'; - uwsgi_sapi_module.ini_entries[uphp.ini_size] = 0; + uphp.ini_entries[uphp.ini_size-1] = '\n'; + uphp.ini_entries[uphp.ini_size] = 0; + uwsgi_sapi_module.ini_entries = uphp.ini_entries; } extern ps_module ps_mod_uwsgi; From 18816280a4a91ca39193bba73bc04b047645bbbd Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Wed, 19 Jul 2023 19:42:31 +0200 Subject: [PATCH 6/8] This adds support for Python 3.12 The code compiles, and runs all my (admittedly pretty primitive) web applications. There may still be hidden issues in more complicated scenarios (like threading support). --- .github/workflows/test.yml | 4 +- plugins/python/python_plugin.c | 74 +++++++++++++++++++++++++--------- plugins/python/uwsgi_python.h | 14 ++++++- 3 files changed, 69 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 739bed40d4..009d48438e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] test-suite: [unittest, python, deadlocks] steps: - name: Add deadnakes ppa @@ -24,7 +24,7 @@ jobs: libpcre3-dev libjansson-dev libcap2-dev \ curl check - name: Install distutils - if: contains(fromJson('["3.6","3.7","3.8","3.9","3.10","3.11"]'), matrix.python-version) + if: contains(fromJson('["3.6","3.7","3.8","3.9","3.10","3.11","3.12"]'), matrix.python-version) run: | sudo apt install --no-install-recommends -qqyf python${{ matrix.python-version }}-distutils \ - uses: actions/checkout@v2 diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index dcb5d348e0..de92f34c2f 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -233,6 +233,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'); @@ -298,6 +313,9 @@ int uwsgi_python_init() { 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 @@ -660,21 +678,6 @@ void init_uwsgi_vars() { -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; @@ -695,7 +698,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); @@ -1208,7 +1213,10 @@ void uwsgi_python_init_apps() { // prepare for stack suspend/resume if (uwsgi.async > 0) { -#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); @@ -1360,7 +1368,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 } } @@ -1372,7 +1385,12 @@ void uwsgi_python_post_uwsgi_fork(int step) { 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 { @@ -1643,7 +1661,11 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) { 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 @@ -1652,7 +1674,11 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) { #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 @@ -1886,7 +1912,11 @@ void uwsgi_python_resume(struct wsgi_request *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 @@ -1895,7 +1925,11 @@ void uwsgi_python_resume(struct wsgi_request *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 diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index 1e75fd641c..961a46c49f 100644 --- a/plugins/python/uwsgi_python.h +++ b/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 @@ -182,7 +186,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; From 8f7178f1a825e646df564ed225ff3a18d28d479d Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sun, 17 Sep 2023 16:23:17 +0200 Subject: [PATCH 7/8] ci: run compile test on ubuntu 22.04 too --- .github/workflows/compile-test.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compile-test.yml b/.github/workflows/compile-test.yml index 9d9c564fdc..2a05e3495b 100644 --- a/.github/workflows/compile-test.yml +++ b/.github/workflows/compile-test.yml @@ -8,22 +8,31 @@ on: jobs: build: + strategy: + matrix: + include: + - os: ubuntu-20.04 + php: "php7.4" + php-config: "php-config7.4" + - os: ubuntu-22.04 + php: "php8.1" + php-config: "php-config8.1" - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} steps: - name: remove sury php ppa that does not ship libphpX.Y-embed run: | sudo add-apt-repository --remove ppa:ondrej/php - sudo apt remove php7.4-dev php7.4 php7.4-common + sudo apt remove ${{ matrix.php }}-dev ${{ matrix.php }} ${{ matrix.php }}-common - name: Install dependencies run: | sudo apt update -qq - sudo apt install --no-install-recommends -qqyf python3.8-dev \ + sudo apt install --no-install-recommends -qqyf python3-dev \ libxml2-dev libpcre3-dev libcap2-dev \ libargon2-0-dev libsodium-dev \ - php7.4-dev libphp7.4-embed \ - liblua5.1-0-dev ruby2.7-dev \ + ${{ matrix.php }}-dev lib${{ matrix.php }}-embed \ + liblua5.1-0-dev ruby-dev \ libjansson-dev libldap2-dev libpq-dev \ libpam0g-dev libsqlite3-dev libyaml-dev \ libzmq3-dev libmatheval-dev libperl-dev \ @@ -37,7 +46,7 @@ jobs: curl check - uses: actions/checkout@v2 - name: Build kitchensink uWSGI binary - run: UWSGICONFIG_PHPPATH=php-config7.4 /usr/bin/python3 uwsgiconfig.py --build travis + run: UWSGICONFIG_PHPPATH=${{ matrix.php-config }} /usr/bin/python3 uwsgiconfig.py --build travis - name: Build uWSGI binary run: | /usr/bin/python3 uwsgiconfig.py --build base From b030a71bb3f3d512a719ad71b5d5d73593e0b6f7 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Wed, 4 Oct 2023 12:36:02 +1100 Subject: [PATCH 8/8] Use sysconfig if distutils is not available distutils have been removed in Python 3.12. Co-authored-by: Steve Kowalik Co-authored-by: Terence D. Honles Co-authored-by: Riccardo Magliocchetti --- plugins/asyncio/uwsgiplugin.py | 18 +++++++++++++----- plugins/gevent/uwsgiplugin.py | 18 +++++++++++++----- plugins/greenlet/uwsgiplugin.py | 18 +++++++++++++----- plugins/python/uwsgiplugin.py | 20 +++++++++++++------- plugins/pyuwsgi/uwsgiplugin.py | 21 +++++++++++++++------ plugins/stackless/uwsgiplugin.py | 18 +++++++++++++----- plugins/tornado/uwsgiplugin.py | 18 +++++++++++++----- setup.cpyext.py | 3 +-- uwsgiconfig.py | 3 +-- 9 files changed, 95 insertions(+), 42 deletions(-) diff --git a/plugins/asyncio/uwsgiplugin.py b/plugins/asyncio/uwsgiplugin.py index 7cb17f54eb..56e56e8150 100644 --- a/plugins/asyncio/uwsgiplugin.py +++ b/plugins/asyncio/uwsgiplugin.py @@ -1,11 +1,19 @@ -from distutils import sysconfig +try: + from distutils import sysconfig + paths = [ + sysconfig.get_python_inc(), + sysconfig.get_python_inc(plat_specific=True), + ] +except ImportError: + import sysconfig + paths = [ + sysconfig.get_path('include'), + sysconfig.get_path('platinclude'), + ] NAME = 'asyncio' -CFLAGS = [ - '-I' + sysconfig.get_python_inc(), - '-I' + sysconfig.get_python_inc(plat_specific=True) -] +CFLAGS = ['-I' + path for path in paths] LDFLAGS = [] LIBS = [] GCC_LIST = ['asyncio'] diff --git a/plugins/gevent/uwsgiplugin.py b/plugins/gevent/uwsgiplugin.py index 4ff550a9f9..422a5ffc19 100644 --- a/plugins/gevent/uwsgiplugin.py +++ b/plugins/gevent/uwsgiplugin.py @@ -1,11 +1,19 @@ -from distutils import sysconfig +try: + from distutils import sysconfig + paths = [ + sysconfig.get_python_inc(), + sysconfig.get_python_inc(plat_specific=True), + ] +except ImportError: + import sysconfig + paths = [ + sysconfig.get_path('include'), + sysconfig.get_path('platinclude'), + ] NAME = 'gevent' -CFLAGS = [ - '-I' + sysconfig.get_python_inc(), - '-I' + sysconfig.get_python_inc(plat_specific=True) -] +CFLAGS = ['-I' + path for path in paths] LDFLAGS = [] LIBS = [] diff --git a/plugins/greenlet/uwsgiplugin.py b/plugins/greenlet/uwsgiplugin.py index 27b1da1235..c712b53699 100644 --- a/plugins/greenlet/uwsgiplugin.py +++ b/plugins/greenlet/uwsgiplugin.py @@ -1,11 +1,19 @@ -from distutils import sysconfig +try: + from distutils import sysconfig + paths = [ + sysconfig.get_python_inc(), + sysconfig.get_python_inc(plat_specific=True), + ] +except ImportError: + import sysconfig + paths = [ + sysconfig.get_path('include'), + sysconfig.get_path('platinclude'), + ] NAME = 'greenlet' -CFLAGS = [ - '-I' + sysconfig.get_python_inc(), - '-I' + sysconfig.get_python_inc(plat_specific=True) -] +CFLAGS = ['-I' + path for path in paths] LDFLAGS = [] LIBS = [] diff --git a/plugins/python/uwsgiplugin.py b/plugins/python/uwsgiplugin.py index e3765c997b..7de8457376 100644 --- a/plugins/python/uwsgiplugin.py +++ b/plugins/python/uwsgiplugin.py @@ -1,8 +1,17 @@ import os import sys - -from distutils import sysconfig - +try: + from distutils import sysconfig + paths = [ + sysconfig.get_python_inc(), + sysconfig.get_python_inc(plat_specific=True), + ] +except ImportError: + import sysconfig + paths = [ + sysconfig.get_path('include'), + sysconfig.get_path('platinclude'), + ] def get_python_version(): version = sysconfig.get_config_var('VERSION') @@ -30,10 +39,7 @@ def get_python_version(): 'raw' ] -CFLAGS = [ - '-I' + sysconfig.get_python_inc(), - '-I' + sysconfig.get_python_inc(plat_specific=True), -] +CFLAGS = ['-I' + path for path in paths] LDFLAGS = [] if 'UWSGI_PYTHON_NOLIB' not in os.environ: diff --git a/plugins/pyuwsgi/uwsgiplugin.py b/plugins/pyuwsgi/uwsgiplugin.py index 4b6bce042a..3bfd66eddf 100644 --- a/plugins/pyuwsgi/uwsgiplugin.py +++ b/plugins/pyuwsgi/uwsgiplugin.py @@ -1,14 +1,23 @@ -from distutils import sysconfig -import os, sys +import os +import sys +try: + from distutils import sysconfig + paths = [ + sysconfig.get_python_inc(), + sysconfig.get_python_inc(plat_specific=True), + ] +except ImportError: + import sysconfig + paths = [ + sysconfig.get_path('include'), + sysconfig.get_path('platinclude'), + ] os.environ['UWSGI_PYTHON_NOLIB'] = '1' NAME = 'pyuwsgi' -CFLAGS = [ - '-I' + sysconfig.get_python_inc(), - '-I' + sysconfig.get_python_inc(plat_specific=True), -] +CFLAGS = ['-I' + path for path in paths] LDFLAGS = [] LIBS = [] diff --git a/plugins/stackless/uwsgiplugin.py b/plugins/stackless/uwsgiplugin.py index d720e2b9bd..a304b97a52 100644 --- a/plugins/stackless/uwsgiplugin.py +++ b/plugins/stackless/uwsgiplugin.py @@ -1,11 +1,19 @@ -from distutils import sysconfig +try: + from distutils import sysconfig + paths = [ + sysconfig.get_python_inc(), + sysconfig.get_python_inc(plat_specific=True), + ] +except ImportError: + import sysconfig + paths = [ + sysconfig.get_path('include'), + sysconfig.get_path('platinclude'), + ] NAME = 'stackless' -CFLAGS = [ - '-I' + sysconfig.get_python_inc(), - '-I' + sysconfig.get_python_inc(plat_specific=True), -] +CFLAGS = ['-I' + path for path in paths] LDFLAGS = [] LIBS = [] diff --git a/plugins/tornado/uwsgiplugin.py b/plugins/tornado/uwsgiplugin.py index c0179b609b..f80b6efbf1 100644 --- a/plugins/tornado/uwsgiplugin.py +++ b/plugins/tornado/uwsgiplugin.py @@ -1,11 +1,19 @@ -from distutils import sysconfig +try: + from distutils import sysconfig + paths = [ + sysconfig.get_python_inc(), + sysconfig.get_python_inc(plat_specific=True), + ] +except ImportError: + import sysconfig + paths = [ + sysconfig.get_path('include'), + sysconfig.get_path('platinclude'), + ] NAME = 'tornado' -CFLAGS = [ - '-I' + sysconfig.get_python_inc(), - '-I' + sysconfig.get_python_inc(plat_specific=True), -] +CFLAGS = ['-I' + path for path in paths] LDFLAGS = [] LIBS = [] diff --git a/setup.cpyext.py b/setup.cpyext.py index c29b1d3a9a..9a238d7ab0 100644 --- a/setup.cpyext.py +++ b/setup.cpyext.py @@ -12,9 +12,8 @@ import shlex import uwsgiconfig -from setuptools import setup +from setuptools import setup, Extension from setuptools.command.build_ext import build_ext -from distutils.core import Extension class uWSGIBuildExt(build_ext): diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 344e0a941d..26a5297a53 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -12,6 +12,7 @@ import sys import subprocess +import sysconfig from threading import Thread, Lock from optparse import OptionParser @@ -20,8 +21,6 @@ except ImportError: from Queue import Queue -from distutils import sysconfig - try: import ConfigParser except ImportError: