aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/build_ext.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-08-19 16:00:56 -0400
committerGitHub <noreply@github.com>2016-08-19 16:00:56 -0400
commit6ae38d0538ceaa9c0360f7f04956acd5e138656d (patch)
treecf69b08b3d42c91165fddba2cc63d836d7db73d8 /setuptools/command/build_ext.py
parent7c32dac163b1d8f1256caf0a4e42ed19ff74d150 (diff)
parentfc6050ad4c1481be0a1aba1f056e76aa8be50039 (diff)
downloadexternal_python_setuptools-6ae38d0538ceaa9c0360f7f04956acd5e138656d.tar.gz
external_python_setuptools-6ae38d0538ceaa9c0360f7f04956acd5e138656d.tar.bz2
external_python_setuptools-6ae38d0538ceaa9c0360f7f04956acd5e138656d.zip
Merge pull request #718 from dholth/master
use abi3 extension if Extension().is_abi3
Diffstat (limited to 'setuptools/command/build_ext.py')
-rw-r--r--setuptools/command/build_ext.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py
index e6db0764..7bb4d24c 100644
--- a/setuptools/command/build_ext.py
+++ b/setuptools/command/build_ext.py
@@ -59,6 +59,14 @@ elif os.name != 'nt':
if_dl = lambda s: s if have_rtld else ''
+def get_abi3_suffix():
+ """Return the file extension for an abi3-compliant Extension()"""
+ import imp
+ for suffix, _, _ in (s for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION):
+ if '.abi3' in suffix: # Unix
+ return suffix
+ elif suffix == '.pyd': # Windows
+ return suffix
class build_ext(_build_ext):
@@ -96,6 +104,13 @@ class build_ext(_build_ext):
filename = _build_ext.get_ext_filename(self, fullname)
if fullname in self.ext_map:
ext = self.ext_map[fullname]
+ if (sys.version_info[0] != 2
+ and getattr(ext, 'py_limited_api')
+ and get_abi3_suffix()):
+ from distutils.sysconfig import get_config_var
+ so_ext = get_config_var('SO')
+ filename = filename[:-len(so_ext)]
+ filename = filename + get_abi3_suffix()
if isinstance(ext, Library):
fn, ext = os.path.splitext(filename)
return self.shlib_compiler.library_filename(fn, libtype)