MSS icon indicating copy to clipboard operation
MSS copied to clipboard

Ignore deprecation warnings for pkg_resources.declare_namespace usage

Open matrss opened this issue 2 years ago • 6 comments
trafficstars

These deprecation warnings in the CI runs come from dependencies which still use this deprecated method. There is not much we can do about this, apart from making sure they have a ticket about it in their respective issue tracker.

The following is the list of declared namespaces we see this warning coming from:

  • [X] fs (issue opened: https://github.com/PyFilesystem/pyfilesystem2/issues/577)
  • [X] fs.opener (see above)
  • [ ] xstatic (the github repo contains usage of this deprecated method, the installed package does not (?))
  • [ ] xstatic.pkg
  • [X] mpl_toolkits (fixed upstream: https://github.com/matplotlib/matplotlib/blob/a4dca24d04f928a9e614db403c716237446140b2/doc/users/next_whats_new/mpl_toolkit_pep420.rst)
  • [ ] mpl_toolkits.basemap_data
  • [ ] sphinxcontrib
  • [X] zope (tracked here: https://github.com/zopefoundation/meta/issues/194)

I'll tick these off as I make sure that the issue is handled or at least made aware of.

Apart from that I think we should just ignore this type of warning. That is also what others (xarray, ibis, SCT) are doing.

matrss avatar Aug 23 '23 14:08 matrss

after this is done we will have also updated versions https://github.com/Open-MSS/MSS/issues/1750

ReimarBauer avatar Aug 23 '23 14:08 ReimarBauer

Actually this issue seems to be happening only due to pyfilesystem2 using pkg_resources, which is entirely deprecated.

If you just use xstatic for example, there is no issue:

>>> import warnings
>>> warnings.resetwarnings()
>>> from xstatic.main import XStatic

but as soon as pkg_resources is imported with xstatic installed in the same environment:

>>> import warnings
>>> warnings.resetwarnings()
>>> import pkg_resources
<stdin>:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
/home/icg149/mambaforge/envs/xstatic-report/lib/python3.11/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('xstatic')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
/home/icg149/mambaforge/envs/xstatic-report/lib/python3.11/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('xstatic.pkg')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
/home/icg149/mambaforge/envs/xstatic-report/lib/python3.11/site-packages/pkg_resources/__init__.py:2350: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('xstatic')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(parent)

So I think getting that import removed from fs would silence all those DeprecationWarning's as well.

matrss avatar Aug 24 '23 11:08 matrss

See also

https://github.com/xstatic-py/xstatic/pull/14

ReimarBauer avatar Apr 11 '24 06:04 ReimarBauer

Not much we can do here, other than wait for fs to stop using this deprecated module, I think. I'll push this back to v10.

matrss avatar May 16 '24 08:05 matrss

pyfilesystem refactoring is a task in gsoc, shifting to the next major

ReimarBauer avatar Feb 22 '25 21:02 ReimarBauer

related https://github.com/xstatic-py/xstatic/issues/15

ReimarBauer avatar Apr 17 '25 09:04 ReimarBauer