Skip to content

Removing "pkg_resources.get_distribution" usage from pip's codebase #8550

Closed
@deveshks

Description

@deveshks

We have gotten rid of pkg_resources.get_distribution in almost all the places in pip's codebase in #8054 except one.

try:
self.satisfied_by = pkg_resources.get_distribution(str(no_marker))
except pkg_resources.DistributionNotFound:
return
except pkg_resources.VersionConflict:
existing_dist = get_distribution(
self.req.name
)
if use_user_site:
if dist_in_usersite(existing_dist):
self.should_reinstall = True
elif (running_under_virtualenv() and
dist_in_site_packages(existing_dist)):
raise InstallationError(
"Will not install to the user site because it will "
"lack sys.path precedence to {} in {}".format(
existing_dist.project_name, existing_dist.location)
)
else:
self.should_reinstall = True
else:
if self.editable and self.satisfied_by:
self.should_reinstall = True
# when installing editables, nothing pre-existing should ever
# satisfy
self.satisfied_by = None

The idea to get rid of pkg_resources.get_distribution from other places was taken from #8054 (comment) , but this was deferred to a follow-up PR given that the existing PR was already getting big, and it wasn't trivial to update the last function using that construct.

This issue is opened to drive discussion on how to implement the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: needs triageIssues/PRs that need to be triagedtype: maintenanceRelated to Development and Maintenance Processes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions