forked from vnpy/vnpy_ctp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
107 lines (94 loc) · 3.13 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
""""""
import ast
import platform
import re
from setuptools import Extension, find_packages, setup
def get_version_string() -> str:
"""获取版本号"""
with open("vnpy_ctp/__init__.py", "rb") as f:
content = f.read().decode("utf-8")
version_line = re.search(r"__version__\s+=\s+(.*)", content).group(1)
return str(ast.literal_eval(version_line))
def get_ext_modules() -> list:
"""
获取三方模块
Linux需要编译封装接口
Windows直接使用预编译的pyd即可
Mac由于缺乏二进制库支持无法使用
"""
if platform.system != "Linux":
return []
compiler_flags = [
"-std=c++17", # standard
"-O3", # Optimization
"-Wno-delete-incomplete", "-Wno-sign-compare",
]
extra_link_args = ["-lstdc++"]
runtime_library_dirs = ["$ORIGIN"]
vnctpmd = Extension(
"vnpy_ctp.api.vnctpmd",
[
"vnpy_ctp/api/vnctp/vnctpmd/vnctpmd.cpp",
],
include_dirs=["vnpy_ctp/api/include",
"vnpy_ctp/api/vnctp"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_ctp/api/libs", "vnpy_ctp/api"],
libraries=["thostmduserapi_se", "thosttraderapi_se"],
extra_compile_args=compiler_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)
vnctptd = Extension(
"vnpy_ctp.api.vnctptd",
[
"vnpy_ctp/api/vnctp/vnctptd/vnctptd.cpp",
],
include_dirs=["vnpy_ctp/api/include",
"vnpy_ctp/api/vnctp"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_ctp/api/libs", "vnpy_ctp/api"],
libraries=["thostmduserapi_se", "thosttraderapi_se"],
extra_compile_args=compiler_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)
return [vnctptd, vnctpmd]
setup(
name="vnpy",
version=get_version_string(),
author="vn.py team",
author_email="[email protected]",
license="MIT",
url="https://www.vnpy.com",
description="A framework for developing quant trading systems.",
long_description=__doc__,
keywords='quant quantitative investment trading algotrading',
include_package_data=True,
packages=find_packages(),
package_data={"": [
"*.dll",
"*.so",
"*.pyd",
]},
install_requires=["vnpy"],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Operating System :: Microsoft :: Windows :: Windows 10",
"Operating System :: Microsoft :: Windows :: Windows Server 2019",
"Operating System :: POSIX :: Linux"
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Topic :: Office/Business :: Financial :: Investment",
"Programming Language :: Python :: Implementation :: CPython",
"License :: OSI Approved :: MIT License",
"Natural Language :: Chinese (Simplified)"
],
ext_modules=get_ext_modules(),
)