Remove deprecated pkg_resources usage for setuptools >= 82 compatibility#473
Conversation
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #473 +/- ##
=====================================
Coverage ? 72%
=====================================
Files ? 17
Lines ? 751
Branches ? 0
=====================================
Hits ? 541
Misses ? 210
Partials ? 0 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
pkg resources dependencypkg_resources usage for setuptools >= 82 compatibility
pkg_resources usage for setuptools >= 82 compatibilitypkg_resources usage for setuptools >= 82 compatibility
There was a problem hiding this comment.
Pull request overview
This PR updates lightning_utilities to remain compatible with setuptools >= 82 by removing the deprecated/removed pkg_resources dependency and migrating requirement/version parsing to packaging.
Changes:
- Replaced
pkg_resourcesusage in requirements parsing withpackagingequivalents. - Switched version sorting/parsing from
distutils.version.LooseVersiontopackaging.version.Version. - Added unit tests covering requirements parsing and unfreeze strategies.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/lightning_utilities/install/requirements.py |
Replaces pkg_resources parsing/types and LooseVersion with packaging and adds a local yield_lines. |
setup.py |
Replaces pkg_resources.parse_requirements with a local parser based on packaging.Requirement. |
src/lightning_utilities/docs/formatting.py |
Uses packaging.version.Version for sorting PyPI versions. |
tests/unittests/install/test_requirements.py |
Adds unit tests for yield_lines, requirement parsing, and adjust() behavior. |
pyproject.toml |
Adds packaging to build-system requirements. |
CHANGELOG.md |
Documents the compatibility fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
for more information, see https://pre-commit.ci
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…orresponding tests
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
for more information, see https://pre-commit.ci
What does this PR do?
Fixes compatibility issue with setuptools >= 82 by removing
pkg_resourceswhich was removed in setuptools v82.0.0 (08 Feb 2026).Changes
pkg_resources.parse_requirementswithpackaging.requirements.Requirementpkg_resources.Requirementandyield_lineswithpackagingequivalentsdistutils.version.LooseVersionwithpackaging.version.Versionadjust()method to useself.specifierinstead of deprecatedself.specsWhy
pkg_resourceswas removed from setuptools v82.0.0, causing import errors. This PR migrates to thepackaginglibrary which is already a dependency.PR review
Anyone in the community is free to review the PR once the tests have passed.
Did you have fun?
Make sure you had fun coding 🙃
-->
📚 Documentation preview 📚: https://lit-utilities--473.org.readthedocs.build/en/473/