2016年10月19日星期三

Install python-lzo on osx

- install lzo
$ brew intall lzo

- download python-lzo
$ wget https://pypi.python.org/packages/26/d2/6d118e3b8d29b61d75dc9279ae8233915aaefaa630f6a6ad3b9924147367/python-lzo-1.08.tar.gz\#md5\=5fa6fb70428dcf3318d104ae192ad5c9

- uncompress python-lzo
$ tar zxvf python-lzo-1.08.tar.gz

- edit setup.py
add these lines after line 29 libraries = ["lzo2"]

<blockquote>include_dirs.append("/usr/local/include/")
library_dirs.append("/usr/local/lib")</blockquote>


- edit lzomodule.c
replace #include <lzo1x.h> with #include <lzo/lzo1x.h>

- install
sudo -H python setup.py install


PS:
During the process of installing python-lzo, i got some errors such as:
- lzomodule.c:35:10: fatal error: 'lzo1x.h' file not found
- ld: library not found for -llzo2
- ld: can't open output file for writing 'build/lib.macosx-10.12-x86_64-2.7/lzo.so.ld_z7QuBz', errno=13 for architecture x86_64

If you have encountered same error, this article may be help.