Installing a package with pip under conda env fails to find shared libraries on linux

Hi there,

I am trying to package a python package generated by SWIG. The package contains the python module along with the shared libraries. For packaging I am using wheels. In particular, under the directory that contains the, I do:

python -m build --wheel

When installing with pip under my conda env everything works fine on Windows. However, under linux, when I am importing my module, I get the following ImportError:

ImportError: cannot open shared object file: No such file or directory

The shared lib is located under $CONDA_PREFIX/lib/python3.11/site-packages/my_package and the under $CONDA_PREFIX/lib.

I understand that the system tries to find these shared libraries in default dirs (e.g. usr/lib, LD_LIBRARY_PATH, etc). Therefore, when I add these one under LD_LIBRARY_PATH everything is working.

Is there any way to avoid this? Is there any way to create a symlink or anything like that when installing the python package with pip? I wouldn’t like the users to do that whenever they install my package.

Many thanks in advance and best regards,