How do you install libtorrent-rasterbar Python bindings with a brewed Python?

53

After lots of digging, googling and trial and error, I've been able to get this all to work. I'm sharing my experiences here in the hope to save others the trouble.

The first step is to make sure that you have your Python properly installed. Check that which python gives back the right Python version (probably something like /usr/local/bin/python)

Properly linked boost

Check if your boost is linked against the right version of Python using the following command (Change /usr/local to your Homebrew prefix where necessary).

otool -L /usr/local/lib/libboost_python-mt.dylib

The result should contain the line:

/usr/local/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)

If it points to somewhere in /System/Library/Frameworks, you need to rebuild your boost libraries and force a build from source (ref):

brew rm boost ; brew install boost --build-from-source

Once that is done you can run the above line to verify it linked correctly.

Libtorrent-rasterbar with Python bindings

Now that boost is installed properly, libtorrent-rasterbar can use them to build the Python bindings. We have to edit the formula to enable them, but also to educate the build process on where to find them.

Execute brew edit libtorrent-rasterbar and then change it to match this:

def install
system "./configure", "--disable-debug",
                      "--disable-dependency-tracking",
                      "--enable-python-binding",
                      "--with-boost-python=mt",
                      "--prefix=#{prefix}"

The two important lines here are to enable the python bindings with --enable-python-binding and the second is --with-boost-python=mt to show that it has been installed with an "mt" suffix (ref).

This will allow the build process to recognize the boost library which was installed in the first step. So close the editor, and do brew install libtorrent-rasterbar as normal.

Final Check

Finally, to make sure that it all worked:

% python
Python 2.7.3 (default, Feb 10 2013, 10:53:34) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.24)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import libtorrent
>>> 
Share:
53

Related videos on Youtube

avarndell
Author by

avarndell

Updated on September 18, 2022

Comments

  • avarndell
    avarndell over 1 year

    I have a parent component called "ReportComponent" with a child component "PortCriteriaComponent". When I start form the home page (localhost: 8080/home), and Click on the link to Port Reports, the parent and child components will load. However, if I go to the parent component directly (localhost:8080/reports/4005, the child components will NOT load.

    https://stackblitz.com/edit/angular-va12km

  • Israel Zalmanov
    Israel Zalmanov almost 10 years
    What worked for me is: brew install boost --with-python and brew libtorrent-rasterbar --with-python (OSX 10.9, python 2.7.8 which was installed using brew)
  • Belegnar
    Belegnar about 4 years
    Does not work with Homebrew 2.2.10