From d87ac7540824d73ebd68819ba3fd5784e95080bb Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Wed, 4 Oct 2023 12:08:28 +0200 Subject: [PATCH] use distutils if it's available --- plugins/asyncio/uwsgiplugin.py | 18 ++++++++++++++---- plugins/gevent/uwsgiplugin.py | 18 ++++++++++++++---- plugins/greenlet/uwsgiplugin.py | 18 ++++++++++++++---- plugins/python/uwsgiplugin.py | 17 +++++++++++++---- plugins/pyuwsgi/uwsgiplugin.py | 17 +++++++++++++---- plugins/stackless/uwsgiplugin.py | 18 ++++++++++++++---- plugins/tornado/uwsgiplugin.py | 18 ++++++++++++++---- 7 files changed, 96 insertions(+), 28 deletions(-) diff --git a/plugins/asyncio/uwsgiplugin.py b/plugins/asyncio/uwsgiplugin.py index eff6c62c4..84178c8ce 100644 --- a/plugins/asyncio/uwsgiplugin.py +++ b/plugins/asyncio/uwsgiplugin.py @@ -1,11 +1,21 @@ +import os import sysconfig +def get_includes(): + try: + from distutils import sysconfig as legacy + except ImportError: + legacy = None + + yield sysconfig.get_path('include') + yield sysconfig.get_path('platinclude') + if legacy: + yield legacy.get_python_inc() + yield legacy.get_python_inc(plat_specific=True) + NAME = 'asyncio' -CFLAGS = [ - '-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude') -] +CFLAGS = ['-I' + i for i in filter(os.path.exists, get_includes())] LDFLAGS = [] LIBS = [] GCC_LIST = ['asyncio'] diff --git a/plugins/gevent/uwsgiplugin.py b/plugins/gevent/uwsgiplugin.py index 4d97e1ad1..40f654cc6 100644 --- a/plugins/gevent/uwsgiplugin.py +++ b/plugins/gevent/uwsgiplugin.py @@ -1,11 +1,21 @@ +import os import sysconfig +def get_includes(): + try: + from distutils import sysconfig as legacy + except ImportError: + legacy = None + + yield sysconfig.get_path('include') + yield sysconfig.get_path('platinclude') + if legacy: + yield legacy.get_python_inc() + yield legacy.get_python_inc(plat_specific=True) + NAME = 'gevent' -CFLAGS = [ - '-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude') -] +CFLAGS = ['-I' + i for i in filter(os.path.exists, get_includes())] LDFLAGS = [] LIBS = [] diff --git a/plugins/greenlet/uwsgiplugin.py b/plugins/greenlet/uwsgiplugin.py index c5ba15427..e710bb67f 100644 --- a/plugins/greenlet/uwsgiplugin.py +++ b/plugins/greenlet/uwsgiplugin.py @@ -1,11 +1,21 @@ +import os import sysconfig +def get_includes(): + try: + from distutils import sysconfig as legacy + except ImportError: + legacy = None + + yield sysconfig.get_path('include') + yield sysconfig.get_path('platinclude') + if legacy: + yield legacy.get_python_inc() + yield legacy.get_python_inc(plat_specific=True) + NAME = 'greenlet' -CFLAGS = [ - '-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude') -] +CFLAGS = ['-I' + i for i in filter(os.path.exists, get_includes())] LDFLAGS = [] LIBS = [] diff --git a/plugins/python/uwsgiplugin.py b/plugins/python/uwsgiplugin.py index 63a7653cb..a466c41ea 100644 --- a/plugins/python/uwsgiplugin.py +++ b/plugins/python/uwsgiplugin.py @@ -3,6 +3,18 @@ import sysconfig +def get_includes(): + try: + from distutils import sysconfig as legacy + except ImportError: + legacy = None + + yield sysconfig.get_path('include') + yield sysconfig.get_path('platinclude') + if legacy: + yield legacy.get_python_inc() + yield legacy.get_python_inc(plat_specific=True) + def get_python_version(): version = sysconfig.get_config_var('VERSION') @@ -30,10 +42,7 @@ def get_python_version(): 'raw' ] -CFLAGS = [ - '-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude'), -] +CFLAGS = ['-I' + i for i in filter(os.path.exists, get_includes())] LDFLAGS = [] if 'UWSGI_PYTHON_NOLIB' not in os.environ: diff --git a/plugins/pyuwsgi/uwsgiplugin.py b/plugins/pyuwsgi/uwsgiplugin.py index 3cdb99ddb..fcbcacd1c 100644 --- a/plugins/pyuwsgi/uwsgiplugin.py +++ b/plugins/pyuwsgi/uwsgiplugin.py @@ -1,14 +1,23 @@ import sysconfig import os, sys +def get_includes(): + try: + from distutils import sysconfig as legacy + except ImportError: + legacy = None + + yield sysconfig.get_path('include') + yield sysconfig.get_path('platinclude') + if legacy: + yield legacy.get_python_inc() + yield legacy.get_python_inc(plat_specific=True) + os.environ['UWSGI_PYTHON_NOLIB'] = '1' NAME = 'pyuwsgi' -CFLAGS = [ - '-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude'), -] +CFLAGS = ['-I' + i for i in filter(os.path.exists, get_includes())] LDFLAGS = [] LIBS = [] diff --git a/plugins/stackless/uwsgiplugin.py b/plugins/stackless/uwsgiplugin.py index 61a11e0e9..ab8d50ec6 100644 --- a/plugins/stackless/uwsgiplugin.py +++ b/plugins/stackless/uwsgiplugin.py @@ -1,11 +1,21 @@ +import os import sysconfig +def get_includes(): + try: + from distutils import sysconfig as legacy + except ImportError: + legacy = None + + yield sysconfig.get_path('include') + yield sysconfig.get_path('platinclude') + if legacy: + yield legacy.get_python_inc() + yield legacy.get_python_inc(plat_specific=True) + NAME = 'stackless' -CFLAGS = [ - '-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude'), -] +CFLAGS = ['-I' + i for i in filter(os.path.exists, get_includes())] LDFLAGS = [] LIBS = [] diff --git a/plugins/tornado/uwsgiplugin.py b/plugins/tornado/uwsgiplugin.py index 15a2460b1..e3db34fe9 100644 --- a/plugins/tornado/uwsgiplugin.py +++ b/plugins/tornado/uwsgiplugin.py @@ -1,11 +1,21 @@ +import os import sysconfig +def get_includes(): + try: + from distutils import sysconfig as legacy + except ImportError: + legacy = None + + yield sysconfig.get_path('include') + yield sysconfig.get_path('platinclude') + if legacy: + yield legacy.get_python_inc() + yield legacy.get_python_inc(plat_specific=True) + NAME = 'tornado' -CFLAGS = [ - '-I' + sysconfig.get_path('include'), - '-I' + sysconfig.get_path('platinclude'), -] +CFLAGS = ['-I' + i for i in filter(os.path.exists, get_includes())] LDFLAGS = [] LIBS = []