Skip to content

Commit

Permalink
Add optional dependency sections for gallery and docs (napari#7487)
Browse files Browse the repository at this point in the history
Looking for feedback here, especially from @Czaki and @melissawm.

Prompted by [this
comment](napari#7468 (comment))
from @psobolewskiPhD.

When adding an example to the gallery, any new dependencies need to be
added to
both (currently nonexistent) `docs` and `testing` optional dependency
groups.
That made me think that there was something a bit off with how we were
thinking
about things. I thought about this a bit more and thought it best to
create a
"gallery" group, which both testing and docs depend on.

I've implemented this in this PR, adding [docs] and [gallery] and then
adding
dependencies on [gallery] to both [docs] and [testing]. Some questions:

- Currently, I've added anything that is imported in the gallery to the
gallery
dependencies, even if it is already a core dependency. The rationale
here is
that if we, for example, drop the dependency on pandas, we still want
the
examples using pandas to run. It's nice to have our core dependencies
and our
  *direct* example dependencies uncoupled.
- However, adding minimum versions to the examples makes it quite
onerous to
keep gallery dependencies in sync. I've therefore kept gallery
dependencies
  bare, with no version requirements. Is that a bad idea?
- The docs dependencies are copied over from [the requirements.txt file
in the
docs
repo](https://github.com/napari/docs/blob/45d18dcd4653f56e9fdaf438a5897882c44fc13a/requirements.txt).
  Is that what we want to do or do we want to clean these up/add
minimum/maximum versions? (And maybe that could come in a separate PR?)

---------

Co-authored-by: Grzegorz Bokota <[email protected]>
  • Loading branch information
jni and Czaki authored Feb 20, 2025
1 parent 343c081 commit c3fdd6c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/upgrade_test_constraints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
uv pip compile --python-version 3.12 --upgrade --output-file ${constraints}/constraints_py3.12_examples.txt ${pyproject_toml} ${constraints}/version_denylist.txt ${constraints}/version_denylist_examples.txt "${flags[@]}"
uv pip compile --python-version 3.10 --upgrade --output-file ${constraints}/constraints_py3.10_docs.txt ${pyproject_toml} ${constraints}/version_denylist.txt ${constraints}/version_denylist_examples.txt docs/requirements.txt "${flags[@]}"
uv pip compile --python-version 3.10 --upgrade --output-file ${constraints}/constraints_py3.10_docs.txt ${pyproject_toml} ${constraints}/version_denylist.txt ${constraints}/version_denylist_examples.txt --extra docs "${flags[@]}"
uv pip compile --python-version 3.12 --upgrade --output-file ${prefix}/resources/requirements_mypy.txt ${prefix}/resources/requirements_mypy.in
# END PYTHON DEPENDENCIES
Expand Down
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ optional = [
"PartSegCore-compiled-backend>=0.15.11",
]
testing = [
"napari[gallery]",
"babel>=2.9.0",
"fsspec>=2023.10.0",
"hypothesis>=6.8.0",
Expand All @@ -153,6 +154,35 @@ testing = [
testing_extra = [
"torch>=1.10.2",
]
# needed for gallery examples
gallery = [
"zarr",
"dask[array,distributed]",
"matplotlib",
"pooch",
"nilearn",
"xarray",
]
# needed to build docs
docs = [
"napari[gallery]",
"sphinx<8",
"sphinx-autobuild",
"sphinx-tabs",
"sphinx-tags",
"sphinx-design",
"sphinx-external-toc",
"sphinx-favicon>=1.0",
"sphinx-copybutton",
"sphinx-gallery",
"sphinx_autodoc_typehints==1.12.0",
"myst-nb",
"napari-sphinx-theme>=0.3.0",
"matplotlib",
"lxml[html_clean]>5",
"imageio-ffmpeg",
"pytest",
]
release = [
"PyGithub>=1.46",
"twine>=3.1.1",
Expand Down
5 changes: 0 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ commands =
--save-leaked-object-graph

[testenv:py{310,311,312,313}-{linux,macos,windows}-{pyqt5,pyside2,pyqt6,pyside6}-examples-{cov,no_cov}]
deps =
# For surface_timeseries_.py example
nilearn
# Due to nilearn incompatibility with numpy >=1.24 constraint numpy and add packaging for version check
packaging
commands =
cov: coverage run --parallel-mode \
!cov: python \
Expand Down

0 comments on commit c3fdd6c

Please sign in to comment.