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

ENH: migrate from pkg_resources to importlib.resources on Python 3.9+ #4292

Merged

Conversation

neutrinoceros
Copy link
Member

PR Summary

fix #4287
Turns out it was super easy, barely an inconvenience.

setupext.py Outdated
@@ -205,7 +204,7 @@ def check_for_pyembree(std_libs):
embree_libs = []
embree_aliases = {}
try:
_ = resource_filename("pyembree", "rtcore.pxd")
_ = importlib.resources.files("pyembree") / "rtcore.pxd"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't need changes on the pyembree side, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't. It works exactly like pkg_resources except that it returns a Path object instead of a string.
In hindsight it's completely useless (in both implementations) to look for an exact file like we do here, because both implementations are happy to produce a path to a file even if it's not there (though they do error with ModuleNotFoundError if pyembree isn't installed).

@neutrinoceros
Copy link
Member Author

neutrinoceros commented Jan 10, 2023

Of course the functions I need were not in the standard library before Python 3.9... adding compatibility for Python 3.8

@neutrinoceros neutrinoceros force-pushed the migrate_away_from_pkg_resources branch 2 times, most recently from 3c2c896 to 8c32a23 Compare January 10, 2023 22:37
@neutrinoceros neutrinoceros added enhancement Making something better infrastructure Related to CI, versioning, websites, organizational issues, etc and removed infrastructure Related to CI, versioning, websites, organizational issues, etc labels Jan 10, 2023
@neutrinoceros neutrinoceros force-pushed the migrate_away_from_pkg_resources branch 2 times, most recently from 202e6b2 to 71d63ee Compare January 10, 2023 22:50
@neutrinoceros neutrinoceros changed the title MNT: migrate from pkg_resources to importlib.resources MNT: migrate from pkg_resources to importlib.resources on Python 3.9+ Jan 10, 2023
@neutrinoceros neutrinoceros marked this pull request as ready for review January 10, 2023 23:35
@neutrinoceros neutrinoceros changed the title MNT: migrate from pkg_resources to importlib.resources on Python 3.9+ ENH: migrate from pkg_resources to importlib.resources on Python 3.9+ Jan 11, 2023
@neutrinoceros neutrinoceros merged commit 010617b into yt-project:main Jan 14, 2023
@neutrinoceros neutrinoceros deleted the migrate_away_from_pkg_resources branch January 14, 2023 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Making something better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: drop pkg_resources ?
3 participants