FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: DeprecationWarning for pkg_resources.declare_namespace usage in mpl_toolkit · Issue #25244 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: DeprecationWarning for pkg_resources.declare_namespace usage in mpl_toolkit #25244

Closed

Description

Bug summary

As of setuptools v67.3.0 the use of pkg_resources.declare_namespace in lib/mpl_toolkits/__init__.py raises a DeprecationWarning.

Code for reproduction

$ mamba create -n test python=3.10 matplotlib-base -y
$ mamba activate test
$ export PYTHONDEVMODE=1
$ python -c "import pkg_resources"

Actual outcome

/path/to/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2804: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
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)

Expected outcome

No output

Additional information

See also:
https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
https://packaging.python.org/en/latest/guides/packaging-namespace-packages/
https://peps.python.org/pep-0420/

Operating system

No response

Matplotlib Version

3.7.0

Matplotlib Backend

TkAgg

Python version

Python 3.10.9

Jupyter version

No response

Installation

conda

Activity

  1. tacaswell commented on Feb 17, 2023

    Member

    Is there a good guide for how to migrate from "old" namespace packages to "new" namespace packages? What is going to break if we just delete this __init__.py and how do we warn our users we are about to break them (I asked these in the linked setuptools issue as well)?

  2. added this to the v3.8.0 milestone on Feb 17, 2023
  3. added
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Feb 17, 2023
  4. tacaswell commented on Feb 18, 2023

    Member

    Medium difficulty because it requires understanding packaging related issues but good first issue because it requires no understanding of Matplotlib to do.

    Tasks:

    • sort out what even needs to be done (just delete the __init__.py?)
    • document if / how this will break any downstream packages and how they also need to migrate
    • add an API change note that we did this.
  5. neutrinoceros commented on Feb 20, 2023

    Contributor

    What is going to break if we just delete this init.py

    To answer this, I'll quote https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#native-namespace-packages

    It is extremely important that every distribution that uses the namespace package omits the init.py or uses a pkgutil-style init.py. If any distribution does not, it will cause the namespace logic to fail and the other sub-packages will not be importable.

    And from the same source:

    Warning While native namespace packages and pkgutil-style namespace packages are largely compatible, pkg_resources-style namespace packages are not compatible with the other methods. It’s inadvisable to use different methods in different distributions that provide packages to the same namespace.

    In other words, any dependent code that implements a mpl_toolkits.* subpackage will break immediately when the deprecated __init__.py is removed.
    It also seems that there is no way for dependent code to support both implementations of namespace packages at the same time, so I assume they'll have to drop support for all versions of matplotlib previous to the one that does the change... or renounce supporting that version and newer ones.

    I haven't found a solution to warn about the transition from within matplotlib, so currently my recommendation would be to just reach out to downstream developers by any means appropriate.
    Is there a list of such sub packages somewhere that'd be relevant ? there seem to be only one on PyPI (https://pypi.org/project/mpl-toolkits.clifford/)

  6. ssbarnea commented on Mar 1, 2023

    I remember facing this issue few years back and the conclusion was to avoid using namespaces in general. Much safer and you do not depend on someone else which could break you.

  7. tacaswell commented on Mar 1, 2023

    Member

    Per pypa/setuptools#3434 (comment) it seems we can just delete the __init__.py files and everything will be OK.

  8. BabaYaga1221 commented on Mar 12, 2023

    @tacaswell I just look the same resource on python version 3.10.10 and the excepted outcome was verified. I think that it just needs to update python to a newer version.

    correct me if I am wrong. Thanks

  9. tacaswell commented on Mar 13, 2023

    Member

    @BabaYaga1221 The dependency is on the version of setuptools (not the version of Python).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues🌱 Good first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL