Skip to content

Commit

Permalink
Use sysconfig if distutils is not available
Browse files Browse the repository at this point in the history
distutils have been removed in Python 3.12.

Co-authored-by: Steve Kowalik <[email protected]>
Co-authored-by: Terence D. Honles <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
  • Loading branch information
3 people committed Oct 6, 2023
1 parent 0e9eb9f commit b030a71
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 42 deletions.
18 changes: 13 additions & 5 deletions plugins/asyncio/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -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']
18 changes: 13 additions & 5 deletions plugins/gevent/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -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 = []

Expand Down
18 changes: 13 additions & 5 deletions plugins/greenlet/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -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 = []

Expand Down
20 changes: 13 additions & 7 deletions plugins/python/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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:
Expand Down
21 changes: 15 additions & 6 deletions plugins/pyuwsgi/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -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 = []

Expand Down
18 changes: 13 additions & 5 deletions plugins/stackless/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -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 = []

Expand Down
18 changes: 13 additions & 5 deletions plugins/tornado/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -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 = []

Expand Down
3 changes: 1 addition & 2 deletions setup.cpyext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions uwsgiconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import sys
import subprocess
import sysconfig
from threading import Thread, Lock
from optparse import OptionParser

Expand All @@ -20,8 +21,6 @@
except ImportError:
from Queue import Queue

from distutils import sysconfig

try:
import ConfigParser
except ImportError:
Expand Down

0 comments on commit b030a71

Please sign in to comment.