diff --git a/.cruft.json b/.cruft.json
index c6e4480..b2dbf98 100644
--- a/.cruft.json
+++ b/.cruft.json
@@ -1,7 +1,7 @@
{
"template": "https://github.com/scverse/cookiecutter-scverse",
- "commit": "5d44c58df427f884585ae9772cae81f1b6638f80",
- "checkout": null,
+ "commit": "6ff5b92b5d44ea6d8a88e47538475718d467db95",
+ "checkout": "v0.7.0",
"context": {
"cookiecutter": {
"project_name": "dvp-io",
@@ -18,12 +18,25 @@
".github/workflows/test.yaml",
"docs/_templates/autosummary/**.rst"
],
+ "_exclude_on_template_update": [
+ "CHANGELOG.md",
+ "LICENSE",
+ "README.md",
+ "docs/api.md",
+ "docs/index.md",
+ "docs/notebooks/example.ipynb",
+ "docs/references.bib",
+ "docs/references.md",
+ "src/**",
+ "tests/**"
+ ],
"_render_devdocs": false,
"_jinja2_env_vars": {
"lstrip_blocks": true,
"trim_blocks": true
},
- "_template": "https://github.com/scverse/cookiecutter-scverse"
+ "_template": "https://github.com/scverse/cookiecutter-scverse",
+ "_commit": "6ff5b92b5d44ea6d8a88e47538475718d467db95"
}
},
"directory": null
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index a5a20e6..6104b9e 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -1,6 +1,6 @@
name: Bug report
description: Report something that is broken or incorrect
-labels: bug
+type: Bug
body:
- type: markdown
attributes:
@@ -9,8 +9,7 @@ body:
detailing how to provide the necessary information for us to reproduce your bug. In brief:
* Please provide exact steps how to reproduce the bug in a clean Python environment.
* In case it's not clear what's causing this bug, please provide the data or the data generation procedure.
- * Sometimes it is not possible to share the data, but usually it is possible to replicate problems on publicly
- available datasets or to share a subset of your data.
+ * Replicate problems on public datasets or share data subsets when full sharing isn't possible.
- type: textarea
id: report
@@ -23,67 +22,72 @@ body:
- type: textarea
id: versions
attributes:
- label: Version information
+ label: Versions
description: |
- Please paste below the output of
+ Which version of packages.
+
+ Please install `session-info2`, run the following command in a notebook,
+ click the “Copy as Markdown” button, then paste the results into the text box below.
+
+ ```python
+ In[1]: import session_info2; session_info2.session_info(dependencies=True)
+ ```
+
+ Alternatively, run this in a console:
```python
- import session_info
- session_info.show(html=False, dependencies=True)
+ >>> import session_info2; print(session_info2.session_info(dependencies=True)._repr_mimebundle_()["text/markdown"])
```
+ render: python
placeholder: |
- -----
- anndata 0.8.0rc2.dev27+ge524389
- session_info 1.0.0
- -----
- asttokens NA
- awkward 1.8.0
- backcall 0.2.0
- cython_runtime NA
- dateutil 2.8.2
- debugpy 1.6.0
- decorator 5.1.1
- entrypoints 0.4
- executing 0.8.3
- h5py 3.7.0
- ipykernel 6.15.0
- jedi 0.18.1
- mpl_toolkits NA
- natsort 8.1.0
- numpy 1.22.4
- packaging 21.3
- pandas 1.4.2
- parso 0.8.3
- pexpect 4.8.0
- pickleshare 0.7.5
- pkg_resources NA
- prompt_toolkit 3.0.29
- psutil 5.9.1
- ptyprocess 0.7.0
- pure_eval 0.2.2
- pydev_ipython NA
- pydevconsole NA
- pydevd 2.8.0
- pydevd_file_utils NA
- pydevd_plugins NA
- pydevd_tracing NA
- pygments 2.12.0
- pytz 2022.1
- scipy 1.8.1
- setuptools 62.5.0
- setuptools_scm NA
- six 1.16.0
- stack_data 0.3.0
- tornado 6.1
- traitlets 5.3.0
- wcwidth 0.2.5
- zmq 23.1.0
- -----
- IPython 8.4.0
- jupyter_client 7.3.4
- jupyter_core 4.10.0
- -----
- Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) [GCC 10.3.0]
- Linux-5.18.6-arch1-1-x86_64-with-glibc2.35
- -----
- Session information updated at 2022-07-07 17:55
+ anndata 0.11.3
+ ---- ----
+ charset-normalizer 3.4.1
+ coverage 7.7.0
+ psutil 7.0.0
+ dask 2024.7.1
+ jaraco.context 5.3.0
+ numcodecs 0.15.1
+ jaraco.functools 4.0.1
+ Jinja2 3.1.6
+ sphinxcontrib-jsmath 1.0.1
+ sphinxcontrib-htmlhelp 2.1.0
+ toolz 1.0.0
+ session-info2 0.1.2
+ PyYAML 6.0.2
+ llvmlite 0.44.0
+ scipy 1.15.2
+ pandas 2.2.3
+ sphinxcontrib-devhelp 2.0.0
+ h5py 3.13.0
+ tblib 3.0.0
+ setuptools-scm 8.2.0
+ more-itertools 10.3.0
+ msgpack 1.1.0
+ sparse 0.15.5
+ wrapt 1.17.2
+ jaraco.collections 5.1.0
+ numba 0.61.0
+ pyarrow 19.0.1
+ pytz 2025.1
+ MarkupSafe 3.0.2
+ crc32c 2.7.1
+ sphinxcontrib-qthelp 2.0.0
+ sphinxcontrib-serializinghtml 2.0.0
+ zarr 2.18.4
+ asciitree 0.3.3
+ six 1.17.0
+ sphinxcontrib-applehelp 2.0.0
+ numpy 2.1.3
+ cloudpickle 3.1.1
+ sphinxcontrib-bibtex 2.6.3
+ natsort 8.4.0
+ jaraco.text 3.12.1
+ setuptools 76.1.0
+ Deprecated 1.2.18
+ packaging 24.2
+ python-dateutil 2.9.0.post0
+ ---- ----
+ Python 3.13.2 | packaged by conda-forge | (main, Feb 17 2025, 14:10:22) [GCC 13.3.0]
+ OS Linux-6.11.0-109019-tuxedo-x86_64-with-glibc2.39
+ Updated 2025-03-18 15:47
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
index e237f0a..3bc6540 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -1,6 +1,6 @@
name: Feature request
description: Propose a new feature for dvp-io
-labels: enhancement
+type: Enhancement
body:
- type: textarea
id: description
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index bfa2cf0..c6ecc2f 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -14,16 +14,13 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - name: Set up Python 3.12
- uses: actions/setup-python@v5
+ - uses: actions/checkout@v5
with:
- python-version: "3.12"
- cache: "pip"
- cache-dependency-path: "**/pyproject.toml"
- - name: Install build dependencies
- run: python -m pip install --upgrade pip wheel twine build
+ filter: blob:none
+ fetch-depth: 0
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
- name: Build package
- run: python -m build
+ run: uv build
- name: Check package
- run: twine check --strict dist/*.whl
+ run: uvx twine check --strict dist/*.whl
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 22274a8..d66ed35 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -15,15 +15,13 @@ jobs:
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v5
with:
filter: blob:none
fetch-depth: 0
- - uses: actions/setup-python@v5
- with:
- python-version: "3.x"
- cache: "pip"
- - run: pip install build
- - run: python -m build
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
+ - name: Build package
+ run: uv build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 841bd7c..6bf473b 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -13,55 +13,91 @@ concurrency:
cancel-in-progress: true
jobs:
+ # Get the test environment from hatch as defined in pyproject.toml.
+ # This ensures that the pyproject.toml is the single point of truth for test definitions and the same tests are
+ # run locally and on continuous integration.
+ # Check [[tool.hatch.envs.hatch-test.matrix]] in pyproject.toml and https://hatch.pypa.io/latest/environment/ for
+ # more details.
+ get-environments:
+ runs-on: ubuntu-latest
+ outputs:
+ envs: ${{ steps.get-envs.outputs.envs }}
+ steps:
+ - uses: actions/checkout@v5
+ with:
+ filter: blob:none
+ fetch-depth: 0
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
+ - name: Get test environments
+ id: get-envs
+ run: |
+ ENVS_JSON=$(uvx hatch env show --json | jq -c 'to_entries
+ | map(
+ select(.key | startswith("hatch-test"))
+ | {
+ name: .key,
+ label: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
+ python: .value.python
+ }
+ )')
+ echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
+
+ # Run tests through hatch. Spawns a separate runner for each environment defined in the hatch matrix obtained above.
test:
- runs-on: ${{ matrix.os }}
- defaults:
- run:
- shell: bash -e {0} # -e to fail on error
+ needs: get-environments
+ permissions:
+ id-token: write # for codecov OIDC
strategy:
fail-fast: false
matrix:
- include:
- - os: ubuntu-latest
- python: "3.10"
- - os: ubuntu-latest
- python: "3.12"
- - os: ubuntu-latest
- python: "3.12"
- pip-flags: "--pre"
- name: PRE-RELEASE DEPENDENCIES
-
- name: ${{ matrix.name }} Python ${{ matrix.python }}
+ os: [ubuntu-latest]
+ env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
- env:
- OS: ${{ matrix.os }}
- PYTHON: ${{ matrix.python }}
+ name: ${{ matrix.env.label }}
+ runs-on: ${{ matrix.os }}
+ continue-on-error: ${{ contains(matrix.env.name, 'pre') }} # make "all-green" pass even if pre-release job fails
steps:
- - uses: actions/checkout@v4
- - name: Set up Python ${{ matrix.python }}
- uses: actions/setup-python@v5
+ - uses: actions/checkout@v5
with:
- python-version: ${{ matrix.python }}
- cache: "pip"
- cache-dependency-path: "**/pyproject.toml"
-
- - name: Install test dependencies
- run: |
- python -m pip install --upgrade pip wheel
- - name: Install dependencies
- run: |
- pip install ${{ matrix.pip-flags }} ".[dev,test]"
- - name: Test
+ filter: blob:none
+ fetch-depth: 0
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
+ with:
+ python-version: ${{ matrix.env.python }}
+ - name: create hatch environment
+ run: uvx hatch env create ${{ matrix.env.name }}
+ - name: run tests using hatch
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
+ run: uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes -n auto
+ - name: generate coverage report
run: |
- coverage run -m pytest -v --color=yes
- - name: Report coverage
- run: |
- coverage report
+ # See https://coverage.readthedocs.io/en/latest/config.html#run-patch
+ test -f .coverage || uvx hatch run ${{ matrix.env.name }}:cov-combine
+ uvx hatch run ${{ matrix.env.name }}:cov-report # report visibly
+ uvx hatch run ${{ matrix.env.name }}:coverage xml # create report for upload
- name: Upload coverage
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v5
+ with:
+ fail_ci_if_error: true
+ use_oidc: true
+
+ # Check that all tests defined above pass. This makes it easy to set a single "required" test in branch
+ # protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why.
+ check:
+ name: Tests pass in all hatch environments
+ if: always()
+ needs:
+ - get-environments
+ - test
+ runs-on: ubuntu-latest
+ steps:
+ - uses: re-actors/alls-green@release/v1
+ with:
+ jobs: ${{ toJSON(needs) }}
diff --git a/.gitignore b/.gitignore
index 31e10b3..bd24e4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ __pycache__/
# Tests and coverage
/data/
/node_modules/
+/.coverage*
# docs
/docs/generated/
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 728dc5f..27d8a95 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -6,24 +6,25 @@ default_stages:
- pre-push
minimum_pre_commit_version: 2.16.0
repos:
- - repo: https://github.com/pre-commit/mirrors-prettier
- rev: v4.0.0-alpha.8
+ - repo: https://github.com/biomejs/pre-commit
+ rev: v2.3.10
hooks:
- - id: prettier
+ - id: biome-format
+ exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually.
- repo: https://github.com/tox-dev/pyproject-fmt
- rev: v2.5.0
+ rev: v2.11.1
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.8.3
+ rev: v0.14.10
hooks:
- - id: ruff
+ - id: ruff-check
types_or: [python, pyi, jupyter]
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v5.0.0
+ rev: v6.0.0
hooks:
- id: detect-private-key
- id: check-ast
@@ -35,12 +36,3 @@ repos:
# Check that there are no merge conflicts (could be generated by template sync)
- id: check-merge-conflict
args: [--assume-in-merge]
- - repo: local
- hooks:
- - id: forbid-to-commit
- name: Don't commit rej files
- entry: |
- Cannot commit .rej files. These indicate merge conflicts that arise during automated template updates.
- Fix the merge conflicts manually and remove the .rej files.
- language: fail
- files: '.*\.rej$'
diff --git a/.prettierrc.yaml b/.prettierrc.yaml
deleted file mode 100644
index 9aaffcb..0000000
--- a/.prettierrc.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-overrides:
- # JSON with comments and trailing commas
- - files: .vscode/*.json
- options:
- parser: json5
- quoteProps: preserve
- singleQuote: false
diff --git a/.readthedocs.yaml b/.readthedocs.yaml
index 69897c3..6c28477 100644
--- a/.readthedocs.yaml
+++ b/.readthedocs.yaml
@@ -1,16 +1,16 @@
# https://docs.readthedocs.io/en/stable/config-file/v2.html
version: 2
build:
- os: ubuntu-20.04
+ os: ubuntu-24.04
tools:
- python: "3.10"
-sphinx:
- configuration: docs/conf.py
- # disable this for more lenient docs builds
- fail_on_warning: true
-python:
- install:
- - method: pip
- path: .
- extra_requirements:
- - doc
+ python: "3.13"
+ nodejs: latest
+ jobs:
+ create_environment:
+ - asdf plugin add uv
+ - asdf install uv latest
+ - asdf global uv latest
+ build:
+ html:
+ - uvx hatch run docs:build
+ - mv docs/_build $READTHEDOCS_OUTPUT
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index a6fa580..caaeb4f 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -13,6 +13,6 @@
// Linting and formatting
"editorconfig.editorconfig",
"charliermarsh.ruff",
- "esbenp.prettier-vscode",
+ "biomejs.biome",
],
}
diff --git a/.vscode/settings.json b/.vscode/settings.json
index b6715d6..e034b91 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,5 +1,5 @@
{
- "[python][jsonc][yaml]": {
+ "[python][json][jsonc]": {
"editor.formatOnSave": true,
},
"[python]": {
@@ -9,8 +9,8 @@
"source.organizeImports": "always",
},
},
- "[jsonc][yaml]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "[json][jsonc]": {
+ "editor.defaultFormatter": "biomejs.biome",
},
"python.analysis.typeCheckingMode": "basic",
"python.testing.pytestEnabled": true,
diff --git a/biome.jsonc b/biome.jsonc
new file mode 100644
index 0000000..9f8f220
--- /dev/null
+++ b/biome.jsonc
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
+ "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
+ "formatter": { "useEditorconfig": true },
+ "overrides": [
+ {
+ "includes": ["./.vscode/*.json", "**/*.jsonc"],
+ "json": {
+ "formatter": { "trailingCommas": "all" },
+ "parser": {
+ "allowComments": true,
+ "allowTrailingCommas": true,
+ },
+ },
+ },
+ ],
+}
diff --git a/docs/Makefile b/docs/Makefile
deleted file mode 100644
index d4bb2cb..0000000
--- a/docs/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Minimal makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line, and also
-# from the environment for the first two.
-SPHINXOPTS ?=
-SPHINXBUILD ?= sphinx-build
-SOURCEDIR = .
-BUILDDIR = _build
-
-# Put it first so that "make" without argument is like "make help".
-help:
- @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-
-.PHONY: help Makefile
-
-# Catch-all target: route all unknown targets to Sphinx using the new
-# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
-%: Makefile
- @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
diff --git a/docs/conf.py b/docs/conf.py
index 8019710..4142c95 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -5,11 +5,14 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
+import shutil
import sys
from datetime import datetime
from importlib.metadata import metadata
from pathlib import Path
+from sphinxcontrib import katex
+
HERE = Path(__file__).parent
sys.path.insert(0, str(HERE / "extensions"))
@@ -19,7 +22,7 @@
# NOTE: If you installed your project in editable mode, this might be stale.
# If this is the case, reinstall it to refresh the metadata
info = metadata("dvp-io")
-project_name = info["Name"]
+project = info["Name"]
author = info["Author"]
copyright = f"{datetime.now():%Y}, {author}."
version = info["Version"]
@@ -37,7 +40,7 @@
html_context = {
"display_github": True, # Integrate GitHub
"github_user": "lucas-diedrich",
- "github_repo": project_name,
+ "github_repo": project,
"github_version": "main",
"conf_py_path": "/docs/",
}
@@ -54,9 +57,9 @@
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinxcontrib.bibtex",
+ "sphinxcontrib.katex",
"sphinx_autodoc_typehints",
"sphinx_tabs.tabs",
- "sphinx.ext.mathjax",
"IPython.sphinxext.ipython_console_highlighting",
"sphinxext.opengraph",
*[p.stem for p in (HERE / "extensions").glob("*.py")],
@@ -92,7 +95,8 @@
}
intersphinx_mapping = {
- "python": ("https://docs.python.org/3", None),
+ # TODO: replace `3.13` with `3` once ReadTheDocs supports building with Python 3.14
+ "python": ("https://docs.python.org/3.13", None),
"anndata": ("https://anndata.readthedocs.io/en/stable/", None),
"scanpy": ("https://scanpy.readthedocs.io/en/stable/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
@@ -113,7 +117,7 @@
html_static_path = ["_static"]
html_css_files = ["css/custom.css"]
-html_title = project_name
+html_title = project
html_theme_options = {
"repository_url": repository_url,
@@ -123,6 +127,7 @@
}
pygments_style = "default"
+katex_prerender = shutil.which(katex.NODEJS_BINARY) is not None
nitpick_ignore = [
# If building the documentation fails because of a missing link that is outside your control,
diff --git a/docs/contributing.md b/docs/contributing.md
index 21ab77a..b172fd1 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -1,14 +1,33 @@
# Contributing guide
-Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this project, too.
-This document will not reproduce the entire content from there.
-Instead, it aims at summarizing the most important information to get you started on contributing.
-
+This document aims at summarizing the most important information for getting you started on contributing to this project.
We assume that you are already familiar with git and with making pull requests on GitHub.
-If not, please refer to the [scanpy developer guide][].
+For more extensive tutorials, that also cover the absolute basics,
+please refer to other resources such as the [pyopensci tutorials][],
+the [scientific Python tutorials][], or the [scanpy developer guide][].
+
+[pyopensci tutorials]: https://www.pyopensci.org/learn.html
+[scientific Python tutorials]: https://learn.scientific-python.org/development/tutorials/
[scanpy developer guide]: https://scanpy.readthedocs.io/en/latest/dev/index.html
+:::{tip} The *hatch* project manager
+
+We highly recommend to familiarize yourself with [`hatch`][hatch].
+Hatch is a Python project manager that
+
+- manages virtual environments, separately for development, testing and building the documentation.
+ Separating the environments is useful to avoid dependency conflicts.
+- allows to run tests locally in different environments (e.g. different python versions)
+- allows to run tasks defined in `pyproject.toml`, e.g. to build documentation.
+
+While the project is setup with `hatch` in mind,
+it is still possible to use different tools to manage dependencies, such as `uv` or `pip`.
+
+:::
+
+[hatch]: https://hatch.pypa.io/latest/
+
## Installing dev dependencies
In addition to the packages needed to _use_ this package,
@@ -16,29 +35,103 @@ you need additional python packages to [run tests](#writing-tests) and [build th
:::::{tabs}
::::{group-tab} Hatch
-The easiest way is to get familiar with [hatch environments][], with which these tasks are simply:
+
+On the command line, you typically interact with hatch through its command line interface (CLI).
+Running one of the following commands will automatically resolve the environments for testing and
+building the documentation in the background:
```bash
hatch test # defined in the table [tool.hatch.envs.hatch-test] in pyproject.toml
hatch run docs:build # defined in the table [tool.hatch.envs.docs]
```
+When using an IDE such as VS Code,
+you’ll have to point the editor at the paths to the virtual environments manually.
+The environment you typically want to use as your main development environment is the `hatch-test`
+environment with the latest Python version.
+
+To get a list of all environments for your projects, run
+
+```bash
+hatch env show -i
+```
+
+This will list “Standalone” environments and a table of “Matrix” environments like the following:
+
+```
++------------+---------+--------------------------+----------+---------------------------------+-------------+
+| Name | Type | Envs | Features | Dependencies | Scripts |
++------------+---------+--------------------------+----------+---------------------------------+-------------+
+| hatch-test | virtual | hatch-test.py3.11-stable | dev | coverage-enable-subprocess==1.0 | cov-combine |
+| | | hatch-test.py3.14-stable | test | coverage[toml]~=7.4 | cov-report |
+| | | hatch-test.py3.14-pre | | pytest-mock~=3.12 | run |
+| | | | | pytest-randomly~=3.15 | run-cov |
+| | | | | pytest-rerunfailures~=14.0 | |
+| | | | | pytest-xdist[psutil]~=3.5 | |
+| | | | | pytest~=8.1 | |
++------------+---------+--------------------------+----------+---------------------------------+-------------+
+```
+
+From the `Envs` column, select the environment name you want to use for development.
+In this example, it would be `hatch-test.py3.14-stable`.
+
+Next, create the environment with
+
+```bash
+hatch env create hatch-test.py3.14-stable
+```
+
+Then, obtain the path to the environment using
+
+```bash
+hatch env find hatch-test.py3.14-stable
+```
+
+In case you are using VScode, now open the command palette (Ctrl+Shift+P) and search for `Python: Select Interpreter`.
+Choose `Enter Interpreter Path` and paste the path to the virtual environment from above.
+
+In this future, this may become easier through a hatch vscode extension.
+
+::::
+
+::::{group-tab} uv
+
+A popular choice for managing virtual environments is [uv][].
+The main disadvantage compared to hatch is that it supports only a single environment per project at a time,
+which requires you to mix the dependencies for running tests and building docs.
+This can have undesired side-effects,
+such as requiring to install a lower version of a library your project depends on,
+only because an outdated sphinx plugin pins an older version.
+
+To initalize a virtual environment in the `.venv` directory of your project, simply run
+
+```bash
+uv sync --all-extras
+```
+
+The `.venv` directory is typically automatically discovered by IDEs such as VS Code.
+
::::
::::{group-tab} Pip
-If you prefer managing environments manually, you can use `pip`:
+
+Pip is nowadays mostly superseded by environment manager such as [hatch][].
+However, for the sake of completeness, and since it’s ubiquitously available,
+we describe how you can manage environments manually using `pip`:
```bash
-cd dvp-io
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,test,doc]"
```
+The `.venv` directory is typically automatically discovered by IDEs such as VS Code.
+
::::
:::::
[hatch environments]: https://hatch.pypa.io/latest/tutorials/environment/basic-usage/
+[uv]: https://docs.astral.sh/uv/
## Code-style
@@ -55,7 +148,7 @@ in the root of the repository.
Pre-commit will automatically download all dependencies when it is run for the first time.
Alternatively, you can rely on the [pre-commit.ci][] service enabled on GitHub.
-If you didn't run `pre-commit` before pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message.
+If you didn’t run `pre-commit` before pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message.
If pre-commit.ci added a commit on a branch you still have been working on locally, simply use
@@ -67,13 +160,12 @@ to integrate the changes into yours.
While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage.
Finally, most editors have an _autoformat on save_ feature.
-Consider enabling this option for [ruff][ruff-editors] and [prettier][prettier-editors].
+Consider enabling this option for [ruff][ruff-editors] and [biome][biome-editors].
[pre-commit]: https://pre-commit.com/
[pre-commit.ci]: https://pre-commit.ci/
[ruff-editors]: https://docs.astral.sh/ruff/integrations/
-
-[prettier-editors]: https://prettier.io/docs/en/editors.html
+[biome-editors]: https://biomejs.dev/guides/integrate-in-editor/
(writing-tests)=
@@ -103,6 +195,14 @@ hatch test --all # test with all supported Python versions
::::
+::::{group-tab} uv
+
+```bash
+uv run pytest
+```
+
+::::
+
::::{group-tab} Pip
```bash
@@ -119,12 +219,17 @@ in the root of the repository.
### Continuous integration
-Continuous integration will automatically run the tests on all pull requests and test
+Continuous integration via GitHub actions will automatically run the tests on all pull requests and test
against the minimum and maximum supported Python version.
-Additionally, there's a CI job that tests against pre-releases of all dependencies (if there are any).
+Additionally, there’s a CI job that tests against pre-releases of all dependencies (if there are any).
The purpose of this check is to detect incompatibilities of new package versions early on and
-gives you time to fix the issue or reach out to the developers of the dependency before the package is released to a wider audience.
+gives you time to fix the issue or reach out to the developers of the dependency before the package
+is released to a wider audience.
+
+The CI job is defined in `.github/workflows/test.yaml`,
+however the single point of truth for CI jobs is the Hatch test matrix defined in `pyproject.toml`.
+This means that local testing via hatch and remote testing on CI tests against the same python versions and uses the same environments.
## Publishing a release
@@ -155,11 +260,11 @@ This will automatically create a git tag and trigger a Github workflow that crea
Please write documentation for new or changed features and use-cases.
This project uses [sphinx][] with the following features:
-- The [myst][] extension allows to write documentation in markdown/Markedly Structured Text
-- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
-- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
-- [sphinx-autodoc-typehints][], to automatically reference annotated input and output types
-- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
+- The [myst][] extension allows to write documentation in markdown/Markedly Structured Text
+- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
+- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
+- [sphinx-autodoc-typehints][], to automatically reference annotated input and output types
+- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
See scanpy’s {doc}`scanpy:dev/documentation` for more information on how to write your own.
@@ -183,14 +288,14 @@ please check out [this feature request][issue-render-notebooks] in the `cookiecu
#### Hints
-- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`.
- Only if you do so can sphinx automatically create a link to the external documentation.
-- If building the documentation fails because of a missing link that is outside your control,
- you can add an entry to the `nitpick_ignore` list in `docs/conf.py`
+- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`.
+ Only if you do so can sphinx automatically create a link to the external documentation.
+- If building the documentation fails because of a missing link that is outside your control,
+ you can add an entry to the `nitpick_ignore` list in `docs/conf.py`
(docs-building)=
-#### Building the docs locally
+### Building the docs locally
:::::{tabs}
::::{group-tab} Hatch
@@ -202,12 +307,22 @@ hatch run docs:open
::::
+::::{group-tab} uv
+
+```bash
+cd docs
+uv run sphinx-build -M html . _build -W
+(xdg-)open _build/html/index.html
+```
+
+::::
+
::::{group-tab} Pip
```bash
source .venv/bin/activate
cd docs
-make html
+sphinx-build -M html . _build -W
(xdg-)open _build/html/index.html
```
diff --git a/docs/extensions/typed_returns.py b/docs/extensions/typed_returns.py
index 1135204..0fbffef 100644
--- a/docs/extensions/typed_returns.py
+++ b/docs/extensions/typed_returns.py
@@ -12,7 +12,7 @@
def _process_return(lines: Iterable[str]) -> Generator[str, None, None]:
for line in lines:
if m := re.fullmatch(r"(?P\w+)\s+:\s+(?P[\w.]+)", line):
- yield f'-{m["param"]} (:class:`~{m["type"]}`)'
+ yield f"-{m['param']} (:class:`~{m['type']}`)"
else:
yield line
diff --git a/pyproject.toml b/pyproject.toml
index 555848f..99070d5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -14,63 +14,81 @@ maintainers = [
authors = [
{ name = "Lucas Diedrich" },
]
-requires-python = ">=3.10"
+requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
- "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
+ "Programming Language :: Python :: 3.14",
]
dependencies = [
"anndata",
# for debug logging (referenced from the issue template)
- "session-info",
+ "session-info2",
]
-optional-dependencies.dev = [
+# https://docs.pypi.org/project_metadata/#project-urls
+urls.Documentation = "https://dvp-io.readthedocs.io/"
+urls.Homepage = "https://github.com/lucas-diedrich/dvp-io"
+urls.Source = "https://github.com/lucas-diedrich/dvp-io"
+
+[dependency-groups]
+dev = [
"pre-commit",
"twine>=4.0.2",
]
-optional-dependencies.doc = [
- "docutils>=0.8,!=0.18.*,!=0.19.*",
+test = [
+ "coverage>=7.10",
+ "pytest",
+ "pytest-cov", # For VS Code’s coverage functionality
+]
+doc = [
"ipykernel",
"ipython",
"myst-nb>=1.1",
"pandas",
- # Until pybtex >0.23.0 releases: https://bitbucket.org/pybtex-devs/pybtex/issues/169/
- "setuptools",
- "sphinx>=4",
+ "sphinx>=8.1",
"sphinx-autodoc-typehints",
"sphinx-book-theme>=1",
"sphinx-copybutton",
"sphinx-tabs",
"sphinxcontrib-bibtex>=1",
+ "sphinxcontrib-katex",
"sphinxext-opengraph",
]
-optional-dependencies.test = [
- "coverage",
- "pytest",
-]
-# https://docs.pypi.org/project_metadata/#project-urls
-urls.Documentation = "https://dvp-io.readthedocs.io/"
-urls.Homepage = "https://github.com/lucas-diedrich/dvp-io"
-urls.Source = "https://github.com/lucas-diedrich/dvp-io"
[tool.hatch.build.targets.wheel]
packages = [ "src/dvpio" ]
[tool.hatch.envs.default]
installer = "uv"
-features = [ "dev" ]
+dependency-groups = [ "dev" ]
[tool.hatch.envs.docs]
-features = [ "doc" ]
-scripts.build = "sphinx-build -M html docs docs/_build {args}"
+dependency-groups = [ "doc" ]
+scripts.build = "sphinx-build -M html docs docs/_build -W {args}"
scripts.open = "python -m webbrowser -t docs/_build/html/index.html"
scripts.clean = "git clean -fdX -- {args:docs}"
+# Test the lowest and highest supported Python versions with normal deps
+[[tool.hatch.envs.hatch-test.matrix]]
+deps = [ "stable" ]
+python = [ "3.11", "3.14" ]
+
+# Test the newest supported Python version also with pre-release deps
+[[tool.hatch.envs.hatch-test.matrix]]
+deps = [ "pre" ]
+python = [ "3.14" ]
+
[tool.hatch.envs.hatch-test]
-features = [ "test" ]
+dependency-groups = [ "dev", "test" ]
+
+[tool.hatch.envs.hatch-test.overrides]
+# If the matrix variable `deps` is set to "pre",
+# set the environment variable `UV_PRERELEASE` to "allow".
+matrix.deps.env-vars = [
+ { key = "UV_PRERELEASE", value = "allow", if = [ "pre" ] },
+]
[tool.ruff]
line-length = 120
@@ -112,15 +130,16 @@ lint.per-file-ignores."docs/*" = [ "I" ]
lint.per-file-ignores."tests/*" = [ "D" ]
lint.pydocstyle.convention = "numpy"
-[tool.pytest.ini_options]
+[tool.pytest]
+strict = true
testpaths = [ "tests" ]
-xfail_strict = true
addopts = [
"--import-mode=importlib", # allow using test files with same name
]
[tool.coverage.run]
source = [ "dvpio" ]
+patch = [ "subprocess" ]
omit = [
"**/test_*.py",
]