-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
58 lines (48 loc) · 1.56 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 python
# -*- coding: utf-8 -*-
# @Time : 2019/12/9 15:44
# @Author : NingAnMe <[email protected]>
# python setup.py build_ext --inplace
import os
from distutils.core import setup, Extension
from Cython.Build import cythonize
exclude_keyword = ['init']
def check_keyword(name, keyword):
for key in keyword:
if key in name:
return True
return False
def get_extensions(ipath):
"""
ipath 输入目录
extensions 编译成.so的文件列表(元素是Extension对象)
copys 拷贝的文件列表
initpys __init__.py的文件列表
"""
extensions = []
for each in os.listdir(ipath):
if check_keyword(each, exclude_keyword):
continue
elif os.path.splitext(each)[1] == ".py":
pkg = os.path.splitext(each)[0]
mod = os.path.join(ipath, each)
# mod = each
extensions.append(Extension(pkg, [mod]))
elif os.path.splitext(each)[1] == ".pyc":
continue
return extensions
requires = ['numpy', 'sqlalchemy', 'scipy', 'h5py',
'PyYAML', 'gdal', 'pyproj', 'matplotlib',
'flask_restful']
setup(
ext_modules=cythonize(get_extensions('lib'),
build_dir=os.path.join("build/tmp"))
)
os.system("mv lib lib.bak")
os.system("cp -rf build/lib.linux-x86_64-3.7 lib")
os.system("cp -rf lib.bak/*.mplstyle lib")
os.system("rm -rf lib/*cimiss*")
os.system("cp -rf lib.bak/lib_cimiss.py lib")
os.system("touch lib/__init__.py")
os.system("rm -rf lib.bak")
print("success")