Reference Docker image to run the migration script, give a GitLab CI usage example and improve Markdown syntax

Julien 2025-03-21 16:55:48 +01:00
parent 169a029ae7
commit e0b7fbd997

@ -1,12 +1,23 @@
# Qt6 migration
It's possible to make a plugin for both Qt5 and Qt6.
## Script
1. `pip install astpretty tokenize-rt`
1. Install `python3-pyqt6`, `python3-pyqt6.qtsvg`, `python3-pyqt6.qsci`
> To run this script, you need QGIS with Qt6.
1. Install Python dependencies:
```sh
pip install astpretty tokenize-rt
```
1. Install additionnal system dependencies. Typically on Debian based-images:
```sh
sudo apt install python3-pyqt6 python3-pyqt6.qtsvg python3-pyqt6.qsci
```
1. Download the [pyqt5_to_pyqt6 script](https://github.com/qgis/QGIS/blob/master/scripts/pyqt5_to_pyqt6/pyqt5_to_pyqt6.py)
1. You should check that `PyQt5` is not available in the Python environment, the script will work better
1. `pyqt5_to_pyqt6.py /path/to/plugin`
@ -14,6 +25,52 @@ It's possible to make a plugin for both Qt5 and Qt6.
This will get you in the right direction but might not do all necessary changes. Make sure to test your plugin thoroughly. Consider using an IDE with inspection that can notify you about broken imports, bad usage or non-existent references.
### Use Docker image
A bundled image with QGIS based on Qt6, including Oracle client and PDAL and the migration script is available: <https://gitlab.com/Oslandia/qgis/pyqgis-4-checker>. It can be used like this:
```sh
docker run --rm -v "$(pwd):/home/pyqgisdev/" registry.gitlab.com/oslandia/qgis/pyqgis-4-checker/pyqgis-qt-checker:latest pyqt5_to_pyqt6.py --logfile /home/pyqgisdev/pyqt6_checker.log .
```
### CI
The Docker image can also be used in a CI context to ensure compatibility along the development life-cycle.
#### GitLab CI
```yaml
stages:
- 🐍 lint
variables:
PROJECT_FOLDER: "{plugin_folder_path_within_git_repository}"
lint:qt6:
stage: 🐍 lint
image: registry.gitlab.com/oslandia/qgis/pyqgis-4-checker/pyqgis-qt-checker:latest
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- "$PROJECT_FOLDER/**/*.py"
- ".gitlab-ci.yml"
when: on_success
- when: never
script:
# just print the script help
# - pyqt5_to_pyqt6.py --help
# first, a dry run to get the log file
- pyqt5_to_pyqt6.py --dry_run --logfile pyqt6_checker.log $PROJECT_FOLDER/
# then running with edit enabled to
- pyqt5_to_pyqt6.py --logfile pyqt6_checker.log $PROJECT_FOLDER/
artifacts:
paths:
- pyqt6_checker.log
when: on_success
access: all
expire_in: "30 days"
```
## Official C++ documentation
- [Removed Modules in Qt 6.0](https://doc.qt.io/qt-6/whatsnew60.html#removed-modules-in-qt-6-0)