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
Changes from 4 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
23 changes: 15 additions & 8 deletions hpy/devel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,23 @@ 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 environ, path
from contextlib import nullcontext
from importlib import resources
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}
if not __package__:
# directly called with python -m
ctx = nullcontext(path.join(path.dirname(__file__), ext_name))
elif version_info < (3, 9):
ctx = resources.path(__package__, ext_name)
else:
ctx = nullcontext(resources.files(__package__).joinpath(ext_name))
with ctx as ext_filepath:
m = _load_bootstrap({module_name!r}, __name__, __package__, str(ext_filepath),
__loader__, __spec__, environ)
modules[__name__] = m

__bootstrap__()
Expand Down
Loading