diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2016-05-22 14:38:41 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-05-22 14:38:41 -0400 |
| commit | f9b1e6733434d7ef2060722dc564fbf24249cfb3 (patch) | |
| tree | 0ddcbbfd129ac1c7ed4608571c705cbe7297175c /setuptools/command/build_ext.py | |
| parent | b83cf1a68091b8de46f0ba19f1ce2f031d9cdc94 (diff) | |
| parent | de5db9dbd9da6802219fe1b70ba84207f60470dd (diff) | |
| download | python-setuptools-git-f9b1e6733434d7ef2060722dc564fbf24249cfb3.tar.gz | |
Merge with 21.2.0
Diffstat (limited to 'setuptools/command/build_ext.py')
| -rw-r--r-- | setuptools/command/build_ext.py | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py index 92e4a189..1caf8c81 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -16,15 +16,32 @@ try: except ImportError: _build_ext = _du_build_ext -try: - # Python 2.7 or >=3.2 - from sysconfig import _CONFIG_VARS -except ImportError: - from distutils.sysconfig import get_config_var +from distutils.sysconfig import get_config_var + +get_config_var("LDSHARED") # make sure _config_vars is initialized +del get_config_var +from distutils.sysconfig import _config_vars as _CONFIG_VARS + + +def _customize_compiler_for_shlib(compiler): + if sys.platform == "darwin": + # building .dylib requires additional compiler flags on OSX; here we + # temporarily substitute the pyconfig.h variables so that distutils' + # 'customize_compiler' uses them before we build the shared libraries. + tmp = _CONFIG_VARS.copy() + try: + # XXX Help! I don't have any idea whether these are right... + _CONFIG_VARS['LDSHARED'] = ( + "gcc -Wl,-x -dynamiclib -undefined dynamic_lookup") + _CONFIG_VARS['CCSHARED'] = " -dynamiclib" + _CONFIG_VARS['SO'] = ".dylib" + customize_compiler(compiler) + finally: + _CONFIG_VARS.clear() + _CONFIG_VARS.update(tmp) + else: + customize_compiler(compiler) - get_config_var("LDSHARED") # make sure _config_vars is initialized - del get_config_var - from distutils.sysconfig import _config_vars as _CONFIG_VARS have_rtld = False use_stubs = False @@ -124,20 +141,7 @@ class build_ext(_build_ext): compiler = self.shlib_compiler = new_compiler( compiler=self.compiler, dry_run=self.dry_run, force=self.force ) - if sys.platform == "darwin": - tmp = _CONFIG_VARS.copy() - try: - # XXX Help! I don't have any idea whether these are right... - _CONFIG_VARS['LDSHARED'] = ( - "gcc -Wl,-x -dynamiclib -undefined dynamic_lookup") - _CONFIG_VARS['CCSHARED'] = " -dynamiclib" - _CONFIG_VARS['SO'] = ".dylib" - customize_compiler(compiler) - finally: - _CONFIG_VARS.clear() - _CONFIG_VARS.update(tmp) - else: - customize_compiler(compiler) + _customize_compiler_for_shlib(compiler) if self.include_dirs is not None: compiler.set_include_dirs(self.include_dirs) |
