From 0c0ffb149577b8f346edf1d2493b906a0666cce1 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 28 Oct 2026 09:59:14 +0100 Subject: [PATCH 1/2] Manage dev and docs dependencies with uv dependency groups Move dev tools and docs requirements from optional dependencies and docs/requirements.txt into [dependency-groups], pin Ruff exactly, build the docs with uv in CI and on Read the Docs, and let Dependabot bump exact pins and upper bounds. --- .github/dependabot.yml | 11 +++++++++++ .github/workflows/docs.yml | 14 ++++---------- .github/workflows/style.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- .gitignore | 3 +++ .readthedocs.yml | 14 +++++++++----- DEVELOPING.md | 12 ++++++------ README.md | 14 ++++++++++---- docs/requirements.txt | 5 ----- pyproject.toml | 23 +++++++++++++++-------- 10 files changed, 62 insertions(+), 42 deletions(-) delete mode 100644 docs/requirements.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8ac6b8c4..3cdeda34 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,14 @@ updates: directory: "/" schedule: interval: "monthly" + groups: + actions: + patterns: ["*"] + - package-ecosystem: "uv" + directory: "/" + schedule: + interval: "monthly" + # Bump exact pins and upper bounds, but leave lower bounds alone + versioning-strategy: increase-if-necessary + cooldown: + default-days: 7 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c8f0cda2..65cb590b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,14 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-python@v7 - with: - python-version: "3.12" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r docs/requirements.txt + - uses: astral-sh/setup-uv@v10.3.2 + - name: Install Python + run: uv python install 3.12 - name: Build documentation - run: | - cd docs - make html + run: uv run --python 3.12 --only-group docs make -C docs html diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index c9a81bf9..27cadffa 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -19,5 +19,5 @@ jobs: run: uv python install 3.11 - name: Check style run: | - uv run --extra dev ruff format --check --diff . - uv run --extra dev ruff check . + uv run ruff format --check --diff . + uv run ruff check . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd3b81c4..a4674b83 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: - name: Run tests env: MPLBACKEND: Agg - run: uv run --python ${{ matrix.python-version }} --extra dev pytest + run: uv run --python ${{ matrix.python-version }} pytest # Make sure the lower bounds of the direct dependencies are actually usable test-minimum: @@ -46,4 +46,4 @@ jobs: - name: Run tests env: MPLBACKEND: Agg - run: uv run --python 3.11 --resolution lowest-direct --extra dev pytest + run: uv run --python 3.11 --resolution lowest-direct pytest diff --git a/.gitignore b/.gitignore index ebdd3e46..f3d4f7b4 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,6 @@ target/ # pyenv .python-version + +# Not committed: CI resolves dependencies fresh +uv.lock diff --git a/.readthedocs.yml b/.readthedocs.yml index 17aa4845..b254bfe4 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,12 +6,16 @@ build: os: "ubuntu-24.04" tools: python: "3.12" + jobs: + pre_create_environment: + - asdf plugin add uv + - asdf install uv latest + - asdf global uv latest + create_environment: + - uv venv "${READTHEDOCS_VIRTUALENV_PATH}" + install: + - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --only-group docs # Build from the docs/ directory with Sphinx sphinx: configuration: docs/conf.py - -# Explicitly set the version of Python and its requirements -python: - install: - - requirements: docs/requirements.txt diff --git a/DEVELOPING.md b/DEVELOPING.md index d172490e..84979b0c 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -25,12 +25,14 @@ git config blame.ignoreRevsFile .git-blame-ignore-revs This project uses [uv](https://docs.astral.sh/uv/) for package management and distribution. -Development dependencies are specified as optional dependencies, at least for now and until [development dependencies](https://docs.astral.sh/uv/concepts/dependencies/#development-dependencies) become more widely used. +Development dependencies are specified in the `dev` [dependency group](https://docs.astral.sh/uv/concepts/dependencies/#development-dependencies), which `uv run` installs automatically: ```sh -uv add --optional +uv add --dev ``` +Ruff is pinned to an exact version because new releases can change formatting and lint results. Dependabot opens monthly pull requests to bump it, along with the pinned documentation dependencies, uv-build, and the GitHub Actions. + ## Creating Distributions 1. Bump the version in [pyproject.toml](./pyproject.toml). @@ -64,12 +66,10 @@ The project's documentation is generated by [Sphinx](https://docs.readthedocs.io To manage the content on RTD, request yourself to be added to the [wfdb](https://readthedocs.org/projects/wfdb/) project. The project has already been configured to import content from the GitHub repository. Documentation for new releases should be automatically built and uploaded. See the [import guide](https://docs.readthedocs.io/en/stable/intro/import-guide.html) for more details. -There is some redundancy in specifying the Sphinx requirements between pyproject.toml and [docs/requirements.txt](./docs/requirements.txt), the latter of which is used by RTD. Make sure that the content is consistent across the two files. - -To generate the HTML content locally, install the required dependencies and run from the `docs` directory: +The documentation dependencies are specified in the `docs` dependency group in [pyproject.toml](./pyproject.toml), which is used both locally and by RTD. To generate the HTML content locally, run: ```sh -make html +uv run --only-group docs make -C docs html ``` ## Tests diff --git a/README.md b/README.md index 6d68b17f..8e1e5e42 100644 --- a/README.md +++ b/README.md @@ -27,20 +27,26 @@ The distribution is hosted on PyPI at: [https://pypi.python.org/pypi/wfdb/](http pip install wfdb ``` +Alternatively, add it to a project managed with [uv](https://docs.astral.sh/uv/): + +```sh +uv add wfdb +``` + On some less-common systems, you may need to install `libsndfile` separately. See the [soundfile installation notes](https://pypi.org/project/soundfile/) for more information. ## Development -The development version is hosted at: [https://github.com/MIT-LCP/wfdb-python](https://github.com/MIT-LCP/wfdb-python). This repository also contains demo scripts and example data. To install the development version, clone or download the repository, navigate to the base directory, and run: +The development version is hosted at: [https://github.com/MIT-LCP/wfdb-python](https://github.com/MIT-LCP/wfdb-python). This repository also contains demo scripts and example data. To set up a development environment, install [uv](https://docs.astral.sh/uv/), clone the repository, navigate to the base directory, and run: ```sh -pip install . +uv sync ``` -If you intend to make changes to the repository, you can install additional packages that are useful for development by running: +This creates a virtual environment in `.venv` containing the package and all development tools. Commands can then be run inside this environment with `uv run`, for example: ```sh -pip install ".[dev]" +uv run pytest ``` Please see the [DEVELOPING.md](https://github.com/MIT-LCP/wfdb-python/blob/main/DEVELOPING.md) document for contribution/development instructions. diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 96e61db3..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -numpydoc==1.7.0 -sphinx==7.0.0 -sphinx_rtd_theme==3.0.0 -readthedocs-sphinx-search==0.3.2 -fsspec>=2023.10.0 diff --git a/pyproject.toml b/pyproject.toml index 864bf5a1..6ef56e00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,19 +22,26 @@ dependencies = [ "aiohttp >= 3.10.11", ] -[project.optional-dependencies] -dev = [ - "pytest >= 8.0.0", - "pytest-xdist >= 3.5.0", - "ruff >= 0.13.0", - "sphinx >= 7.0.0", -] - [project.urls] homepage = "https://github.com/MIT-LCP/wfdb-python/" repository = "https://github.com/MIT-LCP/wfdb-python/" documentation = "https://wfdb.readthedocs.io/" +[dependency-groups] +dev = [ + "pytest >= 8.0.0", + "pytest-xdist >= 3.5.0", + "ruff == 0.17.3", +] +# Heavy dependencies are mocked in docs/conf.py, so the project itself is not needed +docs = [ + "fsspec >= 2023.10.0", + "numpydoc == 1.7.0", + "readthedocs-sphinx-search == 0.3.2", + "sphinx == 7.0.0", + "sphinx-rtd-theme == 3.0.0", +] + [tool.ruff] target-version = "py311" extend-exclude = ["*.ipynb"] From ccb05d16e570460e71ffb397c153e94591b5e7f9 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 28 Oct 2026 20:30:10 +0100 Subject: [PATCH 2/2] Remove unused sphinx plugins --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6ef56e00..c57ff58e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,9 +37,7 @@ dev = [ docs = [ "fsspec >= 2023.10.0", "numpydoc == 1.7.0", - "readthedocs-sphinx-search == 0.3.2", "sphinx == 7.0.0", - "sphinx-rtd-theme == 3.0.0", ] [tool.ruff]