Skip to content

Improve optional dependency handling and install documentation #75

@theo-barfoot

Description

@theo-barfoot

Context

Raised during JOSS review (openjournals/joss-reviews#10072) by @yewentao256, who recommended "making a full requirements.txt file for user and fix all unit tests".

Problem

While pyproject.toml already declares core dependencies and an extras optional group (jax, cupy), there are gaps:

  1. The [project.optional-dependencies] extras group bundles CuPy and JAX together — these should be separate extras so users can install only what they need (e.g. pip install torchsparsegradutils[cupy] or pip install torchsparsegradutils[jax]).
  2. The CuPy extra doesn't specify a version range, meaning users may install an incompatible version (see #issue_2 for the tol/rtol breakage).
  3. Tests that depend on optional packages (CuPy, JAX) should skip gracefully with a clear message when the dependency is not installed or is an unsupported version, rather than failing with an import or runtime error.
  4. The README and docs installation section should clearly document the optional extras and what each one provides.

Proposed Changes

  • Split extras into separate optional dependency groups in pyproject.toml:
    [project.optional-dependencies]
    cupy = ["cupy-cuda12x>=13.0"]  # or appropriate version range
    jax = ["jax[cuda12]"]
    all = ["torchsparsegradutils[cupy,jax]"]
    dev = [...]
    docs = [...]
  • Add version constraints for CuPy to ensure compatibility with the solver kwarg API.
  • Ensure all tests using optional dependencies use pytest.importorskip() or equivalent skip markers.
  • Update README and RTD docs installation instructions to document the extras.

Acceptance Criteria

  • Optional dependencies are properly separated in pyproject.toml
  • CuPy version range is pinned to supported versions
  • Tests skip cleanly when optional dependencies are missing
  • Installation instructions in README and docs are updated

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions