Skip to content

Building with Python3 links against Boost Python2 library #52

@daniel-j-h

Description

@daniel-j-h

On a Ubuntu 16.04 box where I have both Python2 as well as Python3:

$ ls /usr/lib/x86_64-linux-gnu/libboost_python*.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so
/usr/lib/x86_64-linux-gnu/libboost_python.so

$ ll /usr/lib/x86_64-linux-gnu/libboost_python.so
lrwxrwxrwx 1 root root 49 Dec 22 14:16 /usr/lib/x86_64-linux-gnu/libboost_python.so -> /usr/lib/x86_64-linux-gnu/libboost_python-py27.so

When I install the osmium Python bindings with Python3 and compile osmium from source

python3 -m pip install osmium

the resulting shared object links against Python2:

ldd /usr/local/lib/python3.6/dist-packages/osmium/_osmium.cpython-36m-x86_64-linux-gnu.so | grep python
        libboost_python-py27.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0 (0x00007f91eeff3000)

which results in undefined symbol errors when trying to use osmium from a Python3 script:

ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0: undefined symbol: PyClass_Type

Is there a way for pyosmium to check if the build process is meant for Python2 or Python3 and then link against 2.x or 3.x Boost.Python shared libraries, respectively?


Workaround is a bit ugly but does the job:

python3 -m pip uninstall osmium
rm -rf ~/.cache/pip/wheels/

rm /usr/lib/x86_64-linux-gnu/libboost_python.so
ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so /usr/lib/x86_64-linux-gnu/libboost_python.so

python3 -m pip install osmium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions