diff options
author | Cosimo Lupo <cosimo.lupo@daltonmaag.com> | 2016-05-18 13:03:33 +0100 |
---|---|---|
committer | Cosimo Lupo <cosimo.lupo@daltonmaag.com> | 2016-05-18 13:03:33 +0100 |
commit | 59b774b0c33c7351c83ac86a2ebd64e27cacc381 (patch) | |
tree | c6297063dfef6de2d37bb01d63d2082413dccc3d /setuptools/command/build_ext.py | |
parent | 0f476502ecbaf05870a9126e9b1caee9d95b7792 (diff) | |
download | external_python_setuptools-59b774b0c33c7351c83ac86a2ebd64e27cacc381.tar.gz external_python_setuptools-59b774b0c33c7351c83ac86a2ebd64e27cacc381.tar.bz2 external_python_setuptools-59b774b0c33c7351c83ac86a2ebd64e27cacc381.zip |
build_ext: move block customizing compiler for shared lib into a function
Diffstat (limited to 'setuptools/command/build_ext.py')
-rw-r--r-- | setuptools/command/build_ext.py | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py index f331f3a0..1caf8c81 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -22,6 +22,27 @@ 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) + + have_rtld = False use_stubs = False libtype = 'shared' @@ -120,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) |