hpyproject / hpy

HPy: a better API for Python
https://hpyproject.org
MIT License
1.02k stars 52 forks source link

fix deprecated pkg_resources #480

Open trim21 opened 4 months ago

trim21 commented 4 months ago

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

hodgestar commented 4 months ago

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

trim21 commented 4 months ago

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

I'm looking into it.

trim21 commented 4 months ago

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.

hodgestar commented 4 months ago

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.

trim21 commented 4 months ago

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 commented 4 months ago

should works fine

trim21 commented 4 months ago

ci is still broken, I'll fix this.

trim21 commented 4 months ago

should works fine now, just test in my repo

image

agronholm commented 4 months ago

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

trim21 commented 4 months ago

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?

GalaxySnail commented 4 months ago

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.

agronholm commented 4 months ago

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

trim21 commented 4 months ago

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 commented 4 months ago

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

agronholm commented 4 months ago

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?