Repository navigation
Numba __init__.py not catching incompatible NumPy version early enough #8718
Copy link
Copy link
Closed
Labels
bug - build/packagingBugs: issue with building or packaging NumbaBugs: issue with building or packaging Numbabug - incorrect behaviorBugs: incorrect behaviorBugs: incorrect behavior
Milestone
Description
Reporting a bug
- I have tried using the latest released version of Numba (most recent is
visible in the change log (https://github.com/numba/numba/blob/main/CHANGE_LOG). - I have included a self contained code sample to reproduce the problem.
i.e. it's possible to run as 'python bug.py'.
Following on from numerous issues reported against #8615, no released version of Numba is compatible with NumPy 1.24, this is stated in the docs e.g.:
numba/docs/source/user/installing.rst
Line 281 in 288a38b
| | 0.56.4 | 2022-11-03 | 3.7.x <= version < 3.11 | 1.18 <= version < 1.24 | 0.39.x | 11.x | 2021.x | |
The problem in practice seems to be as follows:
- As of the version tags on the
release0.56branch of Numba (though this also probably impacts all Numba versions), all builds made against these tags are not compatible with NumPy 1.24 due to some changes in NumPyufuncobjects, see NumPy 1.24 #8691 for necessary adjustments. Essentially theresolve_dtypesmethod was added which tripped a piece of guard code in Numba that returns-1without anExceptionbeing set, this manifests as aSystemErroron import of the C extension containing this code. - Tools installing Numba wheels e.g.
pipare not constrained by the maximum NumPy version in metadata as they are incondapackages. The mechanism to prevent use of incompatible installations in this case is to raise anExceptionat runtime from Numba's__init__.py:called here:Lines 133 to 155 in 288a38b
def _ensure_critical_deps(): """ Make sure Python, NumPy and SciPy have supported versions. """ from numba.np.numpy_support import numpy_version from numba.core.utils import PYVERSION if PYVERSION < (3, 7): raise ImportError("Numba needs Python 3.7 or greater") if numpy_version < (1, 18): raise ImportError("Numba needs NumPy 1.18 or greater") elif numpy_version > (1, 23): raise ImportError("Numba needs NumPy 1.23 or less") try: import scipy except ImportError: pass else: sp_version = tuple(map(int, scipy.__version__.split('.')[:2])) if sp_version < (1, 0): raise ImportError("Numba requires SciPy version 1.0 or greater") Line 206 in 288a38b
_ensure_critical_deps()
I think the issue is that the mechanism in 2. fails if a C extension with the problem in 1. is imported as part of Numba's __init__ ahead of the call to _ensure_critical_deps. i.e. the check for compatibility of dependencies is too late.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug - build/packagingBugs: issue with building or packaging NumbaBugs: issue with building or packaging Numbabug - incorrect behaviorBugs: incorrect behaviorBugs: incorrect behavior
Activity
Make Numba dependency check run ahead of Numba internal imports.