Replace deprecated pkg_resources with packaging.requirements#6239
Open
junagent wants to merge 1 commit intojina-ai:masterfrom
Open
Replace deprecated pkg_resources with packaging.requirements#6239junagent wants to merge 1 commit intojina-ai:masterfrom
junagent wants to merge 1 commit intojina-ai:masterfrom
Conversation
Replace deprecated pkg_resources.Requirement with packaging.requirements Requirement (already a core dependency: packaging>=20.0). Changes: - from pkg_resources import Requirement -> from packaging.requirements import Requirement - Requirement.parse(line) -> Requirement(line) - .project_name -> .name setuptools 82 removed pkg_resources (PEP 740), making this dependency unreliable for newer Python installations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
pkg_resources.Requirementwithpackaging.requirements.Requirementininstall_requirements_helper.py.Problem
The file imports
Requirementfrom the deprecatedpkg_resourcesmodule:With setuptools 82 removing
pkg_resources(PEP 740), this import will break on newer Python installations.Fix
jinaalready haspackaging>=20.0as a core dependency, so the replacement is straightforward:from pkg_resources import Requirementfrom packaging.requirements import RequirementRequirement.parse(line)Requirement(line).project_name.nameThe
packaging.requirements.RequirementAPI is equivalent for parsing requirement strings and accessing name/extras attributes.Note: The
_is_requirements_installedfunction still usespkg_resources.require()for runtime dependency checking. This is a separate concern and not changed in this PR.