9

I am trying to install boost bindings for python3 on Ubuntu Xenial, but it pulls in whole python2.7 dependency tree. I do not want or need python2.7 on my system (Docker image). Is there a way to install only python3 bindings?

8
+400

I have resolved to compiling and installing boost myself (I also installed/compiled Python 3.6 myself.). I have in my Dockerfile now:

# We have to compile it ourselves against the custom Python and cannot use Debian package.
# Includes a symlink workaround for: https://svn.boost.org/trac10/ticket/11120
RUN cd /usr/src && \
 wget --no-verbose https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.gz && \
 tar xzf boost_1_65_1.tar.gz && \
 cd boost_1_65_1 && \
 ln -s /usr/local/include/python3.6m /usr/local/include/python3.6 && \
 ./bootstrap.sh --with-python=$(which python3) && \
 ./b2 install && \
 rm /usr/local/include/python3.6 && \
 ldconfig && \
 cd / && rm -rf /usr/src/*
| improve this answer | |
2

You have three options:

1. Build Boost.Python yourself

This is the option I recommend: it's clean, there's no risk to mess up your system and you have full control on what you get. Moreover1

Boost.Python is a separately-compiled (as opposed to header-only) library

so you can just build that. Download the archive and follow the instruction on the Getting Started guide. (This is what OP did.)


2. Use dpkg to avoid installing unwanted dependecies

If you don't want to build Boost.Python yourself, you can bypass apt (and its dependencies cheking) with dpkg.

Let's say you want to install a package named foo which depends on bar and baz, but you don't actually need baz.

apt download foo bar
sudo dpkg --ignore-depends=baz --install foo.deb bar.deb

Notice that apt will still complain about unresolved dependencies (but hey, that's its job), so the problem is not entirely solved: you just swept it under the carpet.

This option is quicker than the previous one, but I wouldn't recommend it.


3. Use equivs to fool apt

This is new to me. Apparently, you can create dummy packages to fulfill the dependencies. In this way, you don't have to install unwanted/unnecessary packages and apt will not complain about it.

As I said, I've never used equivs before, but you can find out more about it here.

| improve this answer | |
0

due to my research, it's not possible

libboost-python-dev package has libboost-python1.67-dev dependency.

https://packages.debian.org/sid/libboost-python-dev

and libboost-python1.67-dev has python-dev dependency which uses python 2

https://packages.debian.org/sid/libboost-python1.67-dev

so you cannot do this I think you cannot do this in Debian.

I recommend checking arch base and rpm base distros.

| improve this answer | |
-3

I can offer two solutions, one is to build a Python:3.6 image from scratch. Here python3.x becomes the de-facto choice.

Also, another option which worked for me (in Mac OSX) was:

brew install boost-python --with-python3 --without-python

| improve this answer | |
  • 3
    Homebrew on Ubuntu?? – Leopd Nov 19 '18 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.