-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsetup.py
More file actions
66 lines (53 loc) · 1.52 KB
/
setup.py
File metadata and controls
66 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
63
64
65
66
#!/usr/bin/env python
import platform
import cpuinfo
import numpy
import simde_py
from setuptools import Extension, setup
NOOP = "-Wabi"
def is_macos() -> bool:
return platform.system() == "Darwin"
def is_x86_64() -> bool:
return platform.machine() == "x86_64"
def is_arm64() -> bool:
return platform.machine() == "arm64"
def has_avx2() -> bool:
if not is_x86_64():
return False
info = cpuinfo.get_cpu_info()
flags = info.get("flags", [])
return "avx2" in flags
setup(
ext_modules=[
Extension(
"qseek.ext.array_tools",
sources=["src/qseek/ext/array_tools.c"],
include_dirs=[numpy.get_include()],
extra_compile_args=[
"-Xpreprocessor" if is_macos() else NOOP,
"-fopenmp",
"-O3",
"-flto",
],
extra_link_args=[
"-lomp" if is_macos() else "-lgomp",
],
),
Extension(
"qseek.ext.delay_sum",
sources=["src/qseek/ext/delay_sum.c"],
include_dirs=[numpy.get_include(), simde_py.get_include()],
extra_compile_args=[
"-Xpreprocessor" if is_macos() else NOOP,
"-fopenmp",
"-O3",
"-flto",
"-mfma" if is_x86_64() else NOOP,
"-mavx2" if has_avx2() else NOOP,
],
extra_link_args=[
"-lomp" if is_macos() else "-lgomp",
],
),
]
)