aesara-devs / aesara

Aesara is a Python library for defining, optimizing, and efficiently evaluating mathematical expressions involving multi-dimensional arrays.
https://aesara.readthedocs.io
Other
1.17k stars 156 forks source link

Python 3.12 import failure: `ModuleNotFoundError: No module named 'numpy.distutils'` #1520

Open mgorny opened 7 months ago

mgorny commented 7 months ago

Description of your problem or feature request

When attempting to load tests on Python 3.12, aesara/link/c/cmodule.py fails to import because of missing numpy.distutils module. This module is deprecated and has been removed from numpy for Python 3.12.

Please provide the full tracebacks for any relevant errors and/or warning messages.

$ python -m pytest --ignore tests/link/numba -x
========================================================= test session starts =========================================================
platform linux -- Python 3.12.0, pytest-7.4.3, pluggy-1.3.0
rootdir: /tmp/aesara
configfile: pyproject.toml
testpaths: tests/
collected 0 items / 1 error                                                                                                           

=============================================================== ERRORS ================================================================
______________________________________________ ERROR collecting tests/test_breakpoint.py ______________________________________________
ImportError while importing test module '/tmp/aesara/tests/test_breakpoint.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
aesara/configparser.py:234: in fetch_val_for_key
    return self._aesara_cfg.get(section, option)
/usr/lib/python3.12/configparser.py:759: in get
    d = self._unify_values(section, vars)
/usr/lib/python3.12/configparser.py:1130: in _unify_values
    raise NoSectionError(section) from None
E   configparser.NoSectionError: No section: 'blas'

During handling of the above exception, another exception occurred:
aesara/configparser.py:350: in __get__
    val_str = cls.fetch_val_for_key(self.name, delete_key=delete_key)
aesara/configparser.py:238: in fetch_val_for_key
    raise KeyError(key)
E   KeyError: 'blas__ldflags'

During handling of the above exception, another exception occurred:
aesara/link/c/cmodule.py:2726: in default_blas_ldflags
    blas_info = np.__config__.get_info("blas_opt")
E   AttributeError: module 'numpy.__config__' has no attribute 'get_info'

During handling of the above exception, another exception occurred:
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_breakpoint.py:3: in <module>
    from aesara.breakpoint import PdbBreakpoint
aesara/__init__.py:120: in <module>
    from aesara import scalar, tensor
aesara/tensor/__init__.py:106: in <module>
    from aesara.tensor import (  # noqa
aesara/tensor/blas.py:162: in <module>
    from aesara.tensor.blas_headers import blas_header_text, blas_header_version
aesara/tensor/blas_headers.py:1015: in <module>
    if not config.blas__ldflags:
aesara/configparser.py:354: in __get__
    val_str = self.default()
aesara/link/c/cmodule.py:2728: in default_blas_ldflags
    import numpy.distutils.system_info
E   ModuleNotFoundError: No module named 'numpy.distutils'
======================================================= short test summary info =======================================================
ERROR tests/test_breakpoint.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================== 1 error in 2.09s ===========================================================

Please provide any additional information below.

Versions and main components

Aesara config: (fails due to missing numpy.distutils)