🧑💻 Add uv setup workflow#1058
Conversation
…ies-and-setup-virtual-environment
for more information, see https://pre-commit.ci
|
Thanks @Abdol for creating this PR. We would like to have uv support so that's a good start. However, there are a few comments:
|
…ies-and-setup-virtual-environment
…virtual-environment' of https://github.com/TissueImageAnalytics/tiatoolbox into 1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment
@shaneahmed do you have a preference, i.e., requirement file or |
|
|
@shaneahmed I have addressed your feedback as follows:
Regarding the following point:
Do you mean that conda should remain as the recommended installation method? Thanks |
…ies-and-setup-virtual-environment
…virtual-environment' of https://github.com/TissueImageAnalytics/tiatoolbox into 1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment
|
@Abdol I have just merged an update to Python 3.14. This should cause conflicts with your PR particularly related to conda environment set up. |
…ies-and-setup-virtual-environment # Conflicts: # .github/workflows/conda-env-create.yml # requirements/requirements.dev.conda.yml # requirements/requirements.win64.conda.yml # requirements/requirements.win64.dev.conda.yml
…ies-and-setup-virtual-environment
…ies-and-setup-virtual-environment
…virtual-environment' of https://github.com/TissueImageAnalytics/tiatoolbox into 1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1058 +/- ##
========================================
Coverage 99.88% 99.88%
========================================
Files 85 85
Lines 11626 11626
Branches 1524 1524
========================================
Hits 11613 11613
Misses 7 7
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a uv-based development/setup path by moving dependency declarations into pyproject.toml (PEP 621) and updating CI/docs to install from the project metadata rather than requirements/*.txt.
Changes:
- Adds
[project]metadata (dependencies, extras, scripts) anduvindex/source configuration inpyproject.toml. - Updates GitHub Actions / RTD configs and documentation to install via
uv/pip install -e ".[...]"instead ofrequirements.txt. - Adds a test suite to validate version consistency and that a “uv-synced” environment can import key modules / CLI.
Reviewed changes
Copilot reviewed 23 out of 28 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_uv_setup.py |
New tests to validate version consistency and importability of key modules in a synced env. |
setup.py |
Pulls install_requires from pyproject.toml instead of requirements/requirements.txt. |
requirements/requirements.txt |
Removes legacy pip requirements file in favor of pyproject.toml. |
requirements/requirements_dev.txt |
Removes legacy dev requirements file in favor of pyproject.toml extras. |
requirements/requirements_cpu.txt |
Removes legacy PyTorch CPU requirements helper file. |
requirements/requirements.conda.yml |
Updates pip section to install from a path instead of -r requirements.txt. |
requirements/generate_conda_env.py |
Generates conda env from pyproject.toml dependencies. |
README.md |
Documents uv sync --extra dev development setup and CPU-only option. |
pyproject.toml |
Adds [project] + extras + scripts and uv indices/sources configuration. |
pre-commit/requirements_consistency.py |
Stops referencing removed requirements*.txt files. |
pre-commit/missing_imports.py |
Stops referencing removed requirements*.txt files. |
MANIFEST.in |
Removes inclusion of the deleted requirements/requirements.txt. |
docs/requirements.txt |
Removes docs requirements file in favor of pyproject.toml docs extra. |
docs/installation.rst |
Adds/expands uv installation + dev setup steps. |
docs/conf.py |
Drops exclusion patterns tied to removed requirements txt files. |
CONTRIBUTING.rst |
Updates contributor setup instructions to prefer uv sync. |
.readthedocs.yml |
Installs docs via pip install .[docs] and pre-installs CPU-only PyTorch. |
.pre-commit-config.yaml |
Removes requirements-txt-fixer hook (requirements txt removed). |
.gitignore |
Ignores uv.lock. |
.github/workflows/python-package.yml |
Installs package via uv pip install -e . instead of -r requirements.txt. |
.github/workflows/pip-install.yml |
Removes requirements-txt path triggers; continues install validation workflow. |
.github/workflows/mypy-type-check.yml |
Installs dev deps via -e ".[dev]" instead of requirements_dev.txt. |
.github/workflows/conda-env-create.yml |
Trigger paths updated + adds monthly schedule; conda env generation uses pyproject.toml. |
.deepsource.toml |
Points dependency analyzer at pyproject.toml instead of requirements_dev.txt. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| license = { text = "BSD-3-Clause" } | ||
| authors = [{ name = "TIA Centre", email = "TIA@warwick.ac.uk" }] | ||
| requires-python = ">=3.11, <3.14" | ||
| classifiers = [ |
| "pytest-cov>=4.0.0", | ||
| "pytest-runner>=6.0", | ||
| "pytest-xdist[psutil]", | ||
| "ruff==0.15.9", |
| with Path("HISTORY.md").open() as history_file: | ||
| history = history_file.read() | ||
|
|
||
| install_requires = [ | ||
| line | ||
| for line in Path("requirements/requirements.txt").read_text().splitlines() | ||
| if line and line[0] not in ("-", "#") | ||
| ] | ||
| import tomllib | ||
|
|
||
| with Path("pyproject.toml").open("rb") as _f: | ||
| _pyproject = tomllib.load(_f) | ||
| install_requires = _pyproject["project"]["dependencies"] |
| - python>=3.11, <=3.14 | ||
| - pip: | ||
| - -r requirements.txt | ||
| - .. |
| result = subprocess.run( # noqa: S603 | ||
| [sys.executable, "-c", f"import {module}"], | ||
| capture_output=True, | ||
| check=False, | ||
| text=True, | ||
| ) | ||
| assert result.returncode == 0, ( | ||
| f"Failed to import {module!r}.\n" | ||
| f"stderr: {result.stderr.strip()}\n" | ||
| f"This module may be missing from the uv-synced environment." | ||
| ) |
| on: | ||
| push: | ||
| paths: | ||
| - "requirements/requirements*.txt" | ||
| - "requirements/generate_conda_env.py" | ||
| - ".github/workflows/conda-env-create.yml" | ||
| paths: [ "requirements/requirements*.yml", "conda-env-create.yml", "pyproject.toml"] | ||
| pull_request: | ||
| paths: | ||
| - "requirements/requirements*.txt" | ||
| - "requirements/generate_conda_env.py" | ||
| - ".github/workflows/conda-env-create.yml" | ||
| paths: [ "requirements/requirements*.yml", "conda-env-create.yml", "pyproject.toml"] | ||
| schedule: # Run on the 1st of every month at midnight |
| push: | ||
| paths: | ||
| - "requirements*.yml" | ||
| - "conda-env-create.yml" | ||
| - "requirements/requirement*.txt" | ||
| - "setup*py" | ||
| - "setup*cfg" | ||
| - "pyproject*toml" | ||
| - "MANIFEST*in" | ||
| - ".github/workflows/pip-install.yml" | ||
| pull_request: | ||
| paths: | ||
| - "requirements*.yml" | ||
| - "conda-env-create.yml" | ||
| - "requirements/requirement*.txt" | ||
| - "setup*py" |
…toolbox into 1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment # Conflicts: # docs/requirements.txt # requirements/requirements.txt # requirements/requirements_dev.txt
Implements #1056.
Description
The developers of ruff has also made uv, a package manager that claims to be at least 10x times faster than pip. It can also setup a virtual python environment and install dependencies in one go.
I'm considering having a go at adding a uv-based development setup for TIAToolbox.
An example workflow will be:
git clone https://github.com/TissueImageAnalytics/tiatoolbox.git cd tiatoolbox uv syncAfter that, the dependencies will installed in a new Python venv environment.
Reviewing
Can you try testing if the workflow works on Windows and Linux, with and without GPU?
How to Test
Please refer to the branch's README for installation steps.
We need to verify that the PR works across:
Feedback is appreciated. Thanks!
TODO
conda-env-create.yml)mps