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 pkg_resources with importlib.metadata #1672

Closed
seisman opened this issue Dec 17, 2021 · 1 comment · Fixed by #1674
Closed

Replace pkg_resources with importlib.metadata #1672

seisman opened this issue Dec 17, 2021 · 1 comment · Fixed by #1674
Labels
maintenance Boring but important stuff for the core devs
Milestone

Comments

@seisman
Copy link
Member

seisman commented Dec 17, 2021

Description of the problem

from pkg_resources import get_distribution

In __init__.py, we use the get_distribution function from the pkg_resources module to get the version string of the PyGMT package.

It seems, pkg_resources is no longer recommended.

https://setuptools.pypa.io/en/latest/pkg_resources.html

Use of pkg_resources is discouraged in favor of importlib.resources, importlib.metadata, and their backports (resources, metadata). Please consider using those libraries instead of pkg_resources.

https://github.com/pypa/setuptools_scm#retrieving-package-version-at-runtime

Alternatively, you can use pkg_resources which is included in setuptools (but has a significant runtime cost):

I think we should use importlib.metadata instead:

from importlib.metadata import version
__version__ = version("pygmt")

The importlib.metadata module was added in Python 3.8, but PyGMT currently still supports Python 3.7. Luckily, we're going to drop Python 3.7 support on Dec. 26, 2021 as per NEP29, so it won't be a problem for us.

@seisman seisman added the maintenance Boring but important stuff for the core devs label Dec 17, 2021
michaelgrund added a commit that referenced this issue Dec 19, 2021
Address #1672 

If I understood it correctly this PR should not be merged before we drop Python 3.7 suppoort next week on Dec. 26, 2021.
@weiji14 weiji14 added this to the 0.6.0 milestone Dec 20, 2021
@weiji14 weiji14 linked a pull request Dec 20, 2021 that will close this issue
6 tasks
@weiji14
Copy link
Member

weiji14 commented Dec 20, 2021

Closed by #1674

@weiji14 weiji14 closed this as completed Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants