summaryrefslogtreecommitdiff
path: root/setuptools/command/build_ext.py
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-07-08 09:32:21 -0700
committerPaul Ganssle <paul@ganssle.io>2019-08-17 14:29:21 -0700
commiteb7436b36f9967d1becd2b822da548bd59b35d05 (patch)
tree7eb76398792eafeb4e0a675ec1a7094efa3c1e3f /setuptools/command/build_ext.py
parent05f42a2c14275937250c99478c94b20171d14aeb (diff)
downloadpython-setuptools-git-eb7436b36f9967d1becd2b822da548bd59b35d05.tar.gz
Fix some usage of deprecated `imp` module
Diffstat (limited to 'setuptools/command/build_ext.py')
-rw-r--r--setuptools/command/build_ext.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py
index 60a8a32f..daa8e4fe 100644
--- a/setuptools/command/build_ext.py
+++ b/setuptools/command/build_ext.py
@@ -1,7 +1,6 @@
import os
import sys
import itertools
-import imp
from distutils.command.build_ext import build_ext as _du_build_ext
from distutils.file_util import copy_file
from distutils.ccompiler import new_compiler
@@ -12,6 +11,13 @@ from distutils import log
from setuptools.extension import Library
from setuptools.extern import six
+if six.PY2:
+ import imp
+
+ EXTENSION_SUFFIXES = [s for s, _, tp in imp.get_suffixes() if tp == imp.C_EXTENSION]
+else:
+ from importlib.machinery import EXTENSION_SUFFIXES
+
try:
# Attempt to use Cython for building extensions, if available
from Cython.Distutils.build_ext import build_ext as _build_ext
@@ -64,7 +70,7 @@ if_dl = lambda s: s if have_rtld else ''
def get_abi3_suffix():
"""Return the file extension for an abi3-compliant Extension()"""
- for suffix, _, _ in (s for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION):
+ for suffix in EXTENSION_SUFFIXES:
if '.abi3' in suffix: # Unix
return suffix
elif suffix == '.pyd': # Windows