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

DeprecationWarning: pkg_resources is deprecated as an API. #419

Closed
honnorat opened this issue Dec 22, 2023 · 2 comments
Closed

DeprecationWarning: pkg_resources is deprecated as an API. #419

honnorat opened this issue Dec 22, 2023 · 2 comments
Labels
type: bug Something isn't working

Comments

@honnorat
Copy link

Use of pkg_resources is deprecated in favor of importlib.resources:

$ python -W always -c "import earthaccess"
/home/honnorat/usr/conda/envs/earthaccess/lib/python3.12/site-packages/earthaccess/formatters.py:4:
    DeprecationWarning: pkg_resources is deprecated as an API.
    See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources

The code in formatters.py:

import pkg_resources

STATIC_FILES = ["css/iso_bootstrap4.0.0min.css", "css/styles.css"]

def _load_static_files() -> List[str]:
    """Load styles"""
    return [
        pkg_resources.resource_string("earthaccess", fname).decode("utf8")
        for fname in STATIC_FILES
    ]

could be replaced by:

import importlib.resources

def _load_static_files() -> List[str]:
    """Load styles"""
    return [
        (
            importlib.resources.files("earthaccess") / fname
        ).read_text("utf8")
        for fname in STATIC_FILES
    ]
@mfisher87 mfisher87 added the type: bug Something isn't working label Dec 22, 2023
@mfisher87
Copy link
Collaborator

Thank you for the very detailed report! Would you be comfortable opening a pull request?

@chuckwondo
Copy link
Collaborator

Fixed by #497. (See also comment on #452 regarding importlib_resources, rather than importlib.resources).

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in earthaccess project Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants