array-api-compat icon indicating copy to clipboard operation
array-api-compat copied to clipboard

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

Open njzjz opened this issue 1 year ago • 2 comments

/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.

njzjz avatar Oct 04 '24 19:10 njzjz

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/.

asmeurer avatar Oct 05 '24 21:10 asmeurer

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.

njzjz avatar Oct 05 '24 22:10 njzjz

I added python_requires back at https://github.com/data-apis/array-api-compat/pull/189.

asmeurer avatar Oct 16 '24 20:10 asmeurer