Skip to content

Migrate to pyproject.toml (PEP 518/621)#165

Merged
MMathisLab merged 7 commits intomainfrom
cy/migrate-pyproject-from-setup-cfg
Mar 4, 2026
Merged

Migrate to pyproject.toml (PEP 518/621)#165
MMathisLab merged 7 commits intomainfrom
cy/migrate-pyproject-from-setup-cfg

Conversation

@C-Achard
Copy link
Copy Markdown
Collaborator

@C-Achard C-Achard commented Mar 4, 2026

Summary

This PR modernizes dependencies and metadata specifications, moving away from setup.cfg, 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...)


This pull request significantly refactors the pyproject.toml; the most impactful changes are the modernization of packaging metadata, dependency management, and the addition of new pre-commit hooks for Python project formatting and validation.

Packaging and metadata modernization:

  • The [project] table is now used in pyproject.toml, providing explicit metadata such as name, description, license, classifiers, dependencies, optional testing dependencies, and entry points for napari plugins. This aligns with modern Python packaging standards and improves compatibility with tools like pip and PyPI.
  • Dependency specifications have been updated and made more precise, including minimum and maximum versions for key libraries.
  • The build system requirements are updated to use newer versions of setuptools and setuptools-scm, ensuring better support for modern Python features.
  • Removed setup.cfg as it is no longer required.

Pre-commit configuration improvements:

  • Added two new pre-commit hooks: pyproject-fmt for automatic formatting of pyproject.toml files, and validate-pyproject for validating the correctness of pyproject.toml. These help maintain a consistent and error-free project configuration.

Tool configuration updates:

  • Added configuration for pyproject-fmt to enhance readability and ensure Python version classifiers are generated.

C-Achard added 4 commits March 4, 2026 10:02
… config

Populate pyproject.toml with PEP 621 project metadata and setuptools configuration: set build-system requirements (setuptools>=64, wheel, setuptools_scm[toml]>=7), declare package name, description, python requirement, license, authors, classifiers, dependencies, project URLs and napari entry-point. Configure setuptools to use src layout, include package data (napari.yaml), mark version as dynamic (setuptools-scm), and add optional testing dependencies. Minor whitespace/qt_api line adjustments preserved.
Update pyproject.toml: raise build-system requirement to setuptools>=77 and replace the license table with license = "LGPL-3.0-only" plus license-files = ["LICENSE"]. These changes align packaging metadata with newer setuptools/PEP expectations and ensure the license file is included.
Add GNU Lesser General Public License v3 (LGPLv3) to the project classifiers in pyproject.toml to explicitly declare the license. Also rephrase the setuptools-scm comment for clarity that the version is derived from git tags.
Add pyproject-fmt and validate-pyproject to pre-commit to enforce and validate pyproject.toml formatting. Add [tool.pyproject-fmt] settings in pyproject.toml to set max_supported_python to 3.12, enable generation of Python version classifiers, and keep tables in long format to preserve readability.
@C-Achard C-Achard self-assigned this Mar 4, 2026
@C-Achard C-Achard added enhancement New feature or request versioning Issue, fix or feature related to dependencies or plugin version(s) labels Mar 4, 2026
@C-Achard C-Achard added this to the Core plugin overhaul (2026) milestone Mar 4, 2026
C-Achard added 2 commits March 4, 2026 10:16
Delete the GNU Lesser General Public License v3 trove classifier from pyproject.toml to correct package metadata, following PEP 639
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

Migrates project packaging/configuration from setup.cfg to a PEP 518/621-compliant pyproject.toml, and updates developer tooling to format/validate the new packaging metadata.

Changes:

  • Remove legacy setup.cfg metadata/dependency configuration.
  • Define project metadata, dependencies, entry points, and setuptools configuration under [project] / [tool.setuptools] in pyproject.toml.
  • Add pre-commit hooks to format and validate pyproject.toml.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
setup.cfg Removed legacy setuptools configuration in favor of pyproject.toml.
pyproject.toml Adds PEP 621 [project] metadata/deps and setuptools configuration for packaging.
.pre-commit-config.yaml Adds pyproject-fmt and validate-pyproject hooks to keep pyproject.toml consistent/correct.

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

You can also share your feedback on Copilot code review. Take the survey.

Remove the setup-cfg-fmt hook from .pre-commit-config.yaml. Correct a grammar/casing issue in pyproject.toml by changing the author line from "Lead by Jessy Lauer" to "led by Jessy Lauer".
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 3 out of 3 changed files in this pull request and generated no new comments.


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

You can also share your feedback on Copilot code review. Take the survey.

@C-Achard C-Achard requested review from AlexEMG and MMathisLab March 4, 2026 09:58
@C-Achard
Copy link
Copy Markdown
Collaborator Author

C-Achard commented Mar 4, 2026

@MMathisLab @AlexEMG Following updates on other repos, and since we need a release of this eventually for DLC, I suggest we update package dependencies/metadata similarly to DeepLabCut/DeepLabCut#3184.

I also introduced our linting standardization efforts in #166 and #167 if relevant.

@MMathisLab MMathisLab merged commit 5511f7d into main Mar 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request versioning Issue, fix or feature related to dependencies or plugin version(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants