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: