Skip to content

Commit

Permalink
Fix compiler options when building Python extension on Mac OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
hongquan authored and dm8tbr committed Aug 8, 2021
1 parent 1235598 commit c30a1d9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

def get_libsnowboy_folder():
if sys.platform == 'darwin':
return 'lib/osx/libsnowboy-detect.a'
uname = os.uname()
machine = uname.machine
return 'lib/osx'
machine = os.uname().machine
folder = ''
if machine.startswith('arm'):
folder = 'rpi'
Expand All @@ -27,14 +26,12 @@ def get_libsnowboy_folder():
return os.path.join('lib', folder)


swig_opts=['-c++']
cxx_flags = ['-O3', '-D_GLIBCXX_USE_CXX11_ABI=0']
libraries = ['m', 'dl', 'snowboy-detect']
link_args = []

if sys.platform == 'darwin':
swig_opts.extend(['-bundle', '-flat_namespace', '-undefined', 'suppress'])
link_args = ['-framework Accelerate']
link_args = ['-framework', 'Accelerate', '-bundle', '-flat_namespace', '-undefined', 'suppress']
else:
cxx_flags.append('-std=c++0x')
libraries.extend(['f77blas', 'cblas', 'atlas'])
Expand All @@ -48,7 +45,7 @@ def get_libsnowboy_folder():
Extension(
'_snowboydetect',
['swig/{}/snowboy-detect-swig.i'.format(PY_DIR)],
swig_opts=swig_opts,
swig_opts=['-c++'],
include_dirs=['.'],
libraries=libraries,
extra_compile_args=cxx_flags,
Expand Down

0 comments on commit c30a1d9

Please sign in to comment.