Ubuntu 20.04 下安装 Deluge 1.3.15

Deluge 1.3.15 需要 Python 2,但是由于 Python 2 已经停止支持,因此 Ubuntu 20.04 的官方源也逐渐在取消对这些旧版 Python 的支持。如果真的需要装一个老版本的话,就有很多东西需要自己编译。

首先整理一下需要的依赖:

  • Deluge 1.3.15 需要 Python 2 以及一些 Python 2 的库,但是有些库已经不能直接通过官方源安装(在 PyPI 中仍然存在)
  • Deluge 调用 libtorrent 的 Python binding
  • libtorrent 的 Python Binding 基于 Boost.Python
  • Ubuntu 20.04 的默认 Python 版本是 3.8,Boost.Python (1.71) 也基于 3.8 构建

那么为了正常运行 Deluge 1.3.15,需要做的事情有这些:

  • 用 pip2 解决 Deluge 的 Python 依赖
  • 单独编译基于 Python 2.7 的 Boost.Python

安装依赖:

# libtorrent
apt install libboost-dev libboost-system-dev libboost-chrono-dev libboost-random-dev libssl-dev libgeoip-dev

# Deluge
apt install python2 python2-dev
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
python2 get-pip.py

apt install python-mako python-chardet python-openssl python-pkg-resources python-xdg intltool librsvg2-common xdg-utils geoip-database
pip install Twisted service-identity

编译 Boost.Python:

wget https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.gz
tar xzvf boost_1_71_0.tar.gz
apt purge libboost-python-dev libboost-python1.71-dev libboost-python1.71.0
./bootstrap.sh --with-python=/usr/bin/python2
./b2 --with-python
checkinstall ./b2 install --with-python

如果要编译基于 Python 3 的版本,在 booststrap 的时候选择对应的 Python 解释器即可。

编译 libtorrent:

git clone https://github.com/arvidn/libtorrent.git libtorrent
cd libtorrent
git checkout RC_1_1
./autotool.sh
PYTHON_VERSION=2.7 ./configure --enable-python-binding --with-libiconv --disable-debug --enable-encryption --with-libgeoip=system --with-boost-python=boost_python27
make -j$(nproc)
checkinstall
ldconfig

注意这里通过 –with-boost-python 来指定 linker 使用的选项名(-lboost_python27)。

之后正常安装 Deluge 1.3.15 即可:

wget https://ftp.osuosl.org/pub/deluge/source/1.3/deluge-1.3.15.tar.xz
tar xJvf deluge*.tar.xz
python2 setup.py build
python2 setup.py install --install-layout=deb

Reference

https://stackoverflow.com/questions/28830653/build-boost-with-multiple-python-versions

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注