forked from ludopulles/BLASter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
62 lines (53 loc) · 1.52 KB
/
setup.py
File metadata and controls
62 lines (53 loc) · 1.52 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from pathlib import Path
from sys import argv, platform
from setuptools import Extension, setup
from Cython.Build import cythonize
import numpy as np
# Make sure OpenMP is used in Cython and Eigen.
openmp_arg = '/openmp' if platform.startswith("win") else '-fopenmp'
include_dirs = [np.get_include()]
# Look for the Eigen library in `/usr/include` and `~/.local/include`.
for f in [Path('eigen3'), Path('/usr/include/eigen3'), Path.home().joinpath('.local/include/eigen3')]:
if f.exists() and f.is_dir():
include_dirs += [str(f)]
break
else:
print("ERROR: Eigen3 library is required!")
print("NOTE : Please run 'make eigen3'")
exit(1)
# Compile with extra arguments
compile_args = [
'--std=c++17',
'-DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION',
openmp_arg,
]
# Link with extra arguments
link_args = [openmp_arg]
if '--cython-gdb' in argv:
# Debug arguments
debug_args = [
'-O1',
'-fsanitize=address,undefined',
'-g',
'-fno-omit-frame-pointer',
]
compile_args += debug_args
link_args += debug_args
else:
# "Release" arguments
compile_args += [
'-O3',
'-march=native',
'-DEIGEN_NO_DEBUG',
]
extensions = [Extension(
name="blaster_core",
sources=["core/blaster.pyx"],
include_dirs=include_dirs,
extra_compile_args=compile_args,
extra_link_args=link_args
)]
setup(
ext_modules=cythonize(extensions, language_level="3", build_dir='build/cpp'),
options={'build': {'build_lib': 'src/'}},
)