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

fix deprecated pkg_resources #480

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ different ABIs:

The resulting filename is e.g. ``simple.hpy0.so``.

require backport ``importlib_resources>=5.0`` on ``CPython<3.10``.

HPy Hybrid ABI

The HPy Hybrid ABI is essentially the same as the Universal ABI, with
Expand Down Expand Up @@ -324,7 +326,7 @@ of features. As on April 2023, the following milestones have been reached:
CPython.

- it is possible to load HPy Universal extensions on CPython, thanks to the
``hpy.universal`` package.
``hpy.universal`` package (require ``importlib_resources>=5.0`` on ``CPython<3.10``).

- it is possible to load HPy Universal extensions on
PyPy (using the PyPy `hpy branch <https://foss.heptapod.net/pypy/pypy/tree/branch/hpy>`_).
Expand Down
35 changes: 27 additions & 8 deletions hpy/devel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,37 @@ def handle_hpy_ext_modules(dist, attr, hpy_ext_modules):
_HPY_UNIVERSAL_MODULE_STUB_TEMPLATE = """
# DO NOT EDIT THIS FILE!
# This file is automatically generated by hpy

def __bootstrap__():

from sys import modules
from os import environ
from pkg_resources import resource_filename
from sys import modules, version_info
from os import path, environ
from hpy.universal import _load_bootstrap
ext_filepath = resource_filename(__name__, {ext_file!r})
m = _load_bootstrap({module_name!r}, __name__, __package__, ext_filepath,
__loader__, __spec__, environ)

ext_name = {ext_file!r}
module_name = {module_name!r}

if version_info < (3, 10):
import importlib_resources as resources
else:
from importlib import resources

if not __package__:
# directly called with python -m
ext_filepath = path.join(path.dirname(__file__), ext_name)
else:
ext_filepath = resources.files(__package__).joinpath(ext_name)
trim21 marked this conversation as resolved.
Show resolved Hide resolved

m = _load_bootstrap(
module_name,
__name__,
__package__,
str(ext_filepath),
__loader__,
__spec__,
environ,
)
modules[__name__] = m


__bootstrap__()
"""

Expand Down