pypa/pyproject-hooks

Tests fail on Python 3.11 due to importlib.resources DeprecationWarning

encukou opened this issue · 1 comments

Tests fail on Python 3.11:

pep517/in_process/__init__.py:14: in _in_proc_script_path
    return resources.path(__package__, '_in_process.py')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ('pep517.in_process', '_in_process.py'), kwargs = {}

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
>       warnings.warn(
            f"{func.__name__} is deprecated. Use files() instead. "
            "Refer to https://importlib-resources.readthedocs.io"
            "/en/latest/using.html#migrating-from-legacy for migration advice.",
            DeprecationWarning,
            stacklevel=2,
        )
E       DeprecationWarning: path is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.

/usr/lib64/python3.11/importlib/resources/_legacy.py:18: DeprecationWarning

The page mentioned in the error message is not helpful, and the current docs don't quite explain a non-deprecated way to get a file using importlib.resources (the Traversable API is not yet documented).

The code suggests a workaround of not using importlib.resources, however: the except clause works:

https://github.com/pypa/pep517/blob/a942316305395f8f757f210e2b16f738af73f8b8/pep517/in_process/__init__.py#L10-L18