-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsetup.py
58 lines (50 loc) · 1.37 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
#!/usr/bin/env python3
import os
from setuptools import (
setup,
Extension
)
import numpy as np
BUILDING_EXT = os.environ.get('STOCK_PANDAS_BUILDING_EXT')
ext_kwargs = dict(
# Ignore warning caused by cpython for using deprecated apis
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
include_dirs=[np.get_include()]
)
# Distribution ref
# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
if BUILDING_EXT:
from Cython.Build import cythonize
extensions = cythonize(
Extension(
'stock_pandas.math._lib',
['stock_pandas/math/_lib.pyx'],
language='c++',
**ext_kwargs
),
compiler_directives={
'linetrace': False,
'language_level': 3
}
)
# When packaging the package, use the pre-compiled c++ file
else:
extensions = [
Extension(
'stock_pandas.math._lib',
['stock_pandas/math/_lib.cpp'],
**ext_kwargs
)
]
# Only run setup when building the package
if __name__ == '__main__':
setup(
ext_modules=extensions,
packages=[
'stock_pandas',
'stock_pandas.commands',
'stock_pandas.directive',
'stock_pandas.math',
'stock_pandas.meta'
]
)