pyfilesystem2 icon indicating copy to clipboard operation
pyfilesystem2 copied to clipboard

`UserWarning: pkg_resources is deprecated as an API`

Open j93hahn opened this issue 7 months ago • 9 comments

I'm using fs==2.4.16 but whenever I import fs I get this error message:

/Users/jjahn/Desktop/Exa/monorepo/python/shared/exa_ml/.venv/lib/python3.10/site-packages/fs/__init__.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  __import__("pkg_resources").declare_namespace(__name__)  # type: ignore

It's caused by this line:

__import__("pkg_resources").declare_namespace(__name__)  # type: ignore

Just move to PEP420 implicit namespace packaging (no __init__.py file at all) and it will resolve this error. But it should get fixed before 2025-11-30 or users may have problems

j93hahn avatar Jun 17 '25 04:06 j93hahn

Doesn't the error also reference pinning setup-tools to a specific version? I fixed by pinning setup-tools to 80.4.0. You may have the more appropriate fix but I would have thought somewhere around here would have been the fix.

javitab avatar Jul 29 '25 17:07 javitab

duplicate of #577 fixed by #590

milahu avatar Jul 30 '25 07:07 milahu

duplicate of #577 fixed by #590

When is the release?

cadmi avatar Aug 06 '25 17:08 cadmi

When is the release?

First my PRs to fix this would need to be merged by a maintainer.

eli-schwartz avatar Aug 27 '25 05:08 eli-schwartz

Could we please get this fixed in a new release soon? That would give other projects time to update their dependencies to prevent breakage in two months... At this point it's clear to me that this project is unmaintained, but if the maintainers don't even merge small pull requests anymore then please communicate that to signal that people should move away from this project.

malmeloo avatar Sep 15 '25 18:09 malmeloo

Could we please get this fixed in a new release soon?

can you please switch to a package manager that lets you build and install packages also from github, not just from pypi? example: fs.nix based on https://github.com/PyFilesystem/pyfilesystem2/pull/590#issuecomment-3135204107

or add some pyfilesystem2 branch as a gitmodule to your project

but waiting for nonexistant maintainers to fix some pypi release is... a waste of time

milahu avatar Sep 15 '25 19:09 milahu

My package manager can handle git dependencies just fine, but if I publish my library to pypi with a git dependency, some my users are bound to run into issues. I just want to avoid the additional support burden, so a PyPi release would be a much nicer solution 🙂

I'm looking for an in-memory filesystem provider, and unfortunately PyFilesystem appears to be pretty unique when it comes to that. On second thought however, I could probably use the builtin tarfile module with a bytesio object to accomplish that...

malmeloo avatar Sep 15 '25 19:09 malmeloo

I'm looking for an in-memory filesystem provider

fsspec memory? (https://github.com/fsspec/filesystem_spec/issues/1904)

milahu avatar Sep 15 '25 20:09 milahu

Oh nice! It's insane how difficult it is to find things through google nowadays...

That MemoryFS limitation is a bummer though, and unfortunately a dealbreaker I'm afraid... I see you've already started a PR to change that, but I don't think I have the time to continue that effort right now. For now I think (hope) I can make it work with tarfile

malmeloo avatar Sep 15 '25 20:09 malmeloo