Get Involved/development/Set up a development environment: Difference between revisions

From KDE Community Wiki
m (→‎Set up kde-builder: fix subsections level for distro specific sections)
(→‎openSUSE Tumbleweed: Add instructions to install dependencies for kde-builder and a 3rd party a package of kde-builder)
Line 74: Line 74:
=== openSUSE Tumbleweed ===
=== openSUSE Tumbleweed ===


{{ic|sudo zypper mr -e $(zypper repos {{!}} awk '/source/{print $5}')}}
* Option 1: Installation of the dependencies for kde-builder only:
  {{ic|sudo zypper install python312-dbus-python python312-promises python312-overrides python312-setproctitle}}
 
* Option 2: Installation of kde-builder from a 3rd party package (WIP):
  {{ic|sudo zypper ar https://download.opensuse.org/repositories/home:/enmo/openSUSE_Tumbleweed/home:enmo.repo}}
  {{ic|sudo zypper in python312-kde-builder}}


== Installing distro dependencies ==
== Installing distro dependencies ==

Revision as of 14:06, 19 February 2024

Information

Everything on this page only needs to be done once. Once you've done it, your development environment is set up and you can use it to submit patches and develop KDE Software!


Note

This procedure will set up kde-builder.


Source code for KDE software lives on KDE Invent. But before you can work on it, you'll need to set up a development environment: a set of tools that allows you to access and edit the source code, compile it into a form that the computer can run, and deploy it to a safe location. We will now go through the process of setting one up. To accomplish these tasks, you will need to enter commands using a terminal program, such as KDE's Konsole.

If you're not familiar with the command line interface, you can find tutorials here. However, advanced command-line skills are not required, and you will learn what you need along the way!

Install basic tools

First you will need to use your operating system's package manager to install some basic tools:

  • KDE Neon/Kubuntu/Ubuntu/Debian: sudo apt update && sudo apt install git
  • Arch/Manjaro: sudo pacman -S git
  • Fedora: sudo dnf install git perl perl-IPC-Cmd perl-MD5 perl-FindBin
  • openSUSE Tumbleweed: sudo zypper refresh && sudo zypper install git

Configure Git

We need to set your authorship information properly so that any changes you make can be properly attributed to you:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

The name you provide should be your actual name, not your KDE Identity username or a pseudonym. And the email address must be the same as the email address used for your https://bugs.kde.org account. If they don't match, then the BUG: and FEATURE: keywords won't work (see this page for more information).

Next, in order to authenticate yourself when pushing code changes, you need to add an ssh key to your GitLab profile as described here.

Install kde-builder

kde-builder is the official KDE meta-build-system tool. It is used to manage the building of many software repositories in an automated fashion. Its primary purpose is to manage dependencies. Every software has dependencies: other pieces of software that provide lower-level functionality they rely on. In order to compile any piece of software, its dependencies must be available.

Information

kde-builder is a successor of kdesrc-build. It has the same syntax and behavior, so the wiki instructions you found here can be applied directly, except the fact that you change the executable name. The only difference is the installation procedure.


KDE software has two types of dependencies: dependencies on other pieces of KDE software, and dependencies on 3rd-party software. For example, the KDE application KCalc depends on more than 20 other KDE git repositories as well as the Qt toolkit.

Some Linux distributions do not provide development packages for KDE Frameworks and of other libraries that are up-to-date enough for us to build from the "main" branch of the KDE git repositories (the branch where the development of the next software versions takes place), so we use kde-builder to compile them ourselves. The goal is to avoid using KDE binaries, KDE libraries and other KDE files from the operating system where possible (in the Linux case, these files reside in the /usr directory).

Generic installation instructions

Install kde-builder: https://invent.kde.org/ashark/kde-builder#installation

Install kdesrc-build: https://invent.kde.org/sdk/kdesrc-build#install-kdesrc-build

Arch Linux

KDE neon, Debian, Ubuntu, Kubuntu

pipenv package seems to be broken on Ubuntu 22.04 LTS (the system that KDE Neon is based on), see https://bugs.launchpad.net/ubuntu/+source/pipenv/+bug/1970106. Installing pipenv through pip made it work.

And Ubuntu doesn't ship Python 3.12 on jammy, you need to get it from some deadsnakes ppa. The installation steps looked like this

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12-dev
pip install pipenv
export PATH=~/.local/bin:"$PATH"
pipenv install

You need some source repos enabled before you can install the development packages you need. Do that now, if needed:

sudo sed -i '/^# deb-src/s/^# //' /etc/apt/sources.list && sudo apt update. Look at the content of the file /etc/apt/sources.list, e.g. cat /etc/apt/sources.list. Each line that starts with "deb " should be followed by an identical line but the line should start with "deb-src ", e.g.:

deb http://us.archive.ubuntu.com/ubuntu/ noble main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ noble main restricted

openSUSE Tumbleweed

  • Option 1: Installation of the dependencies for kde-builder only:
 sudo zypper install python312-dbus-python python312-promises python312-overrides python312-setproctitle
  • Option 2: Installation of kde-builder from a 3rd party package (WIP):
 sudo zypper ar https://download.opensuse.org/repositories/home:/enmo/openSUSE_Tumbleweed/home:enmo.repo
 sudo zypper in python312-kde-builder

Installing distro dependencies

For kde-builder:

kde-builder --install-distro-packages

For kdesrc-build:

kdesrc-build --install-distro-packages-perl --install-distro-packages

The step above installs the distribution packages that are needed to build all of the KDE Frameworks.

For more details see Get_Involved/development/Install_the_dependencies.

Handling dependencies after setup

The command above installs 3rd-party dependencies once run. But they can change over time, and kdesrc-build/kde-builder is currently not smart enough to track those changes and apply them later; see https://invent.kde.org/sdk/kdesrc-build/-/issues/9 for more details.

So after setup, if you want to ensure you do not miss some 3rd party dependency do the following:

  • Update the kde-builder/kdesrc-build itself, to ensure you are using latest version.
  • Invoke installation command again: kde-builder --install-distro-packages or kdesrc-build --install-distro-packages.

Note that for kdesrc-build you do not need to care about --install-distro-packages-perl most of the times, because it is considered as freezed.

If you still find any external dependencies needed to build KDE software that were not installed with kde-builder --install-distro-packages, then please send a merge request to the repo-metadata repository to include the needed packages in the list.

Prepare sources location

Create a new directory for all the KDE source code, build files, and installed files. You will need many gigabytes of free disk space. Budget 50 GB for KDE Frameworks + KDE Plasma, and 10-30 GB more for some apps as well.

In default configuration, the ~/kde directory is used. The default source-dir is ~/kde/src, default build-dir is ~/kde/build and default install-dir is ~/kde/usr.

Set up Qt

Qt is the fundamental framework that is needed for pretty much all KDE development. A recent enough version of Qt 6, currently Qt version greater or equal to 6.6, is required to proceed.

The initial setup of kde-builder should have installed the required Qt6 packages for you already.

If your Linux distribution does not provide recent versions of qt packages, it may be a good time to switch distros to something better suited for building KDE software from source code either as the primary operating system or in a virtual machine.

Disable indexing for your development environment

You'll want to disable indexing for your development-related git repos and the files they will build and install. Add the directory ~/kde to the exclusions list in System Settings > Workspace > Search > File Search, like so:

Next Steps

Reboot your computer and log back in so the package changes take effect on your user account. Once that's done, your development environment is set up and ready to build software. Time to learn how to use kde-builder tool to build software from source code!