-
Notifications
You must be signed in to change notification settings - Fork 179
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] Don't link C extensions to libpython #1395
[python] Don't link C extensions to libpython #1395
Conversation
Update: Need to do some more testing/investigation on this... Looks like it may only be a CPython 3.8+ solution. |
Does this actually work? I though linkage was required, but since the build is green, it's not necessary? However, in general, the whole Python build process should be triggered through Python instead of through CMake. It's definately on our list to have proper pip support and universal linux wheels and most effort should go in that direction. |
Your helper here correctly calls I reproduced the error on Linux using Python 3.12 and confirmed that removing the link fixes it for "build with shared -> use with static". From the research it looks like this was only made possible with Python 3.8 so just need to check behaviour under 3.7 and re-verify Windows too.
This is definitely something I would love to see too. Happy to help out where possible to make it happen for eCAL 6 😄 |
TLDR: Everything looks good 😄
I read my link more closely, looks like it was only changing how distutils builds C extensions, so not relevant in this situation. Even if it does give some helpful discussion. Anyway, onto my verification testing. Windows: Ubuntu 22.04 LTS (WSL) with Python 3.7 built via pyenv: Before: After: Inspecting the build differences again we see a very similar thing, expect that the libpython linkage is completely removed. To summarize everything.
(This is probably the most effort I've put into a 2 line change 😆) |
Thanks for all the investigation that you put into this topic 👍 I will merge your PR, thanks for contributing! |
Cherry pick to: 5.12 5.13.
Cherry pick to: 5.12 5.13.
Cherry pick to: 5.12 5.13.
Cherry pick to: 5.12 5.13.
Description
Fixes the Python C extensions having an explicit link dependency on libpython. In environments without libpython this causes problems. The easiest way to encounter this is through pyenv.
Eg: Building the wheel using a Python install that has libpython and trying to install and run it in a Python without it (static build).
The first hint of the problem is running
ldd
on the shared object when using a pyenv installation (for example):This will actually run fine if it is run in a Python interpreter that has a shared libpython as the wheels inherit the symbols from Python (see the PEP 513 link below). However; trying to run this eCAL wheel in a statically built Python will cause an error like:
PEP 513 supporting material
Fixing this is one small step closer to redistributable wheels.
Related issues
Cherry-pick to