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

pkg_resources deprecation in Python 3.12 #40

Open
stephanwindischmann opened this issue Sep 30, 2024 · 0 comments
Open

pkg_resources deprecation in Python 3.12 #40

stephanwindischmann opened this issue Sep 30, 2024 · 0 comments

Comments

@stephanwindischmann
Copy link

stephanwindischmann commented Sep 30, 2024

  • aws-msk-iam-sasl-signer-python version: 1.0.1
  • Python version: 3.12.4
  • Operating System: Ubuntu 22.04
  • Method of installation: pip

Description

pkg_resources was removed in Python 3.12 and offloaded into the setuptools library. The recommendation (see https://setuptools.pypa.io/en/latest/pkg_resources.html) is to use importlib.metadata.

Deprecatin warning:

/home/windi/.pyenv/versions/3.12.4/lib/python3.12/site-packages/aws_msk_iam_sasl_signer/MSKAuthTokenProvider.py:11: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources

It is a fairly trivial fix, just replace return f"{LIB_NAME}/{pkg_resources.get_distribution(LIB_NAME).version}" in __get_user_agent__() with return f"{LIB_NAME}/{importlib.metadata.version(LIB_NAME)}"
e.g.,

import importlib.metadata

# …

def __get_user_agent__():
    """
    Builds the user-agent

    Returns:
        str: The user-agent identifying this signer library.
    """
    return f"{LIB_NAME}/{importlib.metadata.version(LIB_NAME)}"
benwebber added a commit to benwebber/aws-msk-iam-sasl-signer-python that referenced this issue Nov 22, 2024
benwebber added a commit to benwebber/aws-msk-iam-sasl-signer-python that referenced this issue Nov 22, 2024
benwebber added a commit to benwebber/aws-msk-iam-sasl-signer-python that referenced this issue Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant