This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
53 lines (47 loc) · 1.51 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
from __future__ import absolute_import, print_function
import os
import sys
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
# For demo purposes, we build our own tiny library.
try:
print("building libmymath.a")
assert os.system("gcc -shared -fPIC -c mymath.c -o mymath.o") == 0
assert os.system("ar rcs libmymath.a mymath.o") == 0
except:
if not os.path.exists("libmymath.a"):
print("Error building external library, please create libmymath.a manually.")
sys.exit(1)
# Here is how to use the library built above.
ext_modules = cythonize([
Extension(
"call_mymath.call_mymath",
sources=["src/call_mymath/call_mymath.pyx"],
include_dirs=[os.getcwd()], # path to .h file(s)
library_dirs=[os.getcwd()], # path to .a or .so file(s)
libraries=['mymath'],
extra_compile_args=['-DCYTHON_TRACE=1']
),
Extension(
"call_mymath.flat_ns_call_mymath",
sources=["src/flat_ns_call_mymath.pyx"],
include_dirs=[os.getcwd()], # path to .h file(s)
library_dirs=[os.getcwd()], # path to .a or .so file(s)
libraries=['mymath'],
extra_compile_args=['-DCYTHON_TRACE=1']
),
],
compiler_directives={
'embedsignature': True,
'emit_code_comments': True,
'linetrace': True,
'profile': True,
},
)
setup(
name='Demos',
ext_modules=ext_modules,
package_dir={'': 'src'},
packages=['call_mymath'],
)