libtorrent Python bindings.md
1 2 > If you are here because you are trying to build Deluge client, before proceeding, please check build instructions in [[Deluge]] regarding the location of the python virtual environment folder (`.venv` in this case). 3 4 To build a debug version with python bindings, first (re)build and (re)install the debug target: 5 6 ```bash 7 b2 crypto=openssl cxxstd=14 debug 8 sudo b2 install --prefix=/usr/local 9 ``` 10 11 Then check [[Modern Python Tools|Python Tools]], and install `uv`: 12 13 ```bash 14 curl -LsSf https://astral.sh/uv/install.sh | sh 15 ``` 16 17 Then create a virtual env indicating the python version you want to use: 18 19 ```bash 20 uv venv --python 3.12.3 21 ``` 22 23 It will create a folder called `.venv` in your current folder. 24 25 Activate the environment: 26 27 ```bash 28 source .venv/bin/activate 29 ``` 30 31 > Make sure you have the correct path to the `.venv` folder, If you are not in the folder directly containing `.venv` folder. 32 33 Then, install `setuptools`: 34 35 ```bash 36 uv pip install setuptools 37 ``` 38 39 Also make sure that you have: 40 41 ```bash 42 sudo apt install libboost-python-dev 43 ``` 44 45 as specified in [libtorrent python binding](http://www.libtorrent.org/python_binding.html) in *prerequisites*. 46 47 Finally, from `bindings/python` run: 48 49 ```bash 50 python setup.py build_ext --b2-args=variant=debug install 51 ``` 52 53 Python bindings should be ready to use. You should be able to test it with: 54 55 ```bash 56 python 57 Python 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] on linux 58 Type "help", "copyright", "credits" or "license" for more information. 59 >>> import libtorrent 60 >>> 61 ```