-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
58 lines (49 loc) · 1.23 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Setup script for package installation."""
import os
from pathlib import Path
import numpy as np
import pybind11
from setuptools import Extension, setup
include_dirs = [
pybind11.get_include(),
np.get_include(),
]
# If C++ parser should be added, do: export MEPYLOME_CPP=1
add_cpp = os.getenv("MEPYLOME_CPP") == "1"
# If debug compiler flags should be used, do: export MEPYLOME_DEBUG=1
debug = os.getenv("MEPYLOME_DEBUG") == "1"
# Set the compiler flags based on the debug flag
if debug:
print("\n*** Debugging compiler flags are used. ***\n")
compile_args = [
"-O0",
"-Wall",
"-Wextra",
"-fno-stack-protector",
"-g",
"-pg",
]
else:
compile_args = [
"-O3",
"-march=native",
]
sources = list(map(str, Path("pybindings").glob("*.cpp"))) + list(
map(str, Path("src").glob("*.cpp"))
)
cpp_extension = Extension(
name="_mepylome",
sources=sources,
include_dirs=include_dirs,
extra_compile_args=compile_args,
extra_link_args=["-fopenmp"],
language="c++",
)
if add_cpp:
ext_modules = [cpp_extension] if add_cpp else []
print("\n*** Adding cpp extension. ***\n")
else:
ext_modules = []
setup(
ext_modules=ext_modules,
)