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 7 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
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ def build_libraries(self, libraries):
cmdclass={"build_clib": build_clib_hpy},
use_scm_version=get_scm_config,
setup_requires=['setuptools_scm'],
install_requires=['setuptools>=64.0'],
install_requires=[
'setuptools>=64.0',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does hpy actually still need setuptools at run time after this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea, should I remove this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the code import either setuptools or pkg_resources anywhere in the code base after your changes? If not, you can remove the dependency.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly setuptools should never be a run-time dependency of any project. Its only legitimate use at the moment is as a build back-end.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like hpy.devel still require setuptools

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a separate project?

Copy link
Author

@trim21 trim21 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I have no idea what dependency should I have if I use hpy in universal mode........

it require hpy.universal to load dll, so it looks like I should install hpy.universal, and
indeed there is a hpy.universal package in pypi. but it doesn't look right, so I need to include whole hpy, including devel, trace and so on as runtime dependency for my package using hpy in universal mode?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is hpy.universal a separate project or is it somehow packaged separately from this project?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, if setuptools is directly imported by this project, it should be kept as a run-time dependency. At best it could be moved to extras if it's only used in some edge cases, provided that it's properly documented that way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is hpy.universal a separate project or is it somehow packaged separately from this project?

I don't know 🧐, didn't even successfully pack my hpy universal mode wheel yet.

'importlib_resources; python_version<"3.10"',
trim21 marked this conversation as resolved.
Show resolved Hide resolved
],
python_requires='>=3.8',
)