hpy icon indicating copy to clipboard operation
hpy copied to clipboard

fix deprecated pkg_resources

Open trim21 opened this issue 1 year ago • 15 comments

pkg_resources is deprecated.

Replace pkg_resources with importlib.resources, which available on python>=3.10.

https://setuptools.pypa.io/en/latest/pkg_resources.html

image

trim21 avatar May 22 '24 18:05 trim21

@trim21 Many tests failed. Any idea what we can do to fix them?

hodgestar avatar May 22 '24 21:05 hodgestar

@trim21 Many tests failed. Any idea what we can do to fix them?

I'm looking into it.

trim21 avatar May 22 '24 21:05 trim21

this works fine in my project but doesn't work in hpy testing, not sure why. looks like generated py file is imported in a very strange way.

trim21 avatar May 22 '24 21:05 trim21

this works fine in my project but doesn't work in hpy testing, not sure why. looks like generated py file is imported in a very strange way.

Many of the errors seem to come from import hpymod; print(hpymod.__doc__) which doesn't seem that strange.

hodgestar avatar May 22 '24 22:05 hodgestar

this works fine in my project but doesn't work in hpy testing, not sure why. looks like generated py file is imported in a very strange way.

Many of the errors seem to come from import hpymod; print(hpymod.__doc__) which doesn't seem that strange.

some tests just import package with python -m mod so the assumption of __package__ is not empty failed.

Just fixed

trim21 avatar May 22 '24 22:05 trim21

should works fine

trim21 avatar May 22 '24 22:05 trim21

ci is still broken, I'll fix this.

trim21 avatar May 25 '24 14:05 trim21

should works fine now, just test in my repo

image

trim21 avatar Jun 01 '24 21:06 trim21

Couldn't you just use the backport on Python < 3.10?

agronholm avatar Jun 03 '24 07:06 agronholm

Couldn't you just use the backport on Python < 3.10?

In that way developers(hpy users) will need to add extra pypi requiremenets to make it work, right?

trim21 avatar Jun 03 '24 08:06 trim21

In that way developers(hpy users) will need to add extra pypi requiremenets to make it work, right?

However pkg_resources (which is provided by setuptools) has already been an extra requirement. We can't assume setuptools is installed everywhere.

GalaxySnail avatar Jun 03 '24 09:06 GalaxySnail

Yeah, this is just swapping one requirement for another, and you should even make it conditionally installed only on Python < 3.10.

agronholm avatar Jun 03 '24 09:06 agronholm

In that way developers(hpy users) will need to add extra pypi requiremenets to make it work, right?

However pkg_resources (which is provided by setuptools) has already been an extra requirement. We can't assume setuptools is installed everywhere.

make sense

trim21 avatar Jun 03 '24 09:06 trim21

I'm not very familiar with hpy itself, where should I add importlib_resources requirements to make tests pass?

trim21 avatar Jun 03 '24 09:06 trim21

I'm not very familiar with hpy itself, where should I add importlib_resources requirements to make tests pass?

Presumably in setup.py where it has a requirement on setuptools?

agronholm avatar Jun 03 '24 09:06 agronholm

I do not have the time to complete this, feel free to cherry-pick.

trim21 avatar Nov 27 '24 22:11 trim21