Skip to content

Commit 8acaa31

Browse files
authored
remove detect_math_libs (#4383)
Darwin may not require libm, but it doesn't hurt to link it and simplifies configuration logic.
1 parent d7d4fea commit 8acaa31

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

setup.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,6 @@ def add_gcc_paths(self):
501501
finally:
502502
os.unlink(tmpfile)
503503

504-
def detect_math_libs(self):
505-
# Check for MacOS X, which doesn't need libm.a at all
506-
if host_platform == 'darwin':
507-
return []
508-
else:
509-
return ['m']
510-
511504
def detect_modules(self):
512505
# Ensure that /usr/local is always used, but the local build
513506
# directories (i.e. '.' and 'Include') must be first. See issue
@@ -613,8 +606,6 @@ def detect_modules(self):
613606
if item.startswith('-L'):
614607
lib_dirs.append(item[2:])
615608

616-
math_libs = self.detect_math_libs()
617-
618609
#
619610
# The following modules are all pretty straightforward, and compile
620611
# on pretty much any POSIXish platform.
@@ -628,12 +619,12 @@ def detect_modules(self):
628619
exts.append( Extension('cmath', ['cmathmodule.c'],
629620
extra_objects=[shared_math],
630621
depends=['_math.h', shared_math],
631-
libraries=math_libs) )
622+
libraries=['m']) )
632623
# math library functions, e.g. sin()
633624
exts.append( Extension('math', ['mathmodule.c'],
634625
extra_objects=[shared_math],
635626
depends=['_math.h', shared_math],
636-
libraries=math_libs) )
627+
libraries=['m']) )
637628

638629
# time libraries: librt may be needed for clock_gettime()
639630
time_libs = []
@@ -644,10 +635,10 @@ def detect_modules(self):
644635
# time operations and variables
645636
exts.append( Extension('time', ['timemodule.c'],
646637
libraries=time_libs) )
647-
# math_libs is needed by delta_new() that uses round() and by accum()
648-
# that uses modf().
638+
# libm is needed by delta_new() that uses round() and by accum() that
639+
# uses modf().
649640
exts.append( Extension('_datetime', ['_datetimemodule.c'],
650-
libraries=math_libs) )
641+
libraries=['m']) )
651642
# random number generator implemented in C
652643
exts.append( Extension("_random", ["_randommodule.c"]) )
653644
# bisect
@@ -732,9 +723,9 @@ def detect_modules(self):
732723
# According to #993173, this one should actually work fine on
733724
# 64-bit platforms.
734725
#
735-
# audioop needs math_libs for floor() in multiple functions.
726+
# audioop needs libm for floor() in multiple functions.
736727
exts.append( Extension('audioop', ['audioop.c'],
737-
libraries=math_libs) )
728+
libraries=['m']) )
738729

739730
# readline
740731
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
@@ -1972,7 +1963,6 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
19721963
'_ctypes/stgdict.c',
19731964
'_ctypes/cfield.c']
19741965
depends = ['_ctypes/ctypes.h']
1975-
math_libs = self.detect_math_libs()
19761966

19771967
if host_platform == 'darwin':
19781968
sources.append('_ctypes/malloc_closure.c')
@@ -2003,10 +1993,10 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
20031993
libraries=[],
20041994
sources=sources,
20051995
depends=depends)
2006-
# function my_sqrt() needs math library for sqrt()
1996+
# function my_sqrt() needs libm for sqrt()
20071997
ext_test = Extension('_ctypes_test',
20081998
sources=['_ctypes/_ctypes_test.c'],
2009-
libraries=math_libs)
1999+
libraries=['m'])
20102000
self.extensions.extend([ext, ext_test])
20112001

20122002
if host_platform == 'darwin':
@@ -2050,7 +2040,6 @@ def _decimal_ext(self):
20502040
'Modules',
20512041
'_decimal',
20522042
'libmpdec'))]
2053-
libraries = self.detect_math_libs()
20542043
sources = [
20552044
'_decimal/_decimal.c',
20562045
'_decimal/libmpdec/basearith.c',
@@ -2146,7 +2135,7 @@ def _decimal_ext(self):
21462135
ext = Extension (
21472136
'_decimal',
21482137
include_dirs=include_dirs,
2149-
libraries=libraries,
2138+
libraries=['m'],
21502139
define_macros=define_macros,
21512140
undef_macros=undef_macros,
21522141
extra_compile_args=extra_compile_args,

0 commit comments

Comments
 (0)