-
Notifications
You must be signed in to change notification settings - Fork 81
Don't link to libpython for Python >= 3.8 #109
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
Conversation
As of Python 3.8, python C extensions modules should not link to libpython, unless they embed the interpreter in their code. Relevant upstream PR: python/cpython#12946 Signed-off-by: Gabriel Féron <[email protected]>
It looks also like this won't be possible on Windows, according to that PR and the changelog of Python. So this only applies to Linux then. I'm using Python 3.8 in my development environment and linking to CPython works just fine. I understand that this makes it easier to create a build script, but with the build script already set up does it have any tangible advantage? |
Yes, linking works fine. So does not linking. Not linking makes it possible to import the module from a debug build of Python. Linking gives no advantages. So: Linking to libpython:
Not linking to libpython:
I don't understand this part. What build script? |
I meant the CMake scripts, such as the modified file: https://github.com/Ultimaker/libArcus/blob/master/cmake/SIPMacros.cmake . I guess technically that would be a "configure" script to the maintainers, sorry 😃 You wouldn't need to find the Python libraries, and then wouldn't need to write that |
This commit breaks the build when using '-Wl,--no-undefined' eg:
|
Breaks how? |
The comment above was edited. |
Well it does "break" it indeed, but only because you say "every reference needs to be defined" which is not true for Python extension modules. What is the purpose for using |
Heh, gave me quite a headache but found an issue with this code. I made an adjustment here to allow our build server to run it again: b6c89c7 See the commit message for the reasoning. We had temporarily reverted these changes a week ago because of that build issue. It should be fixed more properly now (build pending). Please see if it still works for you as well. |
Currently the build uses the CMAKE_SHARED_LINKER_FLAGS for both the libArcus shared library as well as the Python module. Starting with Python 3.8 the Python module is no longer linked to libpython, and thus some symbols stay undefined. The correct build type for python modules is "MODULE", which uses the distinct CMAKE_MODULE_LINKER_FLAGS. This allows to keep the '-Wl,--no-undefined' linker flag for libArcus. Ultimaker#109
It is the correct flag for For the python module |
As of Python 3.8, python C extensions modules should not link to
libpython, unless they embed the interpreter in their code.
Relevant upstream PR: python/cpython#12946
Signed-off-by: Gabriel Féron [email protected]