[Python-checkins] remove detect_math_libs (#4383)

Benjamin Peterson webhook-mailer at python.org
Sun Nov 12 23:53:42 EST 2017


https://github.com/python/cpython/commit/8acaa31eec84010c2211b838cffa9f69a91a5240
commit: 8acaa31eec84010c2211b838cffa9f69a91a5240
branch: master
author: Benjamin Peterson <benjamin at python.org>
committer: GitHub <noreply at github.com>
date: 2017-11-12T20:53:39-08:00
summary:

remove detect_math_libs (#4383)

Darwin may not require libm, but it doesn't hurt to link it and simplifies configuration logic.

files:
M setup.py

diff --git a/setup.py b/setup.py
index f284301ea4c..cbe6139ddec 100644
--- a/setup.py
+++ b/setup.py
@@ -501,13 +501,6 @@ def add_gcc_paths(self):
         finally:
             os.unlink(tmpfile)
 
-    def detect_math_libs(self):
-        # Check for MacOS X, which doesn't need libm.a at all
-        if host_platform == 'darwin':
-            return []
-        else:
-            return ['m']
-
     def detect_modules(self):
         # Ensure that /usr/local is always used, but the local build
         # directories (i.e. '.' and 'Include') must be first.  See issue
@@ -613,8 +606,6 @@ def detect_modules(self):
                 if item.startswith('-L'):
                     lib_dirs.append(item[2:])
 
-        math_libs = self.detect_math_libs()
-
         #
         # The following modules are all pretty straightforward, and compile
         # on pretty much any POSIXish platform.
@@ -628,12 +619,12 @@ def detect_modules(self):
         exts.append( Extension('cmath', ['cmathmodule.c'],
                                extra_objects=[shared_math],
                                depends=['_math.h', shared_math],
-                               libraries=math_libs) )
+                               libraries=['m']) )
         # math library functions, e.g. sin()
         exts.append( Extension('math',  ['mathmodule.c'],
                                extra_objects=[shared_math],
                                depends=['_math.h', shared_math],
-                               libraries=math_libs) )
+                               libraries=['m']) )
 
         # time libraries: librt may be needed for clock_gettime()
         time_libs = []
@@ -644,10 +635,10 @@ def detect_modules(self):
         # time operations and variables
         exts.append( Extension('time', ['timemodule.c'],
                                libraries=time_libs) )
-        # math_libs is needed by delta_new() that uses round() and by accum()
-        # that uses modf().
+        # libm is needed by delta_new() that uses round() and by accum() that
+        # uses modf().
         exts.append( Extension('_datetime', ['_datetimemodule.c'],
-                               libraries=math_libs) )
+                               libraries=['m']) )
         # random number generator implemented in C
         exts.append( Extension("_random", ["_randommodule.c"]) )
         # bisect
@@ -732,9 +723,9 @@ def detect_modules(self):
         # According to #993173, this one should actually work fine on
         # 64-bit platforms.
         #
-        # audioop needs math_libs for floor() in multiple functions.
+        # audioop needs libm for floor() in multiple functions.
         exts.append( Extension('audioop', ['audioop.c'],
-                               libraries=math_libs) )
+                               libraries=['m']) )
 
         # readline
         do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
@@ -1972,7 +1963,6 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
                    '_ctypes/stgdict.c',
                    '_ctypes/cfield.c']
         depends = ['_ctypes/ctypes.h']
-        math_libs = self.detect_math_libs()
 
         if host_platform == 'darwin':
             sources.append('_ctypes/malloc_closure.c')
@@ -2003,10 +1993,10 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
                         libraries=[],
                         sources=sources,
                         depends=depends)
-        # function my_sqrt() needs math library for sqrt()
+        # function my_sqrt() needs libm for sqrt()
         ext_test = Extension('_ctypes_test',
                      sources=['_ctypes/_ctypes_test.c'],
-                     libraries=math_libs)
+                     libraries=['m'])
         self.extensions.extend([ext, ext_test])
 
         if host_platform == 'darwin':
@@ -2050,7 +2040,6 @@ def _decimal_ext(self):
                                                          'Modules',
                                                          '_decimal',
                                                          'libmpdec'))]
-            libraries = self.detect_math_libs()
             sources = [
               '_decimal/_decimal.c',
               '_decimal/libmpdec/basearith.c',
@@ -2146,7 +2135,7 @@ def _decimal_ext(self):
         ext = Extension (
             '_decimal',
             include_dirs=include_dirs,
-            libraries=libraries,
+            libraries=['m'],
             define_macros=define_macros,
             undef_macros=undef_macros,
             extra_compile_args=extra_compile_args,



More information about the Python-checkins mailing list