支持 macOS 下使用 OpenCTP dylib 构建#14
Open
Yong-yuan-X wants to merge 1 commit into
Open
Conversation
Member
|
不好意思 没有看到此 问下你这个在三个系统下是否都能构建成功 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 issue: ctpbee/ctpbee#325
我在 macOS 本地复现了一下,当前
ctpbee_api在 macOS 下编译生成的vnctpmd/vnctptd默认链接到~/.ctpbee/Frameworks下的 framework:因此,即使把 OpenCTP 的
.dylib文件复制到ctpbee_api/ctp目录,现有构建产物也不会加载这些 dylib。本 PR 增加了一个可选环境变量:
当该环境变量存在时,macOS 构建会使用该目录下的 OpenCTP dylib,并将 dylib 复制到
ctpbee_api/ctp包目录中,保证运行时可以通过@loader_path正确加载。目前兼容以下文件名:如果没有设置
CTPBEE_CTP_DYLIB_DIR,则保持原有 framework 构建逻辑不变。我使用 PyPI 上的
openctp-ctpwheel 解压出的 dylib 进行了验证:CTPBEE_CTP_DYLIB_DIR=/Users/a1-6/Downloads/openctp-wheel/unpacked/openctp_ctp \ python -m pip install -e .安装后执行:
python -c "from ctpbee_api.ctp import MdApi, TdApi; print(MdApi, TdApi)"可以正常导入:
otool -L输出变为:说明构建产物已经从 framework 链接切换到 OpenCTP dylib。