Merged
[feat]: package hixl Python binding as wheel with __init__.py and platform-tagged .so #903
[feat]: package hixl Python binding as wheel with __init__.py and platform-tagged .so #903
Merged
zhaozhihuiAdd on Aug 15
zhaozhihui
zhaozhihuiCollaborators
Aug 15

提交 PR 前,请先阅读 HIXL贡献指南 ,查看 PR 提交方式并遵守相关提交规范。

类型标签

描述

当前 hixl Python binding 以裸 .so 文件形式安装,没有 __init__.py,不支持 Python 层扩展,且 .so 文件名不包含平台和 Python 版本信息。

本次改动将 hixl Python binding 打包为标准 wheel 包,安装到 site-packages/hixl/ 子目录下,包含:

  • hixl/__init__.py:显式导出所有 C 扩展符号(__all__ 列出 40+ 符号),支持后续添加 Python 层接口
  • setup.py:wheel 打包配置,bdist_wheel 设置 root_is_pure=False 生成平台标签
  • MANIFEST.in:包含 .so 文件

用户 import hixl 的使用方式完全不变(向后兼容)。

测试项

  • Python 单元测试:HixlModuleImportTest、HixlDataClassesTest、HixlCapabilityTest 共 15 个用例全部通过
  • import hixl 向后兼容验证:hixl.SUCCESS、hixl.Hixl()、hixl.MemType 等符号均可正常访问

测试结果

测试项 结果
Release 构建 wheel 通过
Python UT (15 cases) 全部通过
import hixl 兼容性 通过

Checklist

其它(可选)

改动文件清单

文件 改动说明
src/python/hixl_py/hixl/__init__.py 新建,显式导出所有 C 扩展符号
src/python/hixl_py/setup.py 新建,wheel 打包配置
src/python/hixl_py/MANIFEST.in 新建,包含 .so 文件
src/python/hixl_py/CMakeLists.txt EXT_SUFFIX 命名 + wheel target + install wheel
tests/depends/python/CMakeLists.txt stub 使用 EXT_SUFFIX
tests/run_test.sh .so 拷贝到 hixl/ 子目录
scripts/package/hixl/scripts/hixl_custom_install.sh pip install hixl wheel
scripts/package/hixl/rpm_deb/custom_postinst.sh pip install hixl wheel
scripts/package/hixl/rpm_deb/custom_prerm.sh pip uninstall hixl
scripts/package/hixl/scripts/hixl_custom_uninstall.sh 参数化 whl_uninstall_package
scripts/package/hixl/scripts/hixl_custom_create_softlink.sh 软链接改为 hixl + dist-info
scripts/package/hixl/scripts/hixl_custom_remove_softlink.sh 移除软链接改为 hixl + dist-info
scripts/package/hixl/scripts/install.sh 添加 hixl 包 chmod
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for zhaozhihui's contribution.)
zhaozhihuizhaozhihuiCollaborators
Aug 15 Created pull request, commit db86aae9
atomgit-bot
atomgit-bot
Aug 15 Comments:

变更摘要

本 PR 将 hixl Python binding 的交付形态从裸 .so 文件改为标准 wheel 包:新增 hixl/__init__.py、setup.py 与 MANIFEST.in,使 C 扩展以 hixl.cpython-3XX-arch.so 形式打包并安装到 site-packages/hixl/ 子目录,同时保留 import hixl 的向后兼容用法。安装/卸载、软链接与权限相关脚本同步从直接拷贝 hixl.so 切换为通过 pip 管理 hixl wheel 及 dist-info;构建脚本 CMakeLists.txt 也相应调整了 EXT_SUFFIX 命名、wheel target 与安装逻辑。

主要改动

  • Python 包结构与导出接口:新增 src/python/hixl_py/hixl/__init__.py,从 hixl.hixl 显式导入并导出全部 C 扩展符号,通过 __all__ 声明 40+ 个常量、类型与函数,为后续 Python 层扩展提供入口。
  • Wheel 打包配置:新增 src/python/hixl_py/setup.py,自定义 bdist_wheel 设置 root_is_pure=False 并重写 get_tag 生成平台与 Python 版本标签,同时用 BuildPyCommand 清理旧 wheel;新增 MANIFEST.in 使用 recursive-include hixl *.so 打包扩展。
  • 安装逻辑切换为 pip 安装 wheel:custom_postinst.sh 与 hixl_custom_install.sh 不再复制 hixl.so 并创建软链接,改为查找 hixl-*.whl 后通过 run_pip install / hixl_install_package 安装到目标目录。
  • 卸载与软链接逻辑适配 wheel 结构:custom_prerm.sh、hixl_custom_uninstall.sh 将卸载对象从 hixl.so 改为 hixl 包及 hixl-*.dist-info,并参数化 whl_uninstall_package 的包名;创建/移除软链接脚本同步改为处理 hixl 与 hixl-*.dist-info。
  • 权限与测试路径调整:install.sh 新增对 hixl 目录及其 dist-info 的 chmod_recur 处理;tests/run_test.sh 将测试 .so 拷贝目标从 hixl_py/ 根目录改为 hixl_py/hixl/ 子目录。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 15 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 15 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 15 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/hixl ✅ zhujingjing, lining23666 (2/2) ✅ zhujingjing (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

zhaozhihui, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
111 messages are collapsed here。 See more
zhujingjing
zhujingjingCollaborators
Aug 17 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 17 Added label: lgtmapproved
CANN-robot
CANN-robotCollaborators
Aug 17 Comments:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
zhaozhihuizhaozhihuiCollaborators
Aug 17 Resolved final issue
CANN-robotCANN-robotCollaborators
Aug 17 Merged pull request