Migrate to pyproject.toml (PEP 518/621)#165
Conversation
… 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.
Delete the GNU Lesser General Public License v3 trove classifier from pyproject.toml to correct package metadata, following PEP 639
There was a problem hiding this comment.
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.cfgmetadata/dependency configuration. - Define project metadata, dependencies, entry points, and setuptools configuration under
[project]/[tool.setuptools]inpyproject.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".
There was a problem hiding this comment.
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.
|
@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. |
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:
[project]table is now used inpyproject.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.setuptoolsandsetuptools-scm, ensuring better support for modern Python features.setup.cfgas it is no longer required.Pre-commit configuration improvements:
pyproject-fmtfor automatic formatting ofpyproject.tomlfiles, andvalidate-pyprojectfor validating the correctness ofpyproject.toml. These help maintain a consistent and error-free project configuration.Tool configuration updates:
pyproject-fmtto enhance readability and ensure Python version classifiers are generated.