I have a library that I've created with PyO3 on my system using Python 3.5.2. The .so file links to the corresponding libpython3.5m file:
$ ldd my_library.so
linux-vdso.so.1 => (0x00007ffffc823000)
libpython3.5m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0 (0x00007fcac34b0000)
...
But if I try to use my library on another system with a different minor version of Python (eg, 3.6.9 or 3.7.3), that library doesn't exist:
$ ldd my_library.so
linux-vdso.so.1 (0x00007fffefaae000)
libpython3.5m.so.1.0 => not found
...
And therefore, I can't use my library:
$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import my_library
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
Is there a way that I can link my library to libpython more generically to be resilient to these minor version changes or at least allow backward-compatibility (build on newer version but allow older versions of Python to also use my library)? Or anything I can do at runtime to let the library still function?