Page MenuHomePhabricator

pkg_resources is deprecated as an API
Closed, ResolvedPublic

Description

pkg_resources is deprecated with newer setuptools:

pywikibot/tools/__init__.py:25
  /home/runner/work/pywikibot/pywikibot/pywikibot/tools/__init__.py:25: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources
IMPORTANT: 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.

See: https://setuptools.pypa.io/en/latest/pkg_resources.html

Python 3.7 is required to use importlib.resources and importlib.metadata needs Python 3,8

The Pywikibot's usage can be found at
https://codesearch.wmcloud.org/pywikibot/?q=pkg_resources&files=&excludeFiles=&repos=

Maybe importlib.metadata should be used to import the package. See also:

Event Timeline

Xqt triaged this task as Medium priority.Jun 28 2023, 12:51 PM
This comment was removed by Xqt.
This comment was removed by Xqt.
Xqt updated the task description. (Show Details)

Change 985365 had a related patch set uploaded (by JJMC89; author: JJMC89):

[pywikibot/core@master] replace pkg_resources with importlib.metadata and packaging

https://gerrit.wikimedia.org/r/985365

Change 985365 merged by jenkins-bot:

[pywikibot/core@master] replace pkg_resources with importlib.metadata and packaging

https://gerrit.wikimedia.org/r/985365

Change 987776 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [cleanup] No longer require setuptools because packaging is used

https://gerrit.wikimedia.org/r/987776

Change 987776 merged by jenkins-bot:

[pywikibot/core@master] [cleanup] No longer require setuptools because packaging is used

https://gerrit.wikimedia.org/r/987776