This is a build script to create, and optionally install, libtorrent.so
statically linked against openssl
, libtorrent 1.1
, 1.2
or 2.0
and boost-python
. wolfssl
is available as an alternative to openssl
when using libtorrent v2 onwards.
This makes setting up Deluge
+ libtorrent
+ ltconfig 2
an automated and reasonably quick installation by copy and pasting a few commands.
Based on these docs:
http://www.libtorrent.org/building.html
http://www.libtorrent.org/python_binding.html
- The script will install the required dependencies when run as a root or using a docker image.
- You can setup the build environment as root and then use the build function as a local user.
- The script is designed to work with a docker image/container and works with docker rootless
There are three stages to the script depending on what requirements it detects.
- It will update the system and require a reboot to proceed, if required.
- If no reboot is required it will continue to install the build environment dependencies and exit unless a module was passed as an argument.
- If the run using a module argument like
all
it will start buildinglibtorrent-python-binding
or the specified module usingpython3
.
The script tries to be automated and helpful but here are the help options to guide you.
Here are a list of available options
Use: -b or --build-directory Help: -h-b or --help-build-directory
Use: -c or --crypto Help: -h-c or --help-crypto
Use: -n or --no-delete Help: -h-n or --help-no-delete
Use: -lm or --libtorrent-master Help: -h-lm or --help-libtorrent-master
Use: -lt or --libtorrent-tag Help: -h-lt or --help-libtorrent-tag
Use: -p or --proxy Help: -h-p or --help-proxy
Use: -tb or --test-build Help: -h-tb or --help-test-build
Use: -s or --scope Help: -h-s or --help-scope
Module specific help - flags are used with the modules listed here.
Use: all or module-name Usage: ~/libtorrent-python.bash all
Here are a list of dependency specific modules
update --------- update host - apt/apk update
install -------- Install dependencies
bootstrap ------ update and install combined
install_deluge - pip install deluge
Here are a list of build specific modules
all ---------- Install all modules - openssl boost libtorrent
openssl ------ Install the openssl module (default)
wolfssl ------ Install the wolf module (Libtorrent v2 only)
boost -------- Download, extract and bootstrap the boost build files
libtorrent --- Build the libtorrent python binding
libtorrent-python.bash
us works on modern Alpine or Debian based hosts.
curl -sLO https://raw.githubusercontent.com/userdocs/python-libtorrent-binding/refs/heads/master/libtorrent-python.bash
chmod +x libtorrent-python.bash
./libtorrent-python.bash
There are two ways to use the script
- With a docker image for the relevant platform.
- Run directly on the system where you want to build the binding.
Using Docker
- Port
8112
for deluge installation. - Built to
$HOME/bindings
Note: This command can be configured using flags top provide a specific outcome. Change ubuntu:20.04
to debian:stable
to use Debian.
docker run -it -p 8112:8112 -v $HOME/bindings:/root ubuntu:latest /bin/bash -c 'cd && apt-get update && apt-get install -y curl git && curl -sL git.io/gplibtorrent | bash -s all && bash'
Optionally you could create and configure the docker first and then use the script from within the container.
docker run -it -p 8112:8112 -v $HOME/bindings:/root ubuntu:latest /bin/bash -c 'cd && apt-get update && apt-get install -y curl git && bash'
Now you can call commands from within the docker container.
curl -sL git.io/gplibtorrent | bash -s all
Note: You can modify this part bash -s all
in either method to customise the behaviour of the command. Refer to the help section above.
Note: You can do this from within a docker container as well.
wget -qO ~/libtorrent-python-binding.sh https://git.io/gplibtorrent
chmod 700 ~/libtorrent-python-binding.sh
~/libtorrent-python-binding.sh
Using Docker
- Port
8112
for deluge installation. - Built to
$HOME/bindings
Note: This command can be configured using flags top provide a specific outcome.
docker run -it -p 8112:8112 -v $HOME/bindings:/root alpine:latest /bin/ash -c 'cd && apk update && apk add bash curl git && curl -sL git.io/mplibtorrent | bash -s all && ash'
Optionally you could create and configure the docker first and then use the script from within the container.
docker run -it -p 8112:8112 -v $HOME/bindings:/root alpine:latest /bin/ash -c 'cd && apk update && apk add bash curl git && ash'
Now you can call commands from within the docker container.
curl -sL git.io/mplibtorrent | bash -s all
Note: You can modify this part bash -s all
in either method to customise the behaviour of the command. Refer to the help section above.
Note: You can do this from within a docker container as well.
wget -qO ~/libtorrent-python-binding.sh https://git.io/mplibtorrent
chmod 700 ~/libtorrent-python-binding.sh
~/libtorrent-python-binding.sh
all
- Install defaults openssl
> boost
> libtorrent
using v1.2.*
latest version
all pv 2 -lt libtorrent-1_1_14
- Install openssl
> boost
> libtorrent
using the release 1.1.14
built with python2
all -lm
- Install defaults openssl
> boost
> libtorrent
RC_1_2
main branch
all -lt RC_2_0
- Install defaults openssl
> boost
> libtorrent
using the RC_2_0
main branch
all pv 2 -lt RC_2_0
- Install defaults openssl
> boost
> libtorrent
using the RC_2_0
main branch built python2
all -c wolfssl -lt v2.0.1
- Install wolfssl
> boost
> libtorrent
using the release v2.0.1
built with python3
all pv 2 -c wolfssl -lt v2.0.1
- Install wolfssl
> boost
> libtorrent
using the release v2.0.1
built with python2
Once the script is finished the required files will be built
~/libtorrent-python/completed
You can install deluge by using the command:
~/libtorrent-python-binding.sh install
It will install to the ~/.local
directory of the user running the script.
Note: This script does not attempt to configure deluge.