-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
62 lines (52 loc) · 1.47 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
59
60
61
62
import sys
import os
from setuptools import setup, find_packages
from Cython.Build import cythonize
from Cython.Build.Dependencies import default_create_extension
try:
import numpy
except ImportError:
numpy = None
if numpy is None:
INCLUDE_PATH = []
else:
INCLUDE_PATH = [numpy.get_include()]
LIB_PATH = []
def build_pa_lib():
from tools import build_portaudio
lib_base = build_portaudio.main()
INCLUDE_PATH.append(str(lib_base / 'include'))
LIB_PATH.append(str(lib_base / 'lib'))
RTFD_BUILD = 'READTHEDOCS' in os.environ.keys()
if RTFD_BUILD:
build_pa_lib()
print('INCLUDE_PATH: ', INCLUDE_PATH)
USE_CYTHON_TRACE = False
if '--use-cython-trace' in sys.argv:
USE_CYTHON_TRACE = True
sys.argv.remove('--use-cython-trace')
def my_create_extension(template, kwds):
name = kwds['name']
if RTFD_BUILD:
kwds['library_dirs'] = LIB_PATH
kwds['include_dirs'] = INCLUDE_PATH
kwds['runtime_library_dirs'] = LIB_PATH
print(kwds)
if USE_CYTHON_TRACE:
kwds['define_macros'] = [('CYTHON_TRACE_NOGIL', '1'), ('CYTHON_TRACE', '1')]
return default_create_extension(template, kwds)
ext_modules = cythonize(
['cysounddevice/**/*.pyx'],
include_path=INCLUDE_PATH,
annotate=True,
# gdb_debug=True,
compiler_directives={
'linetrace':True,
'embedsignature':True,
'binding':True,
},
create_extension=my_create_extension,
)
setup(
ext_modules=ext_modules,
)