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

调整关于Python查找相关的逻辑, 兼容 manylinux, 方便 Python 相关的 CI #5391

Open
myuanz opened this issue Oct 1, 2024 · 3 comments

Comments

@myuanz
Copy link
Contributor

myuanz commented Oct 1, 2024

你在什么场景下需要该功能?

Python whl 在 Linux 的标准打包环境是 manylinux, manylinux 故意不提供 libpython.so 和 libpython.a 以便打包出可轻松移植的 whl 1. 但是在 xmake 的 Python fetch中, 即使设置了 headeronly, 也会尝试查找链接文件, 导致无法正确在 manylinux 下找到 Python. 因此需要调整此逻辑.

同时, Python 的 C 扩展通常是通过 pybind11 完成的, 因此也要同时调整 pybind11 的逻辑.

1: https://peps.python.org/pep-0513/#libpythonx-y-so-1

描述可能的解决方案

  1. 在设置了 headeronly 时, 永远不检查是否能找到链接文件
  2. 在 Windows 下强制关闭 headeronly, Windows 下必须链接到 Python.lib
  3. 为 pybind11 添加一个参数, 设置 Python 的 headeronly 模式

我已经写了提交1用于解决此问题, 但是不确定这样做是否合适 , 因为我看到 CMake 是通过另一种方式解决的此问题: https://gitlab.kitware.com/cmake/cmake/-/issues/20425

1 https://github.com/myuanz/xmake-repo/commits/master/

描述你认为的候选方案

No response

其他信息

  1. 我很想在 pybind11 里加入这样的逻辑: 先找 Python, 如果找不到就提示在 manylinux 这类有 header 但是没有 lib 的环境里, 可以开启 headeronly 来避免报错. 我读了文档看不懂怎么做到这件事
  2. 在寻找 Python 的时候, 如果能找到 header 但是找不到 lib, 提示一下应该会让人好 debug 一些. 但是我不清楚怎么提示比较合适, 因为没有-vD的时候, print 是被隐藏的.
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Adjust the logic related to Python search, be compatible with manylinux, and facilitate Python-related CI

@waruqi
Copy link
Member

waruqi commented Oct 2, 2024

可以来个 pr 改进下 fetch.lua

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


You can send a PR to improve fetch.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants