Skip to content

Remove deprecated pkg_resources usage for setuptools >= 82 compatibility#473

Merged
tchaton merged 14 commits intoLightning-AI:mainfrom
bhimrazy:fix/remove-pkg-resources
Feb 10, 2026
Merged

Remove deprecated pkg_resources usage for setuptools >= 82 compatibility#473
tchaton merged 14 commits intoLightning-AI:mainfrom
bhimrazy:fix/remove-pkg-resources

Conversation

@bhimrazy
Copy link
Collaborator

@bhimrazy bhimrazy commented Feb 10, 2026

What does this PR do?

Fixes compatibility issue with setuptools >= 82 by removing pkg_resources which was removed in setuptools v82.0.0 (08 Feb 2026).

Changes

  • setup.py: Replaced pkg_resources.parse_requirements with packaging.requirements.Requirement
  • requirements.py:
    • Replaced pkg_resources.Requirement and yield_lines with packaging equivalents
    • Replaced distutils.version.LooseVersion with packaging.version.Version
    • Updated adjust() method to use self.specifier instead of deprecated self.specs
  • tests: Added comprehensive unit tests for requirements parsing

Why

pkg_resources was removed from setuptools v82.0.0, causing import errors. This PR migrates to the packaging library 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/

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@0701f88). Learn more about missing BASE report.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added the tests label Feb 10, 2026
@bhimrazy bhimrazy changed the title drop pkg resources dependency Remove deprecated pkg_resources usage for setuptools >= 82 compatibility Feb 10, 2026
@bhimrazy bhimrazy changed the title Remove deprecated pkg_resources usage for setuptools >= 82 compatibility Remove deprecated pkg_resources usage for setuptools >= 82 compatibility Feb 10, 2026
Copy link
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 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_resources usage in requirements parsing with packaging equivalents.
  • Switched version sorting/parsing from distutils.version.LooseVersion to packaging.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.

bhimrazy and others added 5 commits February 10, 2026 15:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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 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.

@bhimrazy bhimrazy requested a review from Borda February 10, 2026 12:21
@tchaton tchaton merged commit 196f271 into Lightning-AI:main Feb 10, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants