From eb0d788dbdc54bf89c479fd82bba9e079e54c61b Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 29 Apr 2026 02:01:01 +0300 Subject: [PATCH 1/7] Switch to `uv` from `pip` --- .docker/Dockerfile | 19 ++++++++++++++----- README.md | 35 +++++++++++++++++++++++++---------- pyproject.toml | 7 +++++++ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 47757cb..3e37a23 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,14 +1,23 @@ ARG QGIS_TEST_VERSION=latest FROM qgis/qgis:${QGIS_TEST_VERSION} -RUN apt-get update \ - && apt-get install -y python3-pip \ +RUN apt update \ + && apt install -y \ + glibc-tools \ && rm -rf /var/lib/apt/lists/* -COPY ./requirements.txt /tmp/ - -RUN pip3 install -r /tmp/requirements.txt --break-system-packages +# Install uv from the official image, which is a lot faster than installing it with pip +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ ENV LANG=C.UTF-8 +# Add crashes dump to STDERR +ENV LD_PRELOAD="/lib/x86_64-linux-gnu/libSegFault.so" +ENV SEGFAULT_SIGNALS="abrt segv" +ENV LIBC_FATAL_STDERR_=1 + +COPY . /usr/src + +RUN uv venv --system-site-packages + WORKDIR /usr/src diff --git a/README.md b/README.md index 7467a8e..b05925f 100644 --- a/README.md +++ b/README.md @@ -2,28 +2,43 @@ This library facilitates packaging and synchronizing QGIS projects for use with [QField](http://www.qfield.org). -This library is the heart of the QFieldSync QGIS plugin. +This library is the heart of the QFieldSync QGIS plugin and QFieldCloud's QGIS worker container. More information can be found in the [QField documentation](https://docs.qfield.org/get-started/). -The plugin can be downloaded on the [QGIS plugin repository](https://plugins.qgis.org/plugins/qfieldsync/). +The QFieldSync plugin can be downloaded on the [QGIS plugin repository](https://plugins.qgis.org/plugins/qfieldsync/). + ## Development Improvements are welcome, feel free to fork and open a PR. -### Code style -Code style is done with [pre-commit](https://pre-commit.com). +### Getting started -``` -pip install pre-commit -# install pre-commit hook -pre-commit install +This project uses [`uv`](https://docs.astral.sh/uv/getting-started/installation/) for managing it's dependencies. + +```shell +git clone git@github.com:opengisch/libqfieldsync.git +cd libqfieldsync + +# we need to pass `system-site-packages` to use the local QGIS version +uv venv --system-site-packages + +# we use `pre-commit` for code styling, see https://pre-commit.com +uv run pre-commit install ``` ## Testing -```console -GITHUB_WORKSPACE=$PWD QGIS_TEST_VERSION=final-3_34_2 docker compose -f .docker/docker-compose.yml run qgis /usr/src/.docker/run-docker-tests.sh +Run local tests (assuming a QGIS installed on host): + +```shell +uv run pytest +``` + +If you want to test with a specific QGIS version, or you don't have QGIS installed, then: + +```shell +QGIS_TEST_VERSION=ltr docker run --rm $(docker build -q -f .docker/Dockerfile .) pytest ``` diff --git a/pyproject.toml b/pyproject.toml index a6a3345..520769c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,3 +123,10 @@ tracker = "https://github.com/opengisch/libqfieldsync/issues" [project.optional-dependencies] dev = ["pre-commit"] + +[dependency-groups] +dev = [ + "pre-commit>=2.21.0", + "pytest>=7.4.4", + "pytest-cov>=4.1.0", +] From 2346bd9a76f7b727e5814b6f362c3f46a85ff453 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 29 Apr 2026 02:02:15 +0300 Subject: [PATCH 2/7] Switch the CI to `uv` testing the `test_packaging` --- .github/workflows/continuous_integration.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 0a30a4b..a2d4d15 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -63,11 +63,11 @@ jobs: - name: Setup Python uses: actions/setup-python@v6 - - name: Install toolchain - run: pip install build + - name: Install uv with all available options + uses: astral-sh/setup-uv@v8.1.0 - - name: Package with build - run: python -m build + - name: Package with uv + run: uv build - name: Install with pip - run: pip install . + run: pip install . --break-system-packages From 68e6ee67aaa8a1e21626223a97c513d400cdee08 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 29 Apr 2026 02:19:06 +0300 Subject: [PATCH 3/7] Add `.mypy_cache` in the `.gitignore` list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f3e04df..cd3c5f5 100644 --- a/.gitignore +++ b/.gitignore @@ -160,6 +160,8 @@ crashlytics.properties crashlytics-build.properties fabric.properties +# Mypy +.mypy_cache/ # My super new category .DS_Store From 231d99f5a56c283b237c1bba264dc1e5cc2204f3 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 29 Apr 2026 02:20:42 +0300 Subject: [PATCH 4/7] Simplify the Dockerfile setup --- .docker/docker-compose.yml | 11 ----------- .github/workflows/continuous_integration.yml | 3 ++- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 .docker/docker-compose.yml diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml deleted file mode 100644 index a223ee6..0000000 --- a/.docker/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: '3' -services: - qgis: - build: - context: .. - dockerfile: ./.docker/Dockerfile - args: - QGIS_TEST_VERSION: ${QGIS_TEST_VERSION} - tty: true - volumes: - - ${GITHUB_WORKSPACE}:/usr/src diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index a2d4d15..b6d82e8 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -50,7 +50,8 @@ jobs: - name: Run tests run: | - docker compose -f .docker/docker-compose.yml run qgis /usr/src/.docker/run-docker-tests.sh + docker build -f .docker/Dockerfile --build-arg QGIS_TEST_VERSION=$QGIS_TEST_VERSION -t libqfieldsync-test . + docker run --rm libqfieldsync-test .docker/run-docker-tests.sh test_packaging: runs-on: ubuntu-latest From 572680673a6b0942fbf17c11f596ab957346eef4 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 29 Apr 2026 17:24:07 +0300 Subject: [PATCH 5/7] Remove obsolete `requirements.txt`, the deps are now in the `pyproject.toml` file --- requirements.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e079f8a..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pytest From 1029a33999bc0d511fc530f5e8cc798f91e9e0df Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 29 Apr 2026 17:24:20 +0300 Subject: [PATCH 6/7] Move project metadata to the top of `pyproject.toml` --- pyproject.toml | 55 ++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 520769c..7d5d1f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,27 @@ -[build-system] -requires = [ - "setuptools>=68.0", - "wheel", +[project] +name = "libqfieldsync" +description = "the qfieldsync library" +version = "1.0" +authors = [ + { name = "OPENGIS.ch", email = "info@opengis.ch" } ] -build-backend = "setuptools.build_meta" +requires-python = ">=3.9" -[tool.ruff] -# Support Python 3.9+. -target-version = "py39" +[project.urls] +homepage = "https://github.com/opengisch/libqfieldsync" +documentation = "https://docs.qfield.org/get-started/" +repository = "https://github.com/opengisch/libqfieldsync" +tracker = "https://github.com/opengisch/libqfieldsync/issues" + +[project.optional-dependencies] +dev = ["pre-commit"] + +[dependency-groups] +dev = [ + "pre-commit>=2.21.0", + "pytest>=7.4.4", + "pytest-cov>=4.1.0", +] [tool.ruff.lint] select = ["ALL"] @@ -105,28 +119,3 @@ exclude = [ "__pycache__", ] select = ["CLB100", "IF100"] - -[project] -name = "libqfieldsync" -description = "the qfieldsync library" -version = "1.0" -authors = [ - { name = "OPENGIS.ch", email = "info@opengis.ch" } -] -requires-python = ">=3.7" - -[project.urls] -homepage = "https://github.com/opengisch/libqfieldsync" -documentation = "https://docs.qfield.org/get-started/" -repository = "https://github.com/opengisch/libqfieldsync" -tracker = "https://github.com/opengisch/libqfieldsync/issues" - -[project.optional-dependencies] -dev = ["pre-commit"] - -[dependency-groups] -dev = [ - "pre-commit>=2.21.0", - "pytest>=7.4.4", - "pytest-cov>=4.1.0", -] From bc97a5c41e0b36b0222af0fbf6843ced633c8855 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 29 Apr 2026 17:36:30 +0300 Subject: [PATCH 7/7] Further simplify the `xvdb-pytest` script, rename it from `run-docker-tests.sh` and update README.md --- .docker/run-docker-tests.sh | 23 -------------------- .docker/xvfb-pytest | 5 +++++ .github/workflows/continuous_integration.yml | 2 +- README.md | 2 +- 4 files changed, 7 insertions(+), 25 deletions(-) delete mode 100755 .docker/run-docker-tests.sh create mode 100755 .docker/xvfb-pytest diff --git a/.docker/run-docker-tests.sh b/.docker/run-docker-tests.sh deleted file mode 100755 index be0e6bb..0000000 --- a/.docker/run-docker-tests.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -#*************************************************************************** -# ------------------- -# begin : 2017-08-24 -# git sha : :%H$ -# copyright : (C) 2017 by OPENGIS.ch -# email : info@opengis.ch -#*************************************************************************** -# -#*************************************************************************** -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU General Public License as published by * -#* the Free Software Foundation; either version 2 of the License, or * -#* (at your option) any later version. * -#* * -#*************************************************************************** - -set -e - -pushd /usr/src -xvfb-run pytest -popd diff --git a/.docker/xvfb-pytest b/.docker/xvfb-pytest new file mode 100755 index 0000000..d8b0640 --- /dev/null +++ b/.docker/xvfb-pytest @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +xvfb-run pytest diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index b6d82e8..01c9b41 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -51,7 +51,7 @@ jobs: - name: Run tests run: | docker build -f .docker/Dockerfile --build-arg QGIS_TEST_VERSION=$QGIS_TEST_VERSION -t libqfieldsync-test . - docker run --rm libqfieldsync-test .docker/run-docker-tests.sh + docker run --rm libqfieldsync-test .docker/xvfb-pytest test_packaging: runs-on: ubuntu-latest diff --git a/README.md b/README.md index b05925f..816625b 100644 --- a/README.md +++ b/README.md @@ -40,5 +40,5 @@ uv run pytest If you want to test with a specific QGIS version, or you don't have QGIS installed, then: ```shell -QGIS_TEST_VERSION=ltr docker run --rm $(docker build -q -f .docker/Dockerfile .) pytest +docker run --rm $(docker build --build-arg QGIS_TEST_VERSION=ltr -q -f .docker/Dockerfile .) .docker/xvfb-pytest ```