Skip to content

🧑‍💻 Add uv setup workflow#1058

Open
Abdol wants to merge 34 commits into
developfrom
1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment
Open

🧑‍💻 Add uv setup workflow#1058
Abdol wants to merge 34 commits into
developfrom
1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment

Conversation

@Abdol

@Abdol Abdol commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

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 sync

After 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:

  • macOS
  • Windows (cuda)
  • Linux (cuda)

Feedback is appreciated. Thanks!

TODO

  • Develop uv implementation
  • Update PR description to include a introduction to the change and how to use it
  • Add instructions on how to install uv on Windows
  • Remove conda .yml files (and its reference in conda-env-create.yml)
  • Remove tiatoolbox .env
  • Add uv install instruction for stable version (not only develop)
  • Pin python version
  • Check uv installation for mps
  • Investigate replacing poetry with uv

@Abdol Abdol self-assigned this Apr 30, 2026
@Abdol Abdol added the enhancement New feature or request label Apr 30, 2026
@Abdol Abdol linked an issue Apr 30, 2026 that may be closed by this pull request
@Abdol Abdol requested review from measty and shaneahmed April 30, 2026 15:44
@Abdol Abdol marked this pull request as draft April 30, 2026 15:46
@shaneahmed

Copy link
Copy Markdown
Member

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:

  1. We should not have duplication of requirements file and pyproject.toml. We should have all the dependencies listed in one file.
  2. We should not replace conda in README at least for now.
  3. Can you remove uv.lock as it is probably not required to be on the repo.
  4. Probably add uv installation instructions to https://tia-toolbox.readthedocs.io/en/latest/installation.html

@shaneahmed shaneahmed added this to the Release v2.1.0 milestone May 1, 2026
shaneahmed and others added 2 commits May 8, 2026 12:18
…virtual-environment' of https://github.com/TissueImageAnalytics/tiatoolbox into 1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment
@Abdol

Abdol commented May 13, 2026

Copy link
Copy Markdown
Collaborator Author
  • We should not have duplication of requirements file and pyproject.toml. We should have all the dependencies listed in one file.

@shaneahmed do you have a preference, i.e., requirement file or pyproject.toml?

@shaneahmed

Copy link
Copy Markdown
Member
  • We should not have duplication of requirements file and pyproject.toml. We should have all the dependencies listed in one file.

@shaneahmed do you have a preference, i.e., requirement file or pyproject.toml?

pyproject.toml is better.

@Abdol

Abdol commented May 13, 2026

Copy link
Copy Markdown
Collaborator Author

@shaneahmed I have addressed your feedback as follows:

  1. All requirements are now unified in pyproject.toml (this needs thorough testing as it affects installing using conda as well)
  2. Removed uv.lock (and added it to .gitignore)
  3. Added uv installation guide to readthedocs

Regarding the following point:

  • We should not replace conda in README at least for now.

Do you mean that conda should remain as the recommended installation method? Thanks

@shaneahmed

Copy link
Copy Markdown
Member

@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.

Abdol and others added 4 commits May 19, 2026 06:46
…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
@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.88%. Comparing base (a1e2512) to head (8877ddc).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Abdol Abdol marked this pull request as ready for review May 21, 2026 21:23
@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot May 22, 2026 10:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and uv index/source configuration in pyproject.toml.
  • Updates GitHub Actions / RTD configs and documentation to install via uv / pip install -e ".[...]" instead of requirements.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.

Comment thread pyproject.toml
Comment on lines +6 to +9
license = { text = "BSD-3-Clause" }
authors = [{ name = "TIA Centre", email = "TIA@warwick.ac.uk" }]
requires-python = ">=3.11, <3.14"
classifiers = [
Comment thread pyproject.toml
"pytest-cov>=4.0.0",
"pytest-runner>=6.0",
"pytest-xdist[psutil]",
"ruff==0.15.9",
Comment thread setup.py
Comment on lines 12 to +19
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
- ..
Comment thread tests/test_uv_setup.py
Comment on lines +108 to +118
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."
)
Comment on lines 8 to +13
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
Comment on lines 4 to 17
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"
Abdol added 2 commits June 8, 2026 16:47
…toolbox into 1056-add-uv-workflow-to-install-dependencies-and-setup-virtual-environment

# Conflicts:
#	docs/requirements.txt
#	requirements/requirements.txt
#	requirements/requirements_dev.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add uv workflow to install dependencies and setup virtual environment

3 participants