hover2pi / svo_filters

A Python wrapper for the SVO Filter Profile Service
MIT License
13 stars 4 forks source link

Use `importlib_resources` instead of `pkg_resources`. #42

Open kelle opened 6 days ago

kelle commented 6 days ago

Getting lots of deprecation warnings in Python 3.11 due to the deprecation of pkg_resources. Please modify code to use importlib_resources instead.

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

For example:

file = resource_filename('sedkit', 'data/sources.txt')

becomes

file = importlib_resources.files('sedkit')/ 'data/sources.txt'
pmocz commented 6 days ago

possible gotcha: May need to use, e.g., str(importlib.resources.files('sedkit')/ 'data/sources.txt') in some cases for a quick fix, since I see this path is sometimes treated and manipulated as a string. importlib_resources.files returns a PosixPath object while resource_filename used to return a string