Use of pkg_resources is deprecated in favor of importlib.resources, importlib.metadata and their backports (importlib_resources, importlib_metadata). Some useful APIs are also provided by packaging (e.g. requirements and version parsing). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.
Currently, Maubot has the following uses of pkg_resources:
Corresponds to as_file(files('maubot').joinpath('management/frontend/build')), but this is a context manager for use with with statement so it doesn't directly translate to the existing usage
The setuptools documentation mentions:
Currently, Maubot has the following uses of pkg_resources:
https://github.com/maubot/maubot/blob/0c72e6fb1e0dcbccc718cff60f02e951b2b2cc57/maubot/cli/util/spdx.py#L30-L33
Corresponds to
files('maubot.cli').joinpath('res/spdx.json.zip').open('rb')
(side note, wouldn't spdx.json.gz be a better option here?)
https://github.com/maubot/maubot/blob/0c72e6fb1e0dcbccc718cff60f02e951b2b2cc57/maubot/server.py#L104-L106
Corresponds to
as_file(files('maubot').joinpath('management/frontend/build'))
, but this is a context manager for use withwith
statement so it doesn't directly translate to the existing usagehttps://github.com/maubot/maubot/blob/0c72e6fb1e0dcbccc718cff60f02e951b2b2cc57/maubot/cli/commands/init.py#L20
https://github.com/maubot/maubot/blob/0c72e6fb1e0dcbccc718cff60f02e951b2b2cc57/maubot/cli/commands/init.py#L36-L38
Corresponds to
files('maubot.cli').joinpath(filename).read_text(encoding='utf-8')
This should be pretty easy to port over to importlib. That said, the pkg_resources API will stay available for the foreseeable future.