Skip to content

Install through pyproject.toml (PEP 518/621)#3184

Merged
C-Achard merged 54 commits intoDeepLabCut:mainfrom
deruyter92:arash_and_jaap/uv_packaging
Mar 4, 2026
Merged

Install through pyproject.toml (PEP 518/621)#3184
C-Achard merged 54 commits intoDeepLabCut:mainfrom
deruyter92:arash_and_jaap/uv_packaging

Conversation

@deruyter92
Copy link
Copy Markdown
Collaborator

@deruyter92 deruyter92 commented Jan 16, 2026

Replacement PR for #3134 by @arashsm79
(cannot push changes to the original branch)

Summary

This PR modernizes how DLC specifies its dependencies and metadata, following latest standards for python packaging and allowing for modern build tools to be used for installation.
Introduces a pyproject.toml‑based configuration as the single source of truth for project metadata and dependencies, in line with current Python packaging standards (PEP 518 / PEP 621).

This does not change the package manager, nor does it require adopting any specific tool, though it is compatible with more modern installation methods. (pip, mamba, uv, conda, pdm...)


For example, uv is an extremely fast Python package and project manager that has seen incredible adoption from the Python community.
Here, the first steps are taken to allow DLC to be installed with modern package managers, such as uv, for different platforms and Python version.

The CI has also been updated accordingly to use uv.
The CI will be updated accordingly in a separate PR

Example UV install

Checkout this PR on a local copy of DLC.
Install uv
If you are not familiar with uv, you can take a look at their Getting Started page.
Run uv sync with the extra dependencies you may want for a quick install.

uv sync --extra gui --python 3.11
uv run deeplabcut

(Solves issues #3111 and similar)

@deruyter92 deruyter92 mentioned this pull request Jan 16, 2026
@deruyter92 deruyter92 force-pushed the arash_and_jaap/uv_packaging branch from 9bb8d35 to 2929daa Compare January 16, 2026 13:31
@deruyter92 deruyter92 force-pushed the arash_and_jaap/uv_packaging branch from 81c9b12 to e824a5b Compare January 16, 2026 13:59
@deruyter92 deruyter92 requested a review from Copilot January 16, 2026 16:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 migrates DeepLabCut's packaging system from the traditional setup.py to a modern pyproject.toml-based configuration using uv as the package manager. The migration streamlines dependency management and follows current Python packaging best practices.

Changes:

  • Migrated package configuration from setup.py to pyproject.toml with support for multiple Python versions and platforms
  • Removed obsolete development tools and scripts that are no longer needed with the new packaging approach
  • Updated documentation to reflect the new installation methods using both uv and pip

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Complete package configuration with dependencies, optional extras, and platform-specific requirements
setup.py Simplified to a compatibility shim that delegates to pyproject.toml
README.md Updated installation instructions for both PyPI and source installations
.pre-commit-config.yaml Replaced black with ruff for code formatting
.github/workflows/python-package.yml Updated CI to install package directly instead of using requirements.txt
tools/update_license_headers.py Removed obsolete developer tool
tools/README.md Removed documentation for obsolete developer tools
testscript_cli.py Removed obsolete test script
reinstall.sh Removed obsolete installation script
dlc.py Removed obsolete CLI entry point file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deruyter92 deruyter92 marked this pull request as ready for review January 21, 2026 17:05
@deruyter92 deruyter92 requested a review from C-Achard January 21, 2026 17:05
@deruyter92 deruyter92 added enhancement New feature or request dependencies Pull requests that update a dependency file labels Jan 21, 2026
@deruyter92 deruyter92 marked this pull request as draft January 22, 2026 06:45
@deruyter92 deruyter92 marked this pull request as ready for review January 22, 2026 08:59
@deruyter92 deruyter92 force-pushed the arash_and_jaap/uv_packaging branch from f906c5d to a1e370b Compare January 22, 2026 09:06
arashsm79 and others added 2 commits January 22, 2026 12:02
- Edit pyproject.toml
- Keep setup.py for backward compatibility
@deruyter92 deruyter92 force-pushed the arash_and_jaap/uv_packaging branch from 5763d4b to eb04efa Compare January 22, 2026 11:09
Re-introduce a missing 'fmpose3d' extras section in pyproject.toml
@C-Achard
Copy link
Copy Markdown
Collaborator

C-Achard commented Mar 3, 2026

Note : re-added missing fmpose3D dependency

Add temporary formatting configuration to pyproject.toml to standardize code style during linting changes. Includes a brief yapf config (based_on_style = "google", indent_width = 4) and isort settings (multi_line_output=3, include_trailing_comma=true, line_length=88, skip __init__.py, etc.). These settings are marked TODO and should be removed once the project linting is finalized.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

pyproject.toml:79

  • This line has trailing whitespace (a tab after the closing bracket), which will be flagged by the trailing-whitespace pre-commit hook added/kept in this repo. Please remove the trailing tab to avoid pre-commit/CI failures.
fmpose3d = ["fmpose3d"]	

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Functional tests started failing in CI without any repository-side dependency changes. The failure occurs during `deeplabcut.export_model()` when TensorFlow writes the graph, raising:
  TypeError: MessageToString() got an unexpected keyword argument 'float_format'

This is consistent with transitive dependency drift in the runner image / resolver (e.g. ubuntu-latest / Python minor version changes) causing an incompatible protobuf runtime to be installed alongside TensorFlow, even though DeepLabCut itself is pinned to a commit.
@C-Achard
Copy link
Copy Markdown
Collaborator

C-Achard commented Mar 3, 2026

Important : trying to run CI with pinned protobuf for functional tests, as functional tests started failing in CI without any repository-side dependency changes. The failure occurs during deeplabcut.export_model() when TensorFlow writes the graph, raising:
TypeError: MessageToString() got an unexpected keyword argument 'float_format'

This is likely due to dependency drift in the runner image / resolver (e.g. -latest / Python minor version changes) causing an incompatible protobuf runtime to be installed alongside TensorFlow, even though DeepLabCut itself is pinned to a commit.

Note; trying with protobuf<7 seems to be successful so far. I tried to advertise the file clearly and only use it where necessary to minimize potential side-effects, but I would not call this future-proof either.

C-Achard added 3 commits March 3, 2026 13:06
Add .github/versioning/tf-ci-constraints.txt to pin TensorFlow-related dependencies for CI. Update .github/workflows/python-package.yml to apply the constraints file for pip installs and install the package in editable mode (-e .) with the constraints before running example tests, replacing the previous git+https install. This ensures consistent TensorFlow/dependency versions and reproducible CI installs.
@AlexEMG AlexEMG requested a review from arashsm79 March 3, 2026 14:56
@C-Achard C-Achard linked an issue Mar 3, 2026 that may be closed by this pull request
@C-Achard C-Achard added this to the DLC3 milestone Mar 3, 2026
@C-Achard C-Achard changed the title uv packaging Install through pyproject.toml (PEP 518/621) Mar 3, 2026
@C-Achard C-Achard merged commit 640f0fa into DeepLabCut:main Mar 4, 2026
10 checks passed
@arashsm79
Copy link
Copy Markdown
Contributor

Maybe squashing this when merging would be cleaner.

@amadorkane
Copy link
Copy Markdown

I'm helping out 3 (so far) other researchers who are having difficulties installing DLC after getting my own copy installed last week on my Windows 11 machine.
They are running into a series of similar dependency issues, so I directed them to this solution (#3184).
However, this is a long and complicated series of entries, so I want to understand what exactly we should be doing for the new installation method. Is this correct?

Install uv

Where do they install pytorch? Before or after any of these uv steps?

uv sync --extra gui --python 3.11
uv run deeplabcut

Also, is this the way to install through a pyproject.toml or am I missing something?

Do you know when the official installation instructions will be updated?
Thanks for working on all this!

@C-Achard
Copy link
Copy Markdown
Collaborator

C-Achard commented Mar 5, 2026

Hello @amadorkane,

Sorry for the continued trouble, the best would be to install pytorch between those two steps you listed; make sure to check their docs for GPU/CUDA support.

uv sync --extra gui --python 3.11
uv pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu<CUDA_VER> # where CUDA_VER is the cuda version supported by your GPU
uv run deeplabcut

However you will need to clone the repo and install from the main branch to benefit from the pyproject.toml based install, and likely update napari to 0.6.6 manually (or install from the napari-DLC repo main branch by cloning).

I understand this is complicated, and I apologize for the situation, but we are doing our best to fix this as soon as possible while ensuring we do not worsen the situation either.

We are almost finished merging + releasing fixes across repositories, but currently the installation is problematic due to pinned versions in the napari-DLC dependencies. A release is staged but it will take a little longer for us to align everything; sorry again.

Once we have this and ideally #3225 merged, we can finally make an easier-to-install rc release and update the docs.
In the meantime, please send any errors you encounter and I will assist with the installation.

Best,
Cyril

@amadorkane
Copy link
Copy Markdown

Thank you very much Cyril! When I saw how many pages of dependencies there were after installation, I got the complexity of the problems you are up against!

I am not sure how to do this: "clone the repo and install from the main branch". In #3219, I was advised to try:
git clone https://github.com/deruyter92/DeepLabCut.git
cd DeepLabCut
git checkout deruyter92/arash_and_jaap/uv_packaging

But that led to an error when doing the last step. The method that finally worked did not involved cloning the forked repo so I'm unclear how to do this part correctly still.

Also, is the following correct for the additional napari steps? Also,

uv sync --extra gui --python 3.11
uv pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu<CUDA_VER> # where CUDA_VER is the cuda version supported by your GPU

uv pip3 install -v "napari==0.6.6" <-- correct?
uv pip3 install napari-deeplabcut <-- correct?

uv run deeplabcut

@C-Achard
Copy link
Copy Markdown
Collaborator

C-Achard commented Mar 6, 2026

Hello @amadorkane,

Apologies for the delay, we are now nearly done with the release.

In the meantime, my colleague @arashsm79 kindly suggested the following, which I edited a bit to work on Windows (in PowerShell) :

mkdir dlc_project
cd dlc_project
uv venv -p 3.12 .dlc_venv
& .\.dlc_venv\Scripts\activate.ps1
uv pip install torch torchvision --torch-backend=cu<CUDA_VER>
uv pip install "deeplabcut[gui] @ git+https://github.com/deeplabcut/deeplabcut.git"
uv run -m deeplabcut

No cloning, should work out of the box, hopefully.
(The GUI might take a bit to open on first launch)

For the CUDA_VER, check the nvidia-smi command output, in the upper right you will see something like :
image
Simply replace <CUDA_VER> with e .g. 131 or 126 or 128 depending on what you see (no separator, no brackets).

Please let me know if this worked,

Best,
Cyril

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request Installation

Projects

None yet

9 participants