diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2020-10-17 16:34:23 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-10-17 16:34:23 -0400 |
| commit | 419087c45b105579f69d8bc729c1aa09eb493c17 (patch) | |
| tree | 88b2c194a60164aa460b378323b450423a7e88ee /setuptools/command/build_ext.py | |
| parent | 38de858e37f9c7a90498ea78c78ed76aca835ad2 (diff) | |
| parent | 898ae04656066d88add9c0a8750f32f938d99716 (diff) | |
| download | python-setuptools-git-419087c45b105579f69d8bc729c1aa09eb493c17.tar.gz | |
Merge branch 'master' into debt/drop-py35
Diffstat (limited to 'setuptools/command/build_ext.py')
| -rw-r--r-- | setuptools/command/build_ext.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py index 03b6f346..03a72b4f 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -1,6 +1,7 @@ import os import sys import itertools +from importlib.machinery import EXTENSION_SUFFIXES 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 @@ -9,15 +10,6 @@ from distutils.errors import DistutilsError 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 @@ -115,11 +107,7 @@ class build_ext(_build_ext): filename = _build_ext.get_ext_filename(self, fullname) if fullname in self.ext_map: ext = self.ext_map[fullname] - use_abi3 = ( - not six.PY2 - and getattr(ext, 'py_limited_api') - and get_abi3_suffix() - ) + use_abi3 = getattr(ext, 'py_limited_api') and get_abi3_suffix() if use_abi3: so_ext = get_config_var('EXT_SUFFIX') filename = filename[:-len(so_ext)] @@ -254,7 +242,8 @@ class build_ext(_build_ext): '\n'.join([ "def __bootstrap__():", " global __bootstrap__, __file__, __loader__", - " import sys, os, pkg_resources, imp" + if_dl(", dl"), + " import sys, os, pkg_resources, importlib.util" + + if_dl(", dl"), " __file__ = pkg_resources.resource_filename" "(__name__,%r)" % os.path.basename(ext._file_name), @@ -266,7 +255,10 @@ class build_ext(_build_ext): " try:", " os.chdir(os.path.dirname(__file__))", if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"), - " imp.load_dynamic(__name__,__file__)", + " spec = importlib.util.spec_from_file_location(", + " __name__, __file__)", + " mod = importlib.util.module_from_spec(spec)", + " spec.loader.exec_module(mod)", " finally:", if_dl(" sys.setdlopenflags(old_flags)"), " os.chdir(old_dir)", |
