Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of deprecated module pkg_resources #577

Open
matrss opened this issue Aug 23, 2023 · 2 comments · May be fixed by #590
Open

Remove usage of deprecated module pkg_resources #577

matrss opened this issue Aug 23, 2023 · 2 comments · May be fixed by #590

Comments

@matrss
Copy link

matrss commented Aug 23, 2023

Pyfilesystem2 makes use of this module which got deprecated at some point. This leads to noisy DeprecationWarning's in the test suite of a project using pyfilesystem2.

To reproduce:

>>> import warnings
>>> warnings.resetwarnings()
>>> import fs
/home/icg149/mambaforge/envs/fs-report/lib/python3.11/site-packages/fs/__init__.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__("pkg_resources").declare_namespace(__name__)  # type: ignore
/home/icg149/mambaforge/envs/fs-report/lib/python3.11/site-packages/fs/__init__.py:4: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('fs')`.
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
  __import__("pkg_resources").declare_namespace(__name__)  # type: ignore
/home/icg149/mambaforge/envs/fs-report/lib/python3.11/site-packages/fs/opener/__init__.py:6: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('fs.opener')`.
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
  __import__("pkg_resources").declare_namespace(__name__)  # type: ignore
/home/icg149/mambaforge/envs/fs-report/lib/python3.11/site-packages/pkg_resources/__init__.py:2350: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('fs')`.
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)
@matrss matrss changed the title Remove usage of deprecated method pkg_resources.declare_namespace Remove usage of deprecated module pkg_resources Aug 24, 2023
@matrss
Copy link
Author

matrss commented Aug 24, 2023

I just now saw that there is PR #553 for this.

@mxmlnkn
Copy link

mxmlnkn commented Sep 15, 2024

Python 3.12 did remove pkg_resources. Pyfilesystem2 can still be installed, but importing it will fail because of the removed pkg_resources.

eli-schwartz added a commit to eli-schwartz/pyfilesystem2 that referenced this issue Sep 16, 2024
We wrap a couple different versions of the stdlib interface, and fall
back to pkg_resources for compatibility with existing use cases on very
old versions of python.

For python 3.8 and on, we make sure to completely avoid external
dependencies, even backports.

Bug: PyFilesystem#577
eli-schwartz added a commit to eli-schwartz/pyfilesystem2 that referenced this issue Sep 16, 2024
Declaring a namespace package has gone through a few revisions.
pkg_resources has a version that is heavily deprecated. pkgutil provides
a python2/python3 compatible version that is also compatible with native
python3 namespaces.

https://packaging.python.org/en/latest/guides/packaging-namespace-packages/

pkg_resources is very very deprecated and importing or using it results
in deprecation warnings. It's time to move off of it entirely.

Fixes: PyFilesystem#577
eli-schwartz added a commit to eli-schwartz/pyfilesystem2 that referenced this issue Sep 16, 2024
Declaring a namespace package has gone through a few revisions.
pkg_resources has a version that is heavily deprecated. pkgutil provides
a python2/python3 compatible version that is also compatible with native
python3 namespaces.

https://packaging.python.org/en/latest/guides/packaging-namespace-packages/

pkg_resources is very very deprecated and importing or using it results
in deprecation warnings. It's time to move off of it entirely.

Fixes: PyFilesystem#577
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants