jeffdaily / parasail-python

Python bindings for the parasail C library.
Other
90 stars 17 forks source link

libparasail.so in LD_LIBRARY_PATH not found during installation #26

Closed HenrikBengtsson closed 6 years ago

HenrikBengtsson commented 6 years ago

I've installed the parasail library separately such that I have libparasail.so on the LD_LIBRARY_PATH:

$ echo $LD_LIBRARY_PATH
/home/alice/parasail-2.2.0-manylinux1_x86_64/lib

$ ls -l /home/alice/parasail-2.2.0-manylinux1_x86_64/lib
total 90992
-rw-r--r-- 1 henrik cbc 58275618 Jul 10 14:58 libparasail.a
-rwxr-xr-x 1 henrik cbc      979 Jul 10 14:58 libparasail.la
lrwxrwxrwx 1 henrik cbc       20 Sep  6 09:18 libparasail.so -> libparasail.so.3.2.0
lrwxrwxrwx 1 henrik cbc       20 Sep  6 09:18 libparasail.so.3 -> libparasail.so.3.2.0
-rwxr-xr-x 1 henrik cbc 34891609 Jul 10 14:58 libparasail.so.3.2.0
drwxr-xr-x 2 henrik cbc       34 Jul 10 14:58 pkgconfig

However, whenever I attempt to install the parasail Python package, it does not find it. Instead it attempts to download it;

$ pip install parasail
Collecting parasail                                                                           
  Using cached https://files.pythonhosted.org/packages/64/e5/b7b0ab11296923be15dbdbcfb4dd79dc427b5b52a7de9716aa64548afdf7/parasail-1.1.12.tar.gz
Requirement already satisfied: numpy in ./lib/python2.7/site-packages (from parasail) (1.15.1)                        
Building wheels for collected packages: parasail                                                     
  Running setup.py bdist_wheel for parasail ... error                                   
  Complete output from command /home/cbctest2/foo2/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/cbctest2/pip-install-RRW3rS/parasail/setup.py';f=getattr(tokenize, 'open', open)(__file__
);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/cbctest2/pip-wheel-I7PfIs --python-tag cp27:
  running bdist_wheel                                                                                     
  parasail/libparasail.so not found, attempting to build                                                          
  Downloading latest parasail master
  [...]

Is this expected/not supported?

This is on:

$ python --version
Python 2.7.9

(Yes, it's old, but I don't this that's related to the problem)

jeffdaily commented 6 years ago

setup.py only looks for parasail/libparasail.so. I don't support the case where parasail was installed separately. My reasoning at the time was:

  1. python users should get the latest and greatest parasail library,
  2. the parasail-python bindings are generally kept up-to-date with the latest and greatest C parasail, and
  3. the ctypes problem of locating the *.so

The wheel that is built by setup.py bundles the library inside the wheel next to the __init__.py file. The import of parasail (in __init__.py) then looks in the __file__ path for the library. I did it that way to avoid (3) above, so that users always get a working parasail-python. I would like to keep this as the default, but I'm willing to add perhaps an option (via env var perhaps?) that could override the location or symlink it or ... I'm open to suggestions.

HenrikBengtsson commented 6 years ago

Background: I came to this from getting SSL: CERTIFICATE_VERIFY_FAILED due to an old Python 2.7.9 installation (https://github.com/jeffdaily/parasail-python/issues/25#issuecomment-419177581). I solved that one by disabling SSL cert validation temporarily. It also install fine when using Python 2.7.15. However, before those to solutions, I attempted with a standalone installation of the parasail library - hence this question.

I don't have any strong feeling about supporting libparasail.* on LD_LIBRARY_PATH, but I might not be the only one that would expect it to possible work. An env var (during installation) for supporting libparasail.* on LD_LIBRARY_PATH would be handy. OTH, I think your original arguments for now supporting are also valid.

Feel free to label 'wontfix' and close.

jeffdaily commented 4 years ago

Just pushed a new release to address this issue. Please try it out and let me know how it works for you.

Set the env var PARASAIL_SKIP_BUILD to avoid downloading and building the C library. The library loading at runtime will search in the package location first (original behavior, but the library will no longer exist), followed by a direct ctypes.CDLL(libname) that should search system locations, followed by searching paths in environment including PARASAIL_LIBPATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, and PATH.

Set PARASAIL_VERBOSE=1 env var to see the progress of the library searching.