-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
68 lines (59 loc) · 2.03 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
63
64
65
66
67
68
import platform
from setuptools import Extension, setup
def get_ext_modules() -> list:
"""
获取三方模块
Linux、Windows需要编译封装接口
Mac由于缺乏二进制库支持无法使用
"""
# Linux
if platform.system() == "Linux":
library_dirs = ["vnpy_ctp/api"]
extra_compile_flags = [
"-std=c++17",
"-O3",
"-Wno-delete-incomplete",
"-Wno-sign-compare",
]
extra_link_args = ["-lstdc++"]
runtime_library_dirs = ["$ORIGIN"]
# Windows
elif platform.system() == "Windows":
library_dirs = ["vnpy_ctp/api/libs", "vnpy_ctp/api"]
extra_compile_flags = [
"/MP", "/std:c++17", # standard
"/O2", "/Ob2", "/Oi", "/Ot", "/Oy", "/GL", # Optimization
"/D_CRT_SECURE_NO_WARNINGS",
# suppress warning of unsafe functions like fopen, strcpy, etc
"/D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING"
]
extra_link_args = []
runtime_library_dirs = []
else:
return []
include_dirs = ["vnpy_ctp/api/include", "vnpy_ctp/api/vnctp"]
libraries = ["thostmduserapi_se", "thosttraderapi_se"]
vnctpmd = Extension(
name="vnpy_ctp.api.vnctpmd",
sources=["vnpy_ctp/api/vnctp/vnctpmd/vnctpmd.cpp"],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
language="cpp",
)
vnctptd = Extension(
name="vnpy_ctp.api.vnctptd",
sources=["vnpy_ctp/api/vnctp/vnctptd/vnctptd.cpp"],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
language="cpp",
)
return [vnctptd, vnctpmd]
setup(ext_modules=get_ext_modules())