Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
deveshks opened this issue Jul 6, 2020 · 3 comments
Closed
Labels
S: needs triage Issues/PRs that need to be triaged type: maintenance Related to Development and Maintenance Processes

Comments

@deveshks
Copy link
Contributor

deveshks commented Jul 6, 2020

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.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Jul 6, 2020
@uranusjr
Copy link
Member

uranusjr commented Jul 6, 2020

I wonder if this is a good time to bring in #8114 as well since they both try to refactor out direct usages of pkg_resources.

@deveshks
Copy link
Contributor Author

deveshks commented Jul 6, 2020

I wonder if this is a good time to bring in #8114 as well since they both try to refactor out direct usages of pkg_resources.

I totally agree. You can now easily replace the custom get_distribution with the implemention in the afore mentioned PR, taking care of the last mention of pkg_resources.get_distribution with that.

@ichard26
Copy link
Member

This has been achieved since #8659 (comment).

@pfmoore pfmoore closed this as completed Mar 13, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S: needs triage Issues/PRs that need to be triaged type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

No branches or pull requests

5 participants