summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
authorDaniel Holth <dholth@fastmail.fm>2016-08-03 21:55:39 -0400
committerDaniel Holth <dholth@fastmail.fm>2016-08-03 21:55:39 -0400
commita2605b297c147a1ad54078181d32fe369fa4f37d (patch)
tree59786ea683feecb6ec208792d6a2086b12995842 /setuptools/command
parent6a4e5446c941291ec5e7c56cee1d5a872300c955 (diff)
downloadpython-setuptools-git-a2605b297c147a1ad54078181d32fe369fa4f37d.tar.gz
use abi3 extension if Extension().is_abi3
Diffstat (limited to 'setuptools/command')
-rw-r--r--setuptools/command/build_ext.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py
index e6db0764..dad28999 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,11 @@ 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, 'is_abi3'):
+ 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)