Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

7.7 KB
Raw Blame
[workspace]
name = "kornia"
description = "Open Source Differentiable Computer Vision Library for PyTorch"
authors = ["Edgar Riba <[email protected]>"]
channels = ["conda-forge"]
platforms = ["linux-64", "linux-aarch64", "osx-arm64", "osx-64", "win-64"]

# ------------------------------------------------------------------------------
# Base: System dependencies
# ------------------------------------------------------------------------------

[dependencies]
python = ">=3.11,<3.15"
uv = "*"
tombi = "*"
ty = ">=0.0.9,<0.0.10"

# ------------------------------------------------------------------------------
# Environments
# ------------------------------------------------------------------------------

[environments]
# Default environment with Python 3.11 (best compatibility)
default = { features = ["py311"], solve-group = "default" }
# CUDA environment for GPU development
cuda = { features = ["cuda", "py311"], solve-group = "cuda" }
# CI environments with specific Python versions
py311 = { features = ["py311"], solve-group = "py311" }
py312 = { features = ["py312"], solve-group = "py312" }
py313 = { features = ["py313"], solve-group = "py313" }
py314 = { features = ["py314"], solve-group = "py314" }

# ------------------------------------------------------------------------------
# Tasks (shared across environments)
# ------------------------------------------------------------------------------

[tasks]
# Installation
install = { cmd = "uv sync --extra dev", description = "Install dev dependencies" }
install-docs = { cmd = "uv sync --extra dev --extra docs", description = "Install dev + docs dependencies" }
# Tests - use env vars (KORNIA_TEST_DEVICE, KORNIA_TEST_DTYPE, KORNIA_TEST_RUNSLOW)
test = { cmd = "uv run pytest tests/", description = "Run tests (configure via KORNIA_TEST_* env vars)" }
test-f32 = { cmd = "uv run pytest tests/", env = { KORNIA_TEST_DTYPE = "float32" } }
test-f64 = { cmd = "uv run pytest tests/", env = { KORNIA_TEST_DTYPE = "float64" } }
test-slow = { cmd = "uv run pytest tests/", env = { KORNIA_TEST_RUNSLOW = "true" } }
test-quick = { cmd = "uv run pytest tests/" }
test-half = { cmd = "uv run pytest tests/", env = { KORNIA_TEST_DTYPE = "float16,bfloat16" }, description = "Run CPU half-precision tests" }
test-mps = { cmd = "uv run pytest tests/ --xfail-known-failures", env = { KORNIA_TEST_DEVICE = "mps", KORNIA_TEST_DTYPE = "float32" }, description = "Run blocking MPS float32 tests against the strict known-failure baseline (unset PYTORCH_ENABLE_MPS_FALLBACK)" }
test-module = { cmd = "uv run pytest", description = "Run tests for a specific module (usage: pixi run test-module tests/<module_path>, e.g., pixi run test-module tests/contrib/)" }
# Quality
lint = { cmd = "uv run pre-commit run ruff-check --all-files && uv run pre-commit run ruff-format --all-files" }
pre-commit-all = { cmd = "uv run pre-commit run --all-files", description = "Run all repository pre-commit checks" }
pre-commit-install = { cmd = "uv run pre-commit install", description = "Install the pre-commit Git hook" }
typecheck = { cmd = "ty check kornia" }
doctest = { cmd = "uv run pytest --doctest-modules kornia/", description = "Run docstring examples; examples needing an uncached model checkpoint are skipped" }
doctest-weights = { cmd = "uv run pytest --doctest-modules kornia/", env = { KORNIA_DOCTEST_DOWNLOAD = "1" }, description = "Run docstring examples, downloading pretrained weights when the cache misses (~838 MB cold)" }
toml-fmt = { cmd = "tombi format", description = "Format TOML files" }
toml-fmt-check = { cmd = "tombi format --check", description = "Check TOML formatting" }
# Docs
build-docs = { cmd = "uv run python -m sphinx -W -b html docs/source docs/build/html", depends-on = [
  "install-docs"
] }
# Changelog tooling is isolated from Kornia's runtime and test dependencies.
changelog-preview = { cmd = "uv tool run --from towncrier==25.8.0 towncrier build --draft --version Unreleased", description = "Preview pending release notes without changing files" }
changelog-build = { cmd = "uv tool run --from towncrier==25.8.0 towncrier build --yes", description = "Assemble release notes (requires --version X.Y.Z); stages changelog and removes consumed fragments" }
# Utility
clean = { cmd = "find . -type f -name '*.pyc' -delete && find . -type d -name '__pycache__' -delete && rm -rf .venv .venv-py312 .venv-py313 .venv-py314" }

