From 4ae41cea9a5a8d12269a6663663bedfc2a496aa4 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 9 Nov 2025 20:01:31 +0100 Subject: [PATCH 1/2] CI: use uv where possible --- .flake8 | 2 +- .github/workflows/test.yml | 64 +++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.flake8 b/.flake8 index 2b2119c4..b9b86734 100644 --- a/.flake8 +++ b/.flake8 @@ -2,5 +2,5 @@ ignore=E402,E741 builtins=buffer,unichr max-line-length = 100 -exclude = build,.git +exclude = build,.git,.venv filename = *.py,*.pyi \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 751231d4..806f0b9d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -82,29 +82,29 @@ jobs: run: | sudo apt-get update -q sudo apt-get install -y libcairo2-dev ninja-build - pipx install poetry + pipx install uv pipx install meson - poetry install + uv sync - name: Install optional test dependencies if: ${{ !contains(matrix.python-version, 'pypy') && !contains(matrix.python-version, '3.14') }} run: | - poetry install --with test-extras + uv sync --group test-extras - name: Build & Test with meson run: | - poetry run meson setup --werror _build - poetry run meson compile -C _build - poetry run meson test -v -C _build + uv run meson setup --werror _build + uv run meson compile -C _build + uv run meson test -v -C _build rm -Rf _build - - name: Build & Test with poetry + - name: Build & Test with uv run: | export CFLAGS="-Werror -coverage" export PYTHONDEVMODE=1 - poetry run pip install --no-build-isolation -e . - poetry run coverage run --branch -m pytest - poetry run coverage xml -i + uv pip install --no-build-isolation -e . + uv run coverage run --branch -m pytest + uv run coverage xml -i - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 @@ -112,14 +112,14 @@ jobs: - name: Run linters if: ${{ !contains(matrix.python-version, 'pypy') }} run: | - poetry run flake8 - poetry run mypy . + uv run flake8 + uv run mypy . - name: Build docs if: ${{ !contains(matrix.python-version, 'pypy') }} run: | - poetry install --with docs - poetry run python -m sphinx -W -a -E -b html -n docs docs/_build + uv sync --group docs + uv run python -m sphinx -W -a -E -b html -n docs docs/_build msvc: runs-on: ${{ matrix.os }} @@ -161,9 +161,9 @@ jobs: - name: Install dependencies run: | - pipx install --python "${{ steps.setup-python.outputs.python-path }}" poetry + pipx install --python "${{ steps.setup-python.outputs.python-path }}" uv pipx install --python "${{ steps.setup-python.outputs.python-path }}" meson - poetry install + uv sync - name: Build & Test with meson env: @@ -172,23 +172,23 @@ jobs: CFLAGS: "-DCAIRO_WIN32_STATIC_BUILD=1" run: | # XXX: pass python, so global python3 doesn't win - poetry run meson setup -Dpython=python --werror _build - poetry run meson compile -C _build - poetry run meson test -v -C _build + uv run meson setup -Dpython=python --werror _build + uv run meson compile -C _build + uv run meson test -v -C _build if (-not $?) { exit 1 } rm -r _build - - name: Build & Test with poetry + - name: Build & Test with uv env: PKG_CONFIG: ${{ github.workspace }}/cairo-prebuild/bin/pkgconf.exe PKG_CONFIG_PATH: ${{ github.workspace }}/cairo-prebuild/lib/pkgconfig CFLAGS: "-DCAIRO_WIN32_STATIC_BUILD=1" PYTHONDEVMODE: 1 run: | - poetry run pip install --no-build-isolation -e . - poetry run coverage run --branch -m pytest + uv pip install --no-build-isolation -e . + uv run coverage run --branch -m pytest if (-not $?) { exit 1 } - poetry run coverage xml -i + uv run coverage xml -i - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 @@ -202,23 +202,23 @@ jobs: - name: Install dependencies run: | - brew install pkg-config cairo python meson poetry ninja - poetry install + brew install pkg-config cairo python meson ninja uv + uv sync - name: Build & Test with meson run: | - poetry run meson setup --werror _build - poetry run meson compile -C _build - poetry run meson test -v -C _build + uv run meson setup --werror _build + uv run meson compile -C _build + uv run meson test -v -C _build rm -Rf _build - - name: Build & Test with poetry + - name: Build & Test with uv run: | export CFLAGS="-Werror -coverage" export PYTHONDEVMODE=1 - poetry run pip install --no-build-isolation -e . - poetry run coverage run --branch -m pytest - poetry run coverage xml -i + uv pip install --no-build-isolation -e . + uv run coverage run --branch -m pytest + uv run coverage xml -i - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 From f84d3c283bd4e4fc6e583a91efb7744b991d4c11 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 9 Nov 2025 20:21:46 +0100 Subject: [PATCH 2/2] docs: add something for uv as well and avoid using the shell plugin for poetry, to keep things simple --- docs/dev.rst | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/docs/dev.rst b/docs/dev.rst index b2218cfc..6c0b435a 100644 --- a/docs/dev.rst +++ b/docs/dev.rst @@ -3,24 +3,45 @@ Development First install the external dependencies, see :doc:`./getting_started`. +Both ``poetry`` and ``uv`` are supported for development. + +poetry +^^^^^^ + To run the tests: .. code-block:: console $ poetry install - $ poetry self add poetry-plugin-shell # once - $ poetry shell - $ pip install -e . + $ poetry run pip install -e . # change things - $ pytest + $ poetry run pytest To work on the documentation: .. code-block:: console $ poetry install --with docs - $ poetry self add poetry-plugin-shell # once - $ poetry shell - $ cd docs - $ make watch + $ poetry run make -C docs watch + # See http://127.0.0.1:8000 + +uv +^^ + +To run the tests: + +.. code-block:: console + + $ uv sync + $ uv pip install -e . + # change things + $ uv run pytest + +To work on the documentation: + +.. code-block:: console + + $ uv sync --group docs + $ uv run make -C docs watch # See http://127.0.0.1:8000 +