5
5
The standard approach does not work:
brew install libtorrent-rasterbar
Will install the boost requirement (linked against the system Python), and libtorrent-rasterbar will install without any Python bindings at all.
How do you fix this?
5
5
The standard approach does not work:
brew install libtorrent-rasterbar
Will install the boost requirement (linked against the system Python), and libtorrent-rasterbar will install without any Python bindings at all.
How do you fix this?
5
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
)
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.
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.
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
>>>
0
brew install libtorrent-rasterbar --with-python
works.
0
I found on github comment on installing packages over brew like libtorrent-rasterbar for example. They don't link to python without explicitly telling brew to do it so you have to add --with-python to brew install command:
brew install libtorrent-rasterbar --with-python
You don't need to install python from brew you can use one already on your mac. But you have to link brew python packages to your path so you can import them directly from python:
mkdir -p /Users/filip/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/filip/Library/Python/2.7/lib/python/site-packages/homebrew.pth
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import libtorrent
>>>
Tested on: MAC OS X Yosemite 10.10.3
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) – Israel Zalmanov – 2014-07-25T04:52:47.000