Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using distutils #2564

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/asyncio/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from distutils import sysconfig
import sysconfig

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import sysconfig
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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sysconfig.get_path also allows us to specify which scheme we want with the second argument, rather than what you've done here. However, I'm loathe to check if 'deb_system' is a suitable scheme, but this only appears to rear it's head on Python 2, rather than every version of Python 3 that also ships distutils.

barriere% python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_path('include')
'/usr/include/python3.9'
>>> 
barriere% python2 
Python 2.7.18 (default, Jul 14 2021, 08:11:37) 
[GCC 10.2.1 20210110] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_path('include')
'/usr/local/include/python2.7'
>>> sysconfig.get_path('include', 'deb_system')
'/usr/include/python2.7'

NAME = 'asyncio'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude')
]
Comment on lines +6 to +7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude')
'-I' + i for i in filter(os.path.exists, get_includes()),

LDFLAGS = []
LIBS = []
Expand Down
6 changes: 3 additions & 3 deletions plugins/gevent/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from distutils import sysconfig
import sysconfig

NAME = 'gevent'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude')
]
LDFLAGS = []
LIBS = []
Expand Down
6 changes: 3 additions & 3 deletions plugins/greenlet/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from distutils import sysconfig
import sysconfig

NAME = 'greenlet'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude')
]
LDFLAGS = []
LIBS = []
Expand Down
6 changes: 3 additions & 3 deletions plugins/python/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys

from distutils import sysconfig
import sysconfig


def get_python_version():
Expand Down Expand Up @@ -31,8 +31,8 @@ def get_python_version():
]

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True),
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude'),
]
LDFLAGS = []

Expand Down
6 changes: 3 additions & 3 deletions plugins/pyuwsgi/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from distutils import sysconfig
import sysconfig
import os, sys

os.environ['UWSGI_PYTHON_NOLIB'] = '1'

NAME = 'pyuwsgi'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True),
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude'),
]
LDFLAGS = []
LIBS = []
Expand Down
6 changes: 3 additions & 3 deletions plugins/stackless/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from distutils import sysconfig
import sysconfig

NAME = 'stackless'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True),
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude'),
]
LDFLAGS = []
LIBS = []
Expand Down
6 changes: 3 additions & 3 deletions plugins/tornado/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from distutils import sysconfig
import sysconfig

NAME = 'tornado'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True),
'-I' + sysconfig.get_path('include'),
'-I' + sysconfig.get_path('platinclude'),
]
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
Loading