• Making 'compiled' modules work with multiple python versions on Linux

    From Olivier B.@perso.olivier.barthelemy@gmail.com to comp.lang.python on Thu Mar 28 16:07:04 2024
    From Newsgroup: comp.lang.python

    I have a python module that includes some C++ code that links with the
    Python C API

    I have now modified the c++ code so that it only uses the Limited API,
    and linked with python3.lib instead of python311.lib.

    I can now use that python module with different python versions on Windows

    But on Linux, it seems that linking to libpython3.so instead of libpython3.11.so.1.0 does not have the same effect, and results in
    many unresolved python symbols at link time

    Is this functionality only available on Windows?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Olivier B.@perso.olivier.barthelemy@gmail.com to comp.lang.python on Fri Mar 29 17:09:32 2024
    From Newsgroup: comp.lang.python

    It is not a symlink on my system, where i built python myself, but a
    15KB so file. But it seems to lack lots of python symbols.
    Maybe what i should do is actually make libpython.so a physical copy
    of libpyton311.so before linking to it, so now on any system the
    module would look to load libpython.so, which could be pointing to any
    version. I'll try that next
    Le ven. 29 mars 2024 à 10:10, Barry <barry@barrys-emacs.org> a écrit :



    On 28 Mar 2024, at 16:13, Olivier B. via Python-list <python-list@python.org> wrote:

    But on Linux, it seems that linking to libpython3.so instead of libpython3.11.so.1.0 does not have the same effect, and results in
    many unresolved python symbols at link time

    Is this functionality only available on Windows?

    Python limited API works on linux, but you do not link against the .so on linux I recall.

    You will have missed that libpython3.so is a symlink to libpython3.11.so.10.

    Windows build practices do not translate one-to-one to linux, or macOS.

    Barry


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Barry Scott@barry@barrys-emacs.org to comp.lang.python on Fri Mar 29 16:45:58 2024
    From Newsgroup: comp.lang.python


    On 29 Mar 2024, at 16:09, Olivier B. <perso.olivier.barthelemy@gmail.com> wrote:

    It is not a symlink on my system, where i built python myself, but a
    15KB so file. But it seems to lack lots of python symbols.

    Maybe what i should do is actually make libpython.so a physical copy
    of libpyton311.so before linking to it, so now on any system the
    module would look to load libpython.so, which could be pointing to any version. I'll try that next
    You do not link against the .so at all. All the symbols you need are defined in the
    python process that loads the extension. Try without the -lpython and it should just work.
    Barry

    Le ven. 29 mars 2024 à 10:10, Barry <barry@barrys-emacs.org> a écrit :



    On 28 Mar 2024, at 16:13, Olivier B. via Python-list <python-list@python.org> wrote:

    But on Linux, it seems that linking to libpython3.so instead of
    libpython3.11.so.1.0 does not have the same effect, and results in
    many unresolved python symbols at link time

    Is this functionality only available on Windows?

    Python limited API works on linux, but you do not link against the .so on linux I recall.

    You will have missed that libpython3.so is a symlink to libpython3.11.so.10. >>
    Windows build practices do not translate one-to-one to linux, or macOS.

    Barry



    --- Synchronet 3.20a-Linux NewsLink 1.114