grafana-toolbox / grafana-client

Python client library for accessing the Grafana HTTP API.
MIT License
106 stars 30 forks source link

distutils.version.LooseVersion is deprecated #122

Closed foreverhy closed 1 year ago

foreverhy commented 1 year ago

Describe the bug Got an error

File /home/ffy/workspace/PyProjects/venv/lib/python3.12/site-packages/grafana_client/elements/dashboard.py:1
----> 1 from distutils.version import LooseVersion
      3 from .base import Base
      6 class Dashboard(Base):

ModuleNotFoundError: No module named 'distutils'

while import grafana_client in python 3.12. Based on PEP386, distutils is deprecated and we may have some alternatives.

To Reproduce Steps to reproduce the behavior:

  1. python 3.12
  2. import grafana_client

Expected behavior ModuleNotFoundError: No module named 'distutils'

Versions

Additional context

amotl commented 1 year ago

Hi @foreverhy,

thank you for writing in and reporting this. We will address this on the next iteration, and patches are always welcome.

With kind regards, Andreas.

amotl commented 1 year ago

When there are no objections, we will probably follow the same strategy like at crate-python, by vendoring packaging.version.

amotl commented 1 year ago

Dear @foreverhy,

GH-123 removes the dependency on distutils.version, and uses verlib2 instead, which is a standalone variant of packaging.version. grafana-client 3.9.2 has been released, including this improvement. Thank you again. 🌻

With kind regards, Andreas.