spacetelescope / gwcs

Generalized World Coordinate System: provides tools for managing WCS in a general way
https://gwcs.readthedocs.io/en/latest/
47 stars 48 forks source link

``pkg_resources.get_distribution`` is deprecated #477

Closed jobovy closed 1 year ago

jobovy commented 1 year ago

I was just hit by a deprecation warning that traced back to this package:

DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

This is caused by the use of pkg_resources.get_distribution here: https://github.com/spacetelescope/gwcs/blob/a1e3b6328a74e26ee16319de17003983609123aa/gwcs/__init__.py#L61-L66 The documentation's configuration file has a similar piece of code.

ChatGPT suggest a direct fix using importlib.metadata (but this only exists for Python >= 3.8, so need the importlib_metadata package for earlier versions of Python; actually, in your pyproject.toml file, I see that you have https://github.com/spacetelescope/gwcs/blob/a1e3b6328a74e26ee16319de17003983609123aa/pyproject.toml#L4 so maybe that's not a concern [but this requirement is not consistent with what's in __init__.py).

Other ways of fixing this could be either to follow the suggestion in #418 or to just directly define the version in the __init__.py file (and in the doc file) and keep it in sync using a tool such as bump2version.