From de7ff5c10d0760e8819a66e0e7c1d57693029360 Mon Sep 17 00:00:00 2001 From: Thomas Roos Date: Sun, 8 Nov 2026 20:25:46 +0100 Subject: [PATCH] python3-haversine: keep working when numba fails to import numba is optional for haversine, but haversine only catches ModuleNotFoundError. With the NumPy 2.5 from OE-Core, numba 0.66 (as in meta-python-ai) raises ImportError: Numba needs NumPy 2.4 or less. Got NumPy 2.5. which makes "import haversine" fail. Catch ImportError instead. AI-Generated: Claude Code, Claude Opus 5.5 Signed-off-by: Thomas Roos Signed-off-by: Khem Raj --- ...-pure-Python-kernels-if-numba-fails-.patch | 40 +++++++++++++++++++ .../python/python3-haversine_2.9.0.bb | 1 + 2 files changed, 41 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-haversine/0001-Fall-back-to-the-pure-Python-kernels-if-numba-fails-.patch diff --git a/meta-python/recipes-devtools/python/python3-haversine/0001-Fall-back-to-the-pure-Python-kernels-if-numba-fails-.patch b/meta-python/recipes-devtools/python/python3-haversine/0001-Fall-back-to-the-pure-Python-kernels-if-numba-fails-.patch new file mode 100644 index 0000000000..6e20534799 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-haversine/0001-Fall-back-to-the-pure-Python-kernels-if-numba-fails-.patch @@ -0,0 +1,40 @@ +From 5f199ca92d651d653cb26b4fb6c48ba91137bec5 Mon Sep 17 00:00:00 2001 +From: Thomas Roos +Date: Sat, 7 Nov 2026 11:45:31 +0100 +Subject: [PATCH] Fall back to the pure Python kernels if numba fails to import + +numba is an optional accelerator, but importing it can fail with an +ImportError other than ModuleNotFoundError, for instance when the +installed NumPy is newer than numba supports: + + ImportError: Numba needs NumPy 2.4 or less. Got NumPy 2.5. + +That error escaped and made "import haversine" fail. Catch ImportError, +which also covers ModuleNotFoundError, so haversine keeps working +without numba. + +Upstream-Status: Submitted [https://github.com/mapado/haversine/pull/91] +AI-Generated: Claude Code, Claude Opus 5.5 +Signed-off-by: Thomas Roos +--- + haversine/haversine.py | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/haversine/haversine.py b/haversine/haversine.py +index a731188..687b602 100755 +--- a/haversine/haversine.py ++++ b/haversine/haversine.py +@@ -176,7 +176,9 @@ try: + _inverse_haversine_kernel_vector = numba.njit(fastmath=True)(_inverse_haversine_kernel_vector) + _haversine_kernel = numba.njit(_haversine_kernel) + _inverse_haversine_kernel = numba.njit(_inverse_haversine_kernel) +-except ModuleNotFoundError: ++except ImportError: ++ # numba is optional. Besides being absent, it can refuse to import, e.g. ++ # "Numba needs NumPy 2.4 or less", which must not break haversine. + pass + + +-- +2.56.0 + diff --git a/meta-python/recipes-devtools/python/python3-haversine_2.9.0.bb b/meta-python/recipes-devtools/python/python3-haversine_2.9.0.bb index 2dfb3356a7..439ff98371 100644 --- a/meta-python/recipes-devtools/python/python3-haversine_2.9.0.bb +++ b/meta-python/recipes-devtools/python/python3-haversine_2.9.0.bb @@ -2,6 +2,7 @@ SUMMARY = "Calculate the distance between 2 points on Earth" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://LICENSE;md5=20a52d2c688975e989fcbee3e6c8d1a1" +SRC_URI += "file://0001-Fall-back-to-the-pure-Python-kernels-if-numba-fails-.patch" SRC_URI[sha256sum] = "1103d7e1f0f108c25b31b63452c54d9d6f29389a70de7dd75fd4b908329b6fcf" inherit pypi setuptools3