From d3c85b310df8d759bd2095dd780a607f4278d8b5 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 21 Aug 2026 11:18:57 +0200 Subject: [PATCH 1/2] [chore] Centralize development dependencies into pyproject.toml groups --- .github/workflows/docs.yml | 8 +++++--- .github/workflows/examples.yml | 7 +++---- .github/workflows/pytest.yml | 5 +++-- .github/workflows/release.yml | 13 +++++++------ .github/workflows/ruff.yml | 9 +++++++-- CONTRIBUTING.md | 8 +++++++- pyproject.toml | 9 ++++++++- 7 files changed, 40 insertions(+), 19 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9de4d7a3..f6d7711b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,6 +18,10 @@ jobs: with: python-version: "3.12" - uses: actions/checkout@v7 + - name: uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true - name: Updated documentation run: | git config --global user.email "${{ github.actor }}@users.noreply.github.com" @@ -26,9 +30,7 @@ jobs: git checkout documentation git pull git merge --allow-unrelated-histories -X theirs develop - python -m pip install --upgrade pip - pip install . - pip install pdoc + uv pip install . --group docs --system echo $(ls -l docs) pdoc --docformat numpy --math -o ./docs ./pyerrors echo $(ls -l docs) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index d32d624b..9c58ce53 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -32,6 +32,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: uv uses: astral-sh/setup-uv@v7 + with: + enable-cache: true - name: Install LaTeX run: | @@ -40,10 +42,7 @@ jobs: dvipng texlive-latex-extra texlive-fonts-recommended cm-super - name: Install - run: | - uv pip install . --system - uv pip install pytest pytest-xdist nbmake --system - uv pip install -U matplotlib!=3.7.0 --system # Exclude version 3.7.0 of matplotlib as this breaks local imports of style files. + run: uv pip install . --group examples --system # The notebooks are independent (only 07 writes to disk), so execute them in # parallel instead of serially. diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index bde82704..53b82e92 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -37,11 +37,12 @@ jobs: python-version: ${{ matrix.python-version }} - name: uv uses: astral-sh/setup-uv@v7 + with: + enable-cache: true - name: Install run: | - uv pip install . --system - uv pip install pytest pytest-cov pytest-benchmark hypothesis --system + uv pip install . --group test --system uv pip freeze --system - name: Run tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ebfe8ebf..8f68e40b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,12 +22,13 @@ jobs: with: python-version: "3.12" - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user + - name: uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + + - name: Install build tooling + run: uv pip install --group release --system - name: Build wheel and source tarball run: python3 -m build diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 2667698c..038f9927 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -14,6 +14,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: astral-sh/ruff-action@v4.1.0 + - name: uv + uses: astral-sh/setup-uv@v7 with: - src: "./pyerrors" + enable-cache: true + - name: Install lint tooling + run: uv pip install --group lint --system + - name: Run Ruff + run: ruff check pyerrors diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a51607e4..89dbdcbc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,12 @@ and create your own branch for the feature or bug fix cd pyerrors git checkout -b feature/my_feature ``` +Create a virtual environment and install the development dependencies with [uv](https://docs.astral.sh/uv/): +``` +uv venv +source .venv/bin/activate +uv pip install --editable . --group test --group examples --group lint +``` After committing your changes please send a pull requests to the `develop` branch. A guide on how to create a pull request can be found [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request). ### Documentation @@ -26,7 +32,7 @@ pytest -vv -Werror pytest --nbmake examples/*.ipynb ruff check pyerrors ``` -The tests require `pytest`, `pytest-cov`, `pytest-benchmark`, `hypothesis` and `nbmake`. To install the test dependencies one can run `pip install pyerrors[test]`. Linting is done with `ruff`, which can be installed via `pip install ruff` or run ad-hoc with `uvx ruff check pyerrors`. +Development dependencies are organized into the `test`, `examples`, `docs`, `lint`, and `release` groups in `pyproject.toml`. They are resolved against the newest compatible releases whenever they are installed. Please make sure that all tests pass for a new pull requests. To get a coverage report in html run diff --git a/pyproject.toml b/pyproject.toml index 11173bdb..507e5e89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,14 +38,21 @@ dependencies = [ "odrpack>=0.5", ] -[project.optional-dependencies] +[dependency-groups] test = [ "pytest", "pytest-cov", "pytest-benchmark", "hypothesis", +] +examples = [ + { include-group = "test" }, "nbmake", + "pytest-xdist", ] +docs = ["pdoc"] +lint = ["ruff"] +release = ["build"] [project.urls] Homepage = "https://github.com/fjosw/pyerrors" From 012f5abc4a9f2ef989e5d406542f27a39c0cb76f Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 21 Aug 2026 11:24:52 +0200 Subject: [PATCH 2/2] [fix] Add python environment to ruff workflow --- .github/workflows/ruff.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 038f9927..c1b8b7ea 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -14,6 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 + with: + python-version: "3.12" - name: uv uses: astral-sh/setup-uv@v7 with: