-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
41 lines (33 loc) · 1.15 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import platform
import glob
from distutils.core import setup
from Cython.Build import cythonize
from setuptools import Extension
def set_gcc():
"""
Try to find and use GCC on OSX for OpenMP support, setting the CC
environment variable accordingly.
"""
# For macports and homebrew
patterns = ['/opt/local/bin/gcc-mp-[0-9].[0-9]',
'/opt/local/bin/gcc-mp-[0-9]',
'/usr/local/bin/gcc-[0-9].[0-9]',
'/usr/local/bin/gcc-[0-9]']
gcc_binaries = []
for pattern in patterns:
gcc_binaries += glob.glob(pattern)
gcc_binaries.sort()
if gcc_binaries:
_, gcc = os.path.split(gcc_binaries[-1])
os.environ["CC"] = gcc
else:
raise Exception('No GCC available. Install gcc from Homebrew '
'using brew install gcc.')
if 'darwin' in platform.platform().lower():
set_gcc()
args = {'extra_compile_args': ['-fopenmp', '-ffast-math', '-O3'],
'extra_link_args': ['-fopenmp']}
extensions = [Extension('prng', ['prng.pyx'], **args),
Extension('fm', ['fm.pyx'], **args)]
setup(ext_modules=cythonize(extensions))