Setting up your development environment

This page contains instructions on how to setup your development environment to run Tribler from source.

Windows

This section contains information about setting up a Tribler development environment on Windows. Unlike Linux based systems where installing third-party libraries is often a single apt-get command, installing and configuring the necessary libraries requires more attention on Windows. Moreover, the Windows environment has different file structures. For instance, where Linux is working extensively with .so (shared object) files, Windows uses DLL files.

Introduction

In this guide, all required dependencies of Tribler will be explained. It presents how to install these dependencies. Some dependencies have to be built from source whereas other dependencies can be installed using a .msi or .exe installer. The guide targets Windows 7 or higher, 64-bit systems, however, it is probably not very hard to install 32-bit packages.

Prerequisites

Python Packages

There are some additional packages which should be installed. They can easily be installed using pip:

Running Tribler

You should now be able to run Tribler from command line. Grab a copy of the Tribler source code and navigate in a command line interface to the source code directory. Start Tribler by executing the Batch script in the tribler/src directory:

If there are any problems with the guide above, please feel free to fix any errors or create an issue so we can look into it.

MacOS

Tribler development environment setup on MacOS (10.10 to latest).

HomeBrew

This guide will outline how to setup a Tribler development environment on Mac.

PyQt5

If you wish to run the Tribler Graphical User Interface, PyQt5 should be available on the system. To install PyQt5, we first need to install Qt5, a C++ library which can be installed with Brew:

brew install python3 qt5 sip pyqt5
brew cask install qt-creator # if you want the visual designer
brew link qt5 --force # to allow access qmake from the terminal

qmake --version # test whether qt is installed correctly

Add qt@5/bin to the PATH environment variable, e.g.:

export PATH="/usr/local/opt/qt@5/bin:$PATH"

Other Packages

There are a bunch of other packages that can easily be installed using pip and brew:

brew install gmp mpfr libmpc libsodium
python3 -m pip install -r requirements.txt

Tribler

The security system on MacOS can prevent libsodium.dylib from being dynamically linked into Tribler when running Python. If this library cannot be loaded, it gives an error that libsodium could not be found. This is because the DYLD_LIBRARY_PATH cannot be set when Python starts. More information about this can be read here.

The best solution to this problem is to link or copy libsodium.dylib into the Tribler root directory.

git clone  https://github.com/Tribler/tribler.git
cd tribler
cp /usr/local/lib/libsodium.dylib ./ || cp /opt/local/lib/libsodium.dylib ./

You can now run Tribler by executing the following bash script in the src directory:

./tribler.sh

Proceed proceed to Build instructions

Help

If there are any problems with the guide above, please feel free to fix any errors or create an issue so we can look into it.

Apple Silicon

There are currently no python bindings available to install from pip. Therefore you need to build them from source.

To do this, please install openssl and boost first:

And then follow the instruction.

This instruction was checked for the following versions:

  • python 3.11

  • libtorrent 1.2.18

Linux

This section contains information about setting up a Tribler development environment on Linux systems.

Debian/Ubuntu/Mint

Install the required dependencies by executing the following command in your terminal:

sudo apt install git libssl-dev libx11-6 libgmp-dev python3 python3-minimal python3-pip python3-libtorrent python3-pyqt5 python3-pyqt5.qtsvg python3-scipy

Clone the Tribler repo:

git clone https://github.com/tribler/tribler

Install python packages:

pip3 install --upgrade -r tribler/requirements.txt

Run Tribler by executing the following commands:

tribler/src/tribler.sh  > tribler.log

Alternatively, you can run the latest stable version of Tribler by downloading and installing the .deb file from here. This option is only recommended for running Tribler and is not suitable for development.

Fedora/CentOS/RedHat

Install the required dependencies by executing the following command in your terminal:

sudo dnf install python3-devel python3-pip git

Clone the Tribler repo:

git clone https://github.com/tribler/tribler

Install python packages:

pip3 install --upgrade -r tribler/requirements.txt

Run Tribler by executing the following commands:

tribler/src/tribler.sh  > tribler.log

If there are any problems with the guide above, please feel free to fix any errors or create an issue so we can look into it.

Development guidelines

Our GUI uses QT toolkit. It can be quite tricky at times. Also, PyQt have LOTS of bugs, so be warned! For the beginner, the best way to develop QT is to just copy-paste stuff around, looking for examples in our codebase.

Do’s and don’ts of QT design

There are three “don’ts” in QT design:
  • Don’t set CSS in the code. Instead, do set it in the widget .ui-file

  • Don’t set it on individual widgets unless absolutely neccesary. Instead, do set it on the highest parent widget, which is the main Tribler window in our case. CSS will do the rest

  • Don’t copy-paste the stylesheets. Instead, do try to move as much CSS as possible to the highest possible parent widget and subclass the widgets in Qt Creator.

Do’s:
  • Do connect signals using Tribler connect() procedure. It is much safer and easy this way.