From 5383fff1e7038124393888991585b953c39b6aec Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Fri, 7 Oct 2016 22:52:09 +0200 Subject: Blindly attempt to detect MinGW (issue #159) --- setup.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index d30f057..f8fcb7a 100644 --- a/setup.py +++ b/setup.py @@ -51,12 +51,17 @@ def no_working_compiler_found(): see http://stackoverflow.com/questions/22313407/ .)\n""") sys.exit(1) -def ask_supports_thread(): +def get_config(): from distutils.core import Distribution from distutils.sysconfig import get_config_vars get_config_vars() # workaround for a bug of distutils, e.g. on OS/X config = Distribution().get_command_obj('config') - ok = config.try_compile('__thread int some_threadlocal_variable_42;') + return config + +def ask_supports_thread(): + config = get_config() + ok = (sys.platform != 'win32' and + config.try_compile('__thread int some_threadlocal_variable_42;')) if ok: define_macros.append(('USE__THREAD', None)) else: @@ -66,6 +71,10 @@ def ask_supports_thread(): sys.stderr.write("Note: will not use '__thread' in the C code\n") sys.stderr.write("The above error message can be safely ignored\n") +def uses_msvc(): + config = get_config() + return config.try_compile('#ifndef _MSC_VER\n#error "not MSVC"\n#endif') + def use_pkg_config(): if sys.platform == 'darwin' and os.path.exists('/usr/local/bin/brew'): use_homebrew_for_libffi() @@ -86,7 +95,7 @@ def use_homebrew_for_libffi(): os.environ.get('PKG_CONFIG_PATH', '') + ':' + pkgconfig) -if sys.platform == 'win32': +if sys.platform == 'win32' and uses_msvc(): COMPILE_LIBFFI = 'c/libffi_msvc' # from the CPython distribution else: COMPILE_LIBFFI = None -- cgit v1.2.1