Skip to content

Commit

Permalink
Merge pull request #3 from Edanflame/main
Browse files Browse the repository at this point in the history
[Mod] 调整安装脚本setup.py,支持Windows下安装时根据Python版本进行编译
  • Loading branch information
vnpy committed Feb 21, 2022
2 parents 3a820a1 + bad5c8f commit e31e34d
Show file tree
Hide file tree
Showing 6 changed files with 1,622 additions and 1,556 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 1.0.0版本

1. 调整安装脚本setup.py,支持Windows下安装时根据Python版本进行编译
2. 调整接口初始化时,接口名称的赋值方式
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p align="center">
<img src ="https://img.shields.io/badge/version-1.0.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.7-blue.svg" />
<img src ="https://img.shields.io/badge/python-3.7|3.8|3.9|3.10-blue.svg" />
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>

Expand All @@ -20,7 +20,7 @@

## 安装

安装需要基于2.9.0版本以上的[VN Studio](https://www.vnpy.com)
安装需要基于3.0.0版本以上的[VN Studio](https://www.vnpy.com)

直接使用pip命令:

Expand All @@ -31,9 +31,11 @@ pip install vnpy_hts
或者下载解压后在cmd中运行:

```
python setup.py install
pip install -e .
```

由于在安装的同时需要编译C++代码,因此在执行上述命令之前需要去微软[官网](https://my.visualstudio.com/Downloads?q=build%20tools)下载Visual Studio Build Tools。其中工作负荷选择Visual C++生成工具,同时推荐下载2017版。

## 使用

以脚本方式启动(script/run.py):
Expand Down Expand Up @@ -63,6 +65,7 @@ def main():
if __name__ == "__main__":
main()
```

## 连接

连接时请注意,请勿选择用户目录作为VN Trader的运行目录,否则会导致程序异常退出(已知为HTS行情API的问题)。
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ classifiers =
Operating System :: Microsoft :: Windows
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Office/Business :: Financial :: Investment
Programming Language :: Python :: Implementation :: CPython
License :: OSI Approved :: MIT License
Expand All @@ -32,4 +35,4 @@ install_requires =
importlib_metadata

[options.package_data]
* = *.dll, *.pyd
* = *.dll, *.pyd
58 changes: 56 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,58 @@
from setuptools import setup
from setuptools import Extension, setup


setup()
def get_ext_modules() -> list:
"""
获取三方模块
Windows需要编译封装接口
Linux和Mac由于缺乏二进制库支持无法使用
"""
extra_compile_flags = ["-O2", "-MT"]
extra_link_args = []
runtime_library_dirs = []

vnhtsmd = Extension(
"vnpy_hts.api.vnhtsmd",
[
"vnpy_hts/api/vnhts/vnhtsmd/vnhtsmd.cpp",
],
include_dirs=["vnpy_hts/api/include",
"vnpy_hts/api/include/hts",
"vnpy_hts/api/vnhts"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_hts/api/libs", "vnpy_hts/api"],
libraries=["DFITCSECMdApi", "DFITCSECTraderApi", "HsFutuSystemInfo", "InformationCollect"],
extra_compile_args=extra_compile_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)

vnhtstd = Extension(
"vnpy_hts.api.vnhtstd",
[
"vnpy_hts/api/vnhts/vnhtstd/vnhtstd.cpp",
],
include_dirs=["vnpy_hts/api/include",
"vnpy_hts/api/include/hts",
"vnpy_hts/api/vnhts"],
define_macros=[],
undef_macros=[],
library_dirs=["vnpy_hts/api/libs", "vnpy_hts/api"],
libraries=["DFITCSECMdApi", "DFITCSECTraderApi", "HsFutuSystemInfo", "InformationCollect"],
extra_compile_args=extra_compile_flags,
extra_link_args=extra_link_args,
runtime_library_dirs=runtime_library_dirs,
depends=[],
language="cpp",
)

return [vnhtstd, vnhtsmd]


setup(
ext_modules=get_ext_modules(),
)

0 comments on commit e31e34d

Please sign in to comment.