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 <steven@wedontsleep.org>
Co-authored-by: Terence D. Honles <terence@honles.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
  • Loading branch information
3 people committed Nov 1, 2023
1 parent fb2a893 commit 8b83d55
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 34 deletions.
18 changes: 15 additions & 3 deletions plugins/asyncio/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +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)]
NAME = 'asyncio'

CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []

Expand Down
18 changes: 15 additions & 3 deletions plugins/gevent/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +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)]
NAME = 'gevent'

CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []

Expand Down
18 changes: 15 additions & 3 deletions plugins/greenlet/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +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)]
NAME = 'greenlet'

CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []

Expand Down
38 changes: 32 additions & 6 deletions plugins/python/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import os,sys

from distutils import sysconfig
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'),
]

def get_python_version():
version = sysconfig.get_config_var('VERSION')
Expand All @@ -10,10 +21,25 @@ def get_python_version():
pass
return version

NAME='python'
GCC_LIST = ['python_plugin', 'pyutils', 'pyloader', 'wsgi_handlers', 'wsgi_headers', 'wsgi_subhandler', 'web3_subhandler', 'pump_subhandler', 'gil', 'uwsgi_pymodule', 'profiler', 'symimporter', 'tracebacker', 'raw']
NAME = 'python'
GCC_LIST = [
'python_plugin',
'pyutils',
'pyloader',
'wsgi_handlers',
'wsgi_headers',
'wsgi_subhandler',
'web3_subhandler',
'pump_subhandler',
'gil',
'uwsgi_pymodule',
'profiler',
'symimporter',
'tracebacker',
'raw'
]

CFLAGS = ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True) ]
CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []

if not 'UWSGI_PYTHON_NOLIB' in os.environ:
Expand Down
19 changes: 16 additions & 3 deletions plugins/pyuwsgi/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
from distutils import sysconfig
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)]
NAME = 'pyuwsgi'

CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []

Expand Down
18 changes: 15 additions & 3 deletions plugins/stackless/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +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)]
NAME = 'stackless'

CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []

Expand Down
18 changes: 15 additions & 3 deletions plugins/tornado/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +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)]
NAME = 'tornado'

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
12 changes: 4 additions & 8 deletions uwsgiconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@

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

try:
from queue import Queue
except:
from Queue import Queue

try:
import sysconfig
except ImportError:
from distutils import sysconfig
from Queue import Queue

try:
import ConfigParser
except:
except ImportError:
import configparser as ConfigParser

try:
Expand Down

0 comments on commit 8b83d55

Please sign in to comment.