# ------------------------------------------------------------------------------
# Restrict CUDA feature to supported platforms only
# ------------------------------------------------------------------------------
[feature.cuda]
platforms = ["linux-64", "linux-aarch64", "win-64"]

# ------------------------------------------------------------------------------
# Feature: CUDA (PyTorch CUDA wheels) - for local GPU development
# PyPI's Linux wheels, which uv.lock selects, are already CUDA builds. Its Windows wheels are CPU-only, and uv
# doesn't support per-environment sources, so the Windows tasks replace torch after syncing.
# ------------------------------------------------------------------------------

[feature.cuda.activation.env]
# On Windows, preserve the CUDA wheel that replaces the locked torch when running tests or other project commands.
# Linux has no such wheel, but this applies there too: re-run the install task after a lock change.
UV_NO_SYNC = "1"

[feature.cuda.tasks]
# --reinstall restores what removing a stale wheel deletes: the nvidia-*-cu12 wheels of an older install own paths the
# locked nvidia-*-cu13 wheels also own, and after a plain sync `import torch` fails on libcudnn.so.9.
install = { cmd = "uv sync --extra dev --reinstall", description = "Install dev dependencies (CUDA PyTorch)" }
install-docs = { cmd = "uv sync --extra dev --extra docs --reinstall", description = "Install dev + docs (CUDA PyTorch)" }
# CUDA test tasks
test-cuda = { cmd = "uv run pytest tests/", env = { KORNIA_TEST_DEVICE = "cuda" }, description = "Run tests on CUDA" }
test-cuda-f32 = { cmd = "uv run pytest tests/", env = { KORNIA_TEST_DEVICE = "cuda", KORNIA_TEST_DTYPE = "float32" } }
test-cuda-f64 = { cmd = "uv run pytest tests/", env = { KORNIA_TEST_DEVICE = "cuda", KORNIA_TEST_DTYPE = "float64" } }
test-cuda-half = { cmd = "uv run pytest tests/ --isolate-half-precision", env = { KORNIA_TEST_DEVICE = "cuda", KORNIA_TEST_DTYPE = "float16,bfloat16" }, description = "Run half-precision CUDA tests with per-test subprocess isolation" }

[feature.cuda.target.win-64.tasks]
# Run pip inside uv's project environment, not Pixi's activated Conda environment. Keep the version equal to torch in
# uv.lock and the index matching its cuda-toolkit, and --no-deps so the index's dependencies do not replace the locked
# ones; tests/test_pixi_tasks.py covers all three.
install = { cmd = "uv sync --extra dev && uv run --no-sync uv pip install --reinstall --no-deps torch==2.15.0 --index https://download.pytorch.org/whl/cu132", description = "Install dev dependencies (CUDA PyTorch)" }
install-docs = { cmd = "uv sync --extra dev --extra docs && uv run --no-sync uv pip install --reinstall --no-deps torch==2.15.0 --index https://download.pytorch.org/whl/cu132", description = "Install dev + docs (CUDA PyTorch)" }

# ------------------------------------------------------------------------------
# Python version features (for CI matrix)
# ------------------------------------------------------------------------------

[feature.py311.dependencies]
python = "3.11.*"

[feature.py312.dependencies]
python = "3.12.*"

[feature.py312.activation.env]
UV_PROJECT_ENVIRONMENT = ".venv-py312"

[feature.py313.dependencies]
python = "3.13.*"

[feature.py313.activation.env]
UV_PROJECT_ENVIRONMENT = ".venv-py313"

[feature.py314.dependencies]
python = "3.14.*"

[feature.py314.activation.env]
UV_PROJECT_ENVIRONMENT = ".venv-py314"