Tag Archives: python3

macOS 下试着编译 libtorrent with python3

主要借鉴 https://github.com/Homebrew/legacy-homebrew/issues/24923
最坑的地方在于

python3 -c "import sysconfig; print(sysconfig.get_config_var('LDLIBRARY'))"
Python.framework/Versions/3.6/Python

然后传到 PYTHON_EXTRA_LIBS 当然挂了。。。

brew install python3 boost  openssl libiconv
brew install boost-python --with-python3 --without-python
git clone https://github.com/arvidn/libtorrent ~/repos/libtorrent
./autotool.sh
LIBS="-L/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/" PYTHON_EXTRA_LDFLAGS=" " PYTHON_EXTRA_LIBS="-Wl,-stack_size,1000000  -framework CoreFoundation /usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/Python"  ./configure --with-libiconv --with-openssl=/usr/local/opt/openssl PYTHON="/usr/local/bin/python3" --enable-python-binding
 
make -k8
sudo make install
sudo python3 setup.py install

装完还是有点问题 不知道是不是因为我的macOS版本不够新

>>> import libtorrent
Traceback (most recent call last):
File ““, line 1, in
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/libtorrent.cpython-36m-darwin.so, 2): Symbol not found: _kSCCompAnyRegex
Referenced from: /usr/local/lib/libtorrent-rasterbar.10.dylib
Expected in: flat namespace
in /usr/local/lib/libtorrent-rasterbar.10.dylib

我不懂CPP 先笔记到这里
更新boost-python选项
我系统版本比较老,还是 El Captain。如果有Sierra编译成功的可以留言一发。

根据 @zzzhr 反馈已经可以用了 就这样吧 再也不想自己编译了,心累。