Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: 调整 Python Binding 初始化行为 #443

Closed
weinibuliu opened this issue Dec 3, 2024 · 0 comments · Fixed by #445
Closed

perf: 调整 Python Binding 初始化行为 #443

weinibuliu opened this issue Dec 3, 2024 · 0 comments · Fixed by #445

Comments

@weinibuliu
Copy link
Contributor

weinibuliu commented Dec 3, 2024

尝试对 Python Binding 做了一些改进,详见 PR #445

该 PR 主要做了以下调整:

  • 新增从环境变量中读取 MAAFW_BINARY_PATH (Maafw DLL 路径)的功能。

  • 调整包的初始化行为:

    • 初始化时首先检查环境变量中是否存在 MAAFW_BINARY_PATH ,如存在且 bool != False,则将值传入 library.open() ;否则,将 {Python 安装目录}/Lib/site-packages/maa/bin 传入 library.open()
    • Library 初始化失败时,抛出错误,错误来源为 maa/library.py
  • 移除 Library.initialized 变量,包含以下文件的改动:
    library.py buffer.py controller.py resource.py tasker.py toolkit.py

  • 初始化时不再 print maafw 版本,同时移除了 ver 变量。如有需求,请自行调用 maa.Library.version() 获取。

  • 同步修改了 binding_test.pytest.yml 中文件路径的逻辑

  • 移除 library.py 多余代码,调整部分方法参数类型说明 f671a5e

这会带来如下改进:

  • 完善 dll 路径处理的逻辑与报错
  • Library 初始化失败时,抛出错误,错误来源为 maa/library.py
@MistEO MistEO linked a pull request Dec 4, 2024 that will close this issue
@weinibuliu weinibuliu changed the title chore: Python Binding 的改进想法 perf: 调整 Python Binding 初始化行为 Dec 4, 2024
MistEO added a commit that referenced this issue Dec 4, 2024
改动详情见 #443
讨论历史见 #444

---------

Co-authored-by: MistEO <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant