-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.py
More file actions
61 lines (51 loc) · 2.06 KB
/
Copy pathsetup.py
File metadata and controls
61 lines (51 loc) · 2.06 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
import os
import sys
from Cython.Build import cythonize
from setuptools import Extension, find_packages, setup
def module_name(dirpath, filename):
l = [os.path.splitext(filename)[0]]
head = dirpath
while True:
head, tail = os.path.split(head)
l.append(tail)
if not head:
break
return '.'.join(reversed(l))
def get_extensions():
#from numpy.distutils.misc_util import get_numpy_include_dirs
#from pathlib import Path
extensions = [
# Extension('waveforms.sys.net._kcp', ['src/kcp.c', 'src/ikcp.c'],
# include_dirs=['src']),
# Extension(
# 'waveforms.math.npufunc',
# ['src/multi_type_logit.c'],
# include_dirs=get_numpy_include_dirs(),
# library_dirs=[str(Path(p).parent / 'lib') for p in get_numpy_include_dirs()],
# libraries=["npymath"],
# # extra_compile_args=['-std=c99'],
# )
]
for dirpath, dirnames, filenames in os.walk('waveforms'):
for filename in filenames:
if filename.endswith('.pyx'):
sources = [os.path.join(dirpath, filename)]
include_dirs = []
extra_link_args = []
libraries = []
if filename == '_waveform.pyx':
sources.append(os.path.join(
'waveforms', '_cwaveform.c'))
include_dirs.append('waveforms')
if sys.platform == 'darwin':
extra_link_args.extend(['-framework', 'Accelerate'])
elif sys.platform.startswith('linux'):
libraries.append('m')
extensions.append(
Extension(module_name(dirpath, filename), sources,
include_dirs=include_dirs,
libraries=libraries,
extra_link_args=extra_link_args))
return extensions
setup(packages=find_packages(),
ext_modules=cythonize(get_extensions(), build_dir=f"build"))