data-apis / array-api-compat

Compatibility layer for common array libraries to support the Array API
https://data-apis.org/array-api-compat/
MIT License
71 stars 23 forks source link

`cannot import name 'cache' from 'functools'` on Python 3.8 #186

Open njzjz opened 1 day ago

njzjz commented 1 day ago
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/array_api_compat/common/_helpers.py:516: in array_namespace
    from .. import torch as torch_namespace
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/array_api_compat/torch/__init__.py:15: in <module>
    from ._aliases import * # noqa: F403
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/array_api_compat/torch/_aliases.py:14: in <module>
    from ._info import __array_namespace_info__
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    """
    Array API Inspection namespace

    This is the namespace for inspection functions as defined by the array API
    standard. See
    https://data-apis.org/array-api/latest/API_specification/inspection.html for
    more details.

    """
    import torch

>   from functools import cache
E   ImportError: cannot import name 'cache' from 'functools' (/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/functools.py)

cache was added in Python 3.9.

I don't find the minimal Python version supported by array-api-compat, but if there is, it's better to add python_requires to the metadata.

asmeurer commented 5 hours ago

3.8 support was dropped 354e00735e2fc51e4825e7d66ea5d77db78d9af7, but I guess I should have maintained the python_requires. We can add 3.8 support back if it's helpful. I would have expected most projects to drop 3.8 since it's EOL (this month) https://devguide.python.org/versions/.

njzjz commented 4 hours ago

For my maintained project, I will drop Python 3.8 support. It's good to have the python_requires, though. It is disturbing when the CI suddenly reports errors.