From 570d566b844f070f587746bad10de31fb8d7fd8f Mon Sep 17 00:00:00 2001 From: Ewen Le Bihan Date: Thu, 11 Jul 2024 17:42:49 +0200 Subject: [PATCH] partially stub out numba functions See https://github.com/librosa/librosa/issues/1854 diff --git a/librosa/__init__.py b/librosa/__init__.py index f1b9b6a4f2..8690f1acfb 100644 --- librosa/__init__.py +++ librosa/__init__.py @@ -209,6 +209,33 @@ set_fftlib """ +# Mock numba functions, see https://github.com/librosa/librosa/issues/1854 + +import sys +from unittest.mock import MagicMock +import sys + +def no_op_decorator(*args, **kwargs): + # print(f"running fake jit with args={args} and kwargs={kwargs}") + def dec(func): + return func + return dec + +def unsupported_decorator(name: str): + def decorator(*args, **kwargs): + def dec(func): + print(f"WARN: running unsupported numba decorator {orig_name}! with args={args} and kwargs={kwargs}") + return func + return dec + return decorator + +# Create a mock numba module with a no-op jit decorator +sys.modules['numba'] = MagicMock() +sys.modules['numba'].jit = no_op_decorator +# will not work when used, but allows importing without crashes +for attr_name in {'guvectorize', 'vectorize', 'stencil'}: + sys.modules['numba'][attr_name] = unsupported_decorator + import lazy_loader as lazy from .version import version as __version__ diff --git a/setup.cfg b/setup.cfg index b82079618b..a35a9d5fd3 100644 --- setup.cfg +++ setup.cfg @@ -60,7 +60,6 @@ include_package_data = True install_requires = audioread >= 2.1.9 - numba >= 0.51.0 numpy >= 1.22.3 scipy >= 1.6.0 scikit-learn >= 1.1.0 @@ -88,7 +87,6 @@ numpydoc sphinx != 1.3.1 sphinx_rtd_theme>=1.2.0 - numba >= 0.51 matplotlib >= 3.5.0 sphinx-multiversion >= 0.2.3 sphinx-gallery >= 0.7 @@ -137,9 +135,6 @@ [mypy-matplotlib.*] ignore_missing_imports = True -[mypy-numba.*] -ignore_missing_imports = True - [mypy-decorator.*] ignore_missing_imports = True