diff -r 6a8fbb97c8d8 setup.py --- a/setup.py Thu Nov 26 02:36:26 2015 +0000 +++ b/setup.py Thu Nov 26 18:59:29 2015 +0800 @@ -568,10 +568,7 @@ if item.startswith('-L'): lib_dirs.append(item[2:]) - # Check for MacOS X, which doesn't need libm.a at all - math_libs = ['m'] - if host_platform == 'darwin': - math_libs = [] + math_libs = self.detect_math_libs() # XXX Omitted modules: gl, pure, dl, SGI-specific modules @@ -675,7 +672,7 @@ # Operations on audio samples # According to #993173, this one should actually work fine on # 64-bit platforms. - exts.append( Extension('audioop', ['audioop.c']) ) + exts.append( Extension('audioop', ['audioop.c'], libraries=math_libs) ) # readline do_readline = self.compiler.find_library_file(lib_dirs, 'readline') @@ -1940,6 +1937,8 @@ elif host_platform.startswith('hp-ux'): extra_link_args.append('-fPIC') + math_libs = self.detect_math_libs() + ext = Extension('_ctypes', include_dirs=include_dirs, extra_compile_args=extra_compile_args, @@ -1948,7 +1947,8 @@ sources=sources, depends=depends) ext_test = Extension('_ctypes_test', - sources=['_ctypes/_ctypes_test.c']) + sources=['_ctypes/_ctypes_test.c'], + libraries=math_libs) self.extensions.extend([ext, ext_test]) if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): @@ -2116,6 +2116,14 @@ ) return ext + def detect_math_libs(self): + # Check for MacOS X, which doesn't need libm.a at all + math_libs = ['m'] + if host_platform == 'darwin': + math_libs = [] + return math_libs + + class PyBuildInstall(install): # Suppress the warning about installation into the lib_dynload # directory, which is not in sys.path when running Python during