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

Replace deprecated pkg_resources with stdlib #239

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

jeffwidman
Copy link
Member

pkg_resources has been deprecated by setuptools for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html

It's got some bugs/warts:

So switch to using importlib functions which are part of the Python standard library as of 3.8.

This is less error-prone, and also removes the need for setuptools to be installed in order for this panel to work.

I realize we technically still support 3.7, but I thought it was fine to change this particular panel to require 3.8, as 3.7 support is best effort given that it's now EOL'd by the core Python team.

I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to.

Note that importlib.metadata.distributions() does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that:

@jeffwidman
Copy link
Member Author

I started down this rabbit hole because I opened the Versions panel on 3.12 and it was blank saying "you need to install setuptools", which smelled wrong...

I don't think it's worth forcing the setuptools requirement for newer Pythons just so that this panel can work for Python 3.7.

@jeffwidman jeffwidman force-pushed the drop-deprecated-pkg_resources branch 3 times, most recently from 199974d to 883de37 Compare April 11, 2024 18:07
Base automatically changed from drop-deprecated-removed-distutils to master April 12, 2024 01:18
@jeffwidman jeffwidman force-pushed the drop-deprecated-pkg_resources branch 3 times, most recently from ce071d4 to b83967a Compare April 12, 2024 16:28
`pkg_resources` has been deprecated by `setuptools` for quite a while:
https://setuptools.pypa.io/en/latest/pkg_resources.html

It's got some bugs/warts:

* pypa/setuptools#2531
* https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182

So switch to using `importlib` functions which are part of the Python
standard library as of `3.8`.

This is less error-prone, and also removes the need for `setuptools` to
be installed in order for this panel to work.

I realize we technically still support `3.7`, but I thought it was fine
to change this particular panel to require `3.8`, as `3.7` support is
best effort given that it's now EOL'd by the core Python team.

I also removed the relative path location for specific libraries as it
was simply blank for me on Python 3.12... I think showing the location
of the site packages directory should suffice. If someone later wants to
build this out further, they're more than welcome to.

Note that `importlib.metadata.distributions()` does have an outstanding
issue that it reports a local editable install twice, but they plan to
eventually fix that:
* pypa/setuptools#4170
@jeffwidman jeffwidman force-pushed the drop-deprecated-pkg_resources branch from b83967a to 3ea2d48 Compare April 13, 2024 13:49
@jeffwidman jeffwidman enabled auto-merge (squash) April 13, 2024 13:49
@jeffwidman jeffwidman merged commit 7012193 into master Apr 13, 2024
10 checks passed
@jeffwidman jeffwidman deleted the drop-deprecated-pkg_resources branch April 13, 2024 13:54
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants