-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Remove pkg_resources #5007
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
base: main
Are you sure you want to change the base?
Remove pkg_resources #5007
Conversation
To be sure, this change is a big deal. It's been decades in the making to provide replacements for this functionality. There are known open issues and efforts to remove the dependence on pkg_resources and probably other use-cases that haven't migrated. My hope is that these cases can pin to Setuptools<81. I don't have any plans to rush this out or force it on the community, but I'd like to start thinking about what it would take to get committed. |
35e39e7
to
b3f9277
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much Jason for the effort in untangling the 2 code bases.
I agree that it is time to start thinking about the removal of pkg_resources
.
I propose we do it in 2 stages:
- Explicitly mention a "due date" to the warning message
- Removal once the "due date" arrives.
I have 2 doubts:
-
Does the
namespace_packages
(deprecated) keyword forsetup.py
works withoutpkg_resources.declare_namespace
?If I understood correctly previously these worked in tandem, but I don't know what is the situation now after the latest changes in https://github.com/pypa/setuptools/blob/v80.8.0/setuptools/namespaces.py#L47-L63.
-
Is the idea of https://github.com/pypa/pkg_resources to also publish something to PyPI? Even if the package is born deprecated it may be a "last-resort" alternative for users that rely on packages that have not received updates for a long time, or that are still working on the migration...
I know at least that folks from
zope
/plone
have been slowly trying to replacepkg_resources.declare_namespace
for a while, but are not there quite yet (refs: Should we add aDeprecationWarning
topkg_resources.declare_namespace
? #3434 (comment), Switch to PEP 420 (Implicit namespace packages) zopefoundation/meta#194), so maybe that would be useful if they take can install a package to extend the time they can work on the migration. We could also consider addingpkg_resources
insetuptools.build_meta:__legacy__.get_requires_for_build_sdist
if we want to be very conservative about the transition.Update: I can see in Setuptools should not rely on pkg_resources #3085 (comment) that this is not straight forward.
It's a mixed bag. If I recall correctly, when pip-installed, a declared namespace gets its Looking at zope.interface as an example:
The same is true for the wheel. These results confirm that, at least for the pip-installed packages, the use of pkg_resources is completely absent. This confirmation gives me higher confidence that this removal is at least safer than I'd previously thought. In fact, I wonder if
There was a time where even the -nspkg.pth file did nothing and fell back to PEP 420 on Python 3.3+. In 27b7d4e, however, I limited the PEP 420 fallback to Python 3.3 and 3.4. I didn't leave any good justification for making that change (no linked issue, no mention in changelog). Maybe it had something to do with #1214. I wonder if that change was a mistake and could have been allowed to simply fall back to PEP 420.
I guess it has to still be used for the editable case... at least where Confirmed - it's still used even for the modern editable case:
I'm less worried about the editable case, because it's outside the typical integration and production workflows and the developer has a lot more control to implement workarounds, such as to pin setuptools.
As you've observed, I was considering this option, but I'm still not confident it's the right thing to do. It would require getting the name opened up for use, which I'm fairly confident the maintainers would do for this purpose. But it would still require the users to install it. It wouldn't be installed implicitly as Setuptools is in some environments. And if they have the ability to install a custom
I'm good with that plan. I'll set the due date for 6 months and mark this PR as draft in the meantime. |
I started looking into this plan, but it seems that pkg_resources doesn't have any of the due date functionality of |
Thank you very much Jason for adding the due date and providing the review about the namespaces.
As a brainstorm: there is one possibility to make it "installed implicitly" in build environments. I mentioned in #3085 (comment) that we could return But I am not sure this direction is worth pursuing specially because Footnotes
|
Summary of changes
Closes #3085
Pull Request Checklist
newsfragments/
.(See documentation for details)