Skip to content

Add DSO to example (broken for pip install) - #18

Closed
ssteinbach wants to merge 1 commit into
pybind:masterfrom
ssteinbach:master
Closed

ssteinbach wants to merge 1 commit into
pybind:masterfrom
ssteinbach:master

Conversation

@ssteinbach

Copy link
Copy Markdown

Hello,

This example was really helpful! I'm confused about how to correctly build/install a DSO that the pybind11 module needs to link. This PR adds a DSO (libarugula) to the example that the python module cmake_example links to (and exposes a function from, test_func).

This PR produces a working module in python setup.py develop or pip install -e . modes, but when running pip install . on the module, the installed version does not import because the RPATH on the installed cmake_example.so points to the temporary directory that pip used to compile the module. The module does however correctly install both cmake_example.so and libarugula.so (testing on linux). Does anyone have any suggestions?

> python -c "import cmake_example"        
Traceback (most recent call last):        
  File "<string>", line 1, in <module>
ImportError: libarugula.so: cannot open shared object file: No such file or directory

LDD info for the library:

> ldd cmake_example.so | grep arugula
        libarugula.so => not found

objdump:

> objdump -x cmake_example.so | grep RPATH
  RPATH                /scratch/tmp/pip-req-build-FfOtXz/build/lib.linux-x86_64-2.7

But all that said, setup.py did install both the cmake_example.so and the libarugula.so so I think its this is close:

> ls *.so
cmake_example.so* libarugula.so*  

And pip uninstall cmake_example also correctly wants to uninstall libarugula from site-packages:

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Uninstalling cmake-example-0.0.1:
  Would remove:
    .../lib/python2.7/site-packages/cmake_example-0.0.1.dist-info/*
    .../lib/python2.7/site-packages/cmake_example.so
    .../lib/python2.7/site-packages/libarugula.so

Thanks!

@ssteinbach

Copy link
Copy Markdown
Author

This should also include #16

@ax3l ax3l mentioned this pull request Mar 31, 2020
@ssteinbach ssteinbach closed this Jan 20, 2021
@ssteinbach

Copy link
Copy Markdown
Author

Looks like this was addressed by #16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant