Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build pgmagick under pythonbrew on OS X?

I'm not having much success when attempting building pgmagick on OS X Lion with XCode 4.3.1.

I've installed both ImageMagick and GraphicsMagick, along side boost, using the following commands (via homebrew):

$ brew install graphicsmagick --with-magick-plus-plus
$ brew install imagemagick --with-magick-plus-plus
$ brew install boost --with-thread-unsafe

then I'm cloning the repo at https://bitbucket.org/hhatto/pgmagick:

$ hg clone https://bitbucket.org/hhatto/pgmagick/src
$ cd pgmagick
$ python setup.py build

However I always receive the following error:

ld: library not found for -lboost_python
collect2: ld returned 1 exit status

Based on the output on stdout, setup is looking in the right place for the boost (/usr/local/lib).

I've also tried easy_install and pip but with no luck. I'm using Pythonbrew but have also disabled this and tried using the stock python install -- still no success.

Any suggestions on how I can fix the problem, or further diagnose the issue?

like image 335
Phillip B Oldham Avatar asked Mar 20 '12 12:03

Phillip B Oldham


Video Answer


2 Answers

According to my own reproduction of this issue in brew 0.9 and OSX 10.6.8, the problem is --with-thread-unsafe isn't being honored by the current brew formula file. You can verify this by checking the formula with brew edit boost and seeing if the option appears within the contents of the formula.

Because of this, libboost_python-mt.a and libboost_python-mt.dylib are being built instead of libboost_python.a and libboost_python.dylib.

The easiest ways to fix this are to edit your pgmagick setup.py to replace boost_lib="boost_python" with boost_lib="boost_python-mt" (as pointed out here) or to follow the instructions and patch here. It's otherwise a known issue.

like image 135
MrGomez Avatar answered Sep 28 '22 18:09

MrGomez


The boost_python lib inside /usr/local/lib/ is named after libboost_python-mt.a and libboost_python-mt.dylib, since the default compiling is w/ multi-threads supporting enabled.

Grep boost_lib="boost_python" under ELSE condition in setup.py and replace it w/ boost_lib="boost_python-mt", will fix the "not found" issue.

Also it's OK to ln "-mt" version to libboost_python.a: as described here for linux boost which no longer appends '-mt' suffix since 1.42.

Ignore this line or you could "with-boost-python=boost_python-mt python setup.py install". You could probably append '--with-boost-python=boost_python-mt' to extra_compile_args inside setup.py, to achieve the same goal.

Furthermore, you could install pgmagick through pip in managed envs. Refs http://rohanradio.com/blog/2011/12/02/installing-pgmagick-on-os-x/

like image 43
okm Avatar answered Sep 28 '22 16:09

okm