diff mbox series

[2/2] piglit: fix numpy 2.4.x compatibility

Message ID 20260106205438.994413-2-tgamblin@baylibre.com
State Under Review
Headers show
Series [1/2] piglit: upgrade to latest revision | expand

Commit Message

Trevor Gamblin Jan. 6, 2026, 8:54 p.m. UTC
numpy has removed the deprecated 'newshape' parameter from its reshape()
function, which is causing piglit build failures like:

|   File "/srv/pokybuild/yocto-worker/musl-qemux86-64/build/build/tmp/work/x86-64-v3-poky-linux-musl/piglit/1.0+gitr/sources/piglit-1.0+gitr/generated_tests/builtin_function_fp64.py", line 536, in _simulate_function
|     expected_output = python_equivalent(*inputs)
|   File "/srv/pokybuild/yocto-worker/musl-qemux86-64/build/build/tmp/work/x86-64-v3-poky-linux-musl/piglit/1.0+gitr/sources/piglit-1.0+gitr/generated_tests/builtin_function_fp64.py", line 311, in _divide
|     if any(y_element == 0 for y_element in column_major_values(y)):
|                                            ~~~~~~~~~~~~~~~~~~~^^^
|   File "/srv/pokybuild/yocto-worker/musl-qemux86-64/build/build/tmp/work/x86-64-v3-poky-linux-musl/piglit/1.0+gitr/sources/piglit-1.0+gitr/generated_tests/builtin_function_fp64.py", line 257, in column_major_values
|     return list(np.reshape(value, newshape=-1, order='F'))
|                 ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| TypeError: reshape() got an unexpected keyword argument 'newshape'

Backport a patch (submitted upstream) to replace that keyword with
'shape' as per numpy guidelines.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 ...tests-use-shape-in-place-of-newshape.patch | 64 +++++++++++++++++++
 meta/recipes-graphics/piglit/piglit_git.bb    |  1 +
 2 files changed, 65 insertions(+)
 create mode 100644 meta/recipes-graphics/piglit/piglit/0001-generated_tests-use-shape-in-place-of-newshape.patch
diff mbox series

Patch

diff --git a/meta/recipes-graphics/piglit/piglit/0001-generated_tests-use-shape-in-place-of-newshape.patch b/meta/recipes-graphics/piglit/piglit/0001-generated_tests-use-shape-in-place-of-newshape.patch
new file mode 100644
index 0000000000..1e7c8a6394
--- /dev/null
+++ b/meta/recipes-graphics/piglit/piglit/0001-generated_tests-use-shape-in-place-of-newshape.patch
@@ -0,0 +1,64 @@ 
+From 461d9d60b0713fdacdb2f4c8756b7fb5f0389ee8 Mon Sep 17 00:00:00 2001
+From: Trevor Gamblin <tgamblin@baylibre.com>
+Date: Tue, 6 Jan 2026 15:25:26 -0500
+Subject: [PATCH] generated_tests: use 'shape' in place of 'newshape'
+
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/1063]
+
+The 'newshape' parameter was deprecated upstream but kept for backwards
+compatibility reasons. It was finally removed as of numpy 2.4.0, so
+transition to using 'shape' in its place.
+
+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
+---
+ generated_tests/builtin_function.py      | 4 ++--
+ generated_tests/builtin_function_fp64.py | 4 ++--
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/generated_tests/builtin_function.py b/generated_tests/builtin_function.py
+index 093c4167f..0a740f603 100644
+--- a/generated_tests/builtin_function.py
++++ b/generated_tests/builtin_function.py
+@@ -293,7 +293,7 @@ def column_major_values(value):
+     """Given a native numpy value, return a list of the scalar values
+     comprising it, in column-major order."""
+     if isinstance(value, np.ndarray):
+-        return list(np.reshape(value, newshape=-1, order='F'))
++        return list(np.reshape(value, shape=-1, order='F'))
+     else:
+         return [value]
+ 
+@@ -301,7 +301,7 @@ def column_major_values(value):
+ def glsl_constant(value):
+     """Given a native numpy value, return GLSL code that constructs
+     it."""
+-    column_major = np.reshape(np.array(value), newshape=-1, order='F')
++    column_major = np.reshape(np.array(value), shape=-1, order='F')
+     if column_major.dtype == bool:
+         values = ['true' if x else 'false' for x in column_major]
+     elif column_major.dtype == np.int64:
+diff --git a/generated_tests/builtin_function_fp64.py b/generated_tests/builtin_function_fp64.py
+index 84d939c11..65a7b4468 100644
+--- a/generated_tests/builtin_function_fp64.py
++++ b/generated_tests/builtin_function_fp64.py
+@@ -254,7 +254,7 @@ def column_major_values(value):
+     """Given a native numpy value, return a list of the scalar values
+     comprising it, in column-major order."""
+     if isinstance(value, np.ndarray):
+-        return list(np.reshape(value, newshape=-1, order='F'))
++        return list(np.reshape(value, shape=-1, order='F'))
+     else:
+         return [value]
+ 
+@@ -262,7 +262,7 @@ def column_major_values(value):
+ def glsl_constant(value):
+     """Given a native numpy value, return GLSL code that constructs
+     it."""
+-    column_major = np.reshape(np.array(value), newshape=-1, order='F')
++    column_major = np.reshape(np.array(value), shape=-1, order='F')
+     if column_major.dtype == bool:
+         values = ['true' if x else 'false' for x in column_major]
+     else:
+-- 
+2.52.0
+
diff --git a/meta/recipes-graphics/piglit/piglit_git.bb b/meta/recipes-graphics/piglit/piglit_git.bb
index f8cf7aa889..7096a38a4a 100644
--- a/meta/recipes-graphics/piglit/piglit_git.bb
+++ b/meta/recipes-graphics/piglit/piglit_git.bb
@@ -13,6 +13,7 @@  SRC_URI = "git://gitlab.freedesktop.org/mesa/piglit.git;protocol=https;branch=ma
            file://0001-CMakeLists.txt-do-not-obtain-wayland-scanner-path-fr.patch \
            file://0001-tests-egl-spec-make-egl_ext_surface_compression-cond.patch \
            file://0001-tests-no_error.py-modify-_command-and-not-command.patch \
+	   file://0001-generated_tests-use-shape-in-place-of-newshape.patch \
            "
 UPSTREAM_CHECK_COMMITS = "1"