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/.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/.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 0a30a4b..01c9b41 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/xvfb-pytest test_packaging: runs-on: ubuntu-latest @@ -63,11 +64,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 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 diff --git a/README.md b/README.md index 7467a8e..816625b 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 +docker run --rm $(docker build --build-arg QGIS_TEST_VERSION=ltr -q -f .docker/Dockerfile .) .docker/xvfb-pytest ``` diff --git a/pyproject.toml b/pyproject.toml index a6a3345..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,21 +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"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e079f8a..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pytest