pyfilesystem2 icon indicating copy to clipboard operation
pyfilesystem2 copied to clipboard

drop the final remaining use of the deprecated pkg_resources module

Open eli-schwartz opened this issue 1 year ago • 2 comments

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: https://github.com/PyFilesystem/pyfilesystem2/issues/577

Depends on: https://github.com/PyFilesystem/pyfilesystem2/pull/589

eli-schwartz avatar Sep 16 '24 04:09 eli-schwartz

Given the deprecation warning suggests pkg_resources will be removed november this year, are we able to renew the push for this again? :)

lib/python3.12/site-packages/fs/__init__.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resour
ces.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.

delfick avatar May 30 '25 23:05 delfick

I haven't given up on this PR by the way -- I am not aware of any issues with it though, so I'm just waiting for someone with commit access to review...

eli-schwartz avatar Jun 08 '25 03:06 eli-schwartz

@willmcgugan Can this be reviewed and merged?

svanscho avatar Jul 10 '25 10:07 svanscho

Depends on: #589

merged both branches in pkg-resources-part-1-and-2

edit: now this also includes #588

milahu avatar Jul 30 '25 07:07 milahu

pkg_resources is still used in tests/test_opener.py

this makes the test fail with NameError: name 'pkg_resources' is not defined

    def test_repr(self):
        # Check __repr__ works
        for entry_point in pkg_resources.iter_entry_points("fs.opener"):
            _opener = entry_point.load()
            repr(_opener())

fixed in https://github.com/milahu/pyfilesystem2/commit/70dc40dae57bbdb579f42cff30cb993a674018a0

milahu avatar Jul 30 '25 08:07 milahu

@milahu please see all my pending PRs, not just two of them. There is a third that fixes that in a very different way than the one you propose.

eli-schwartz avatar Jul 30 '25 12:07 eli-schwartz

ok, so this pr depends on #588 and #589

milahu avatar Jul 30 '25 15:07 milahu