Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions recipes/numpy/test_numpy.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
def test_basic():
"""Smoke-test core ndarray creation and elementwise arithmetic."""
from numpy import array

assert (array([1, 2]) + array([3, 5])).tolist() == [4, 7]


def test_performance():
def test_matmul():
"""Exercise the dense matmul (GEMM) path and verify its result.

Asserts correctness, not speed. mobile-forge builds numpy WITHOUT OpenBLAS
(its config reports blas name="none"), so a dense matmul runs on the
unaccelerated fallback whose wall-clock time swings widely on loaded /
emulated devices and is not a reliable signal. The matmul `a @ I` must
equal `a`; the elapsed time is printed for visibility only.
"""
from time import time

import numpy as np

start_time = time()
SIZE = 500
a = np.random.rand(SIZE, SIZE)
b = np.random.rand(SIZE, SIZE)
np.dot(a, b)

# With OpenBLAS, the test devices take at most 0.4 seconds. Without OpenBLAS, they take
# at least 1.0 seconds.
start_time = time()
product = np.dot(a, np.eye(SIZE)) # full GEMM; a @ I == a
duration = time() - start_time
print(f"{duration:.3f}")
assert duration < 0.7

assert product.shape == (SIZE, SIZE)
assert np.allclose(product, a)


def test_fft():
Expand Down
8 changes: 4 additions & 4 deletions recipes/opencv-python/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ build:
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,max-page-size=16384"
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,-z,max-page-size=16384"
-DOPENCV_FORCE_PYTHON_LIBS=ON
-DPYTHON3_INCLUDE_PATH={prefix}/include/python{py_version_short}
-DPYTHON3_LIBRARIES={prefix}/lib/libpython{py_version_short}.so
-DPYTHON3_INCLUDE_PATH={HOST_PYTHON_HOME}/include/python{py_version_short}
-DPYTHON3_LIBRARIES={HOST_PYTHON_HOME}/lib/libpython{py_version_short}.so
-DPYTHON3_NUMPY_INCLUDE_DIRS={platlib}/numpy/_core/include
# {% else %}
CMAKE_ARGS: >-
Expand All @@ -56,7 +56,7 @@ build:
-DBUILD_EXAMPLES=OFF
-DWITH_OPENCL=OFF
-DOPENCV_FORCE_PYTHON_LIBS=ON
-DPYTHON3_INCLUDE_PATH={prefix}/include/python{py_version_short}
-DPYTHON3_LIBRARIES={prefix}/lib/libpython{py_version_short}.so
-DPYTHON3_INCLUDE_PATH={HOST_PYTHON_HOME}/include/python{py_version_short}
-DPYTHON3_LIBRARIES={HOST_PYTHON_HOME}/lib/libpython{py_version_short}.dylib
-DPYTHON3_NUMPY_INCLUDE_DIRS={platlib}/numpy/_core/include
# {% endif %}
7 changes: 7 additions & 0 deletions recipes/pandas/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ patches:

build:
number: 1
script_env:
# meson introspects numpy by running the cross-python from pandas's source
# dir, whose top-level `pandas/io/` shadows the stdlib `io` on sys.path[0]
# -> numpy's C-ext init fails ("cannot import name 'TextIOWrapper' from
# 'io'"). PYTHONSAFEPATH drops that implicit cwd entry (leaving PYTHONPATH,
# so crossenv's bridge still works).
PYTHONSAFEPATH: "1"
backend-args:
- -Csetup-args=--cross-file
- -Csetup-args={MESON_CROSS_FILE}
Expand Down
4 changes: 3 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ venv_dir="$(pwd)/venv$PYTHON_VER"
if [ ! -d $venv_dir ]; then
echo "Creating Python $PYTHON_VER virtual environment for build in $venv_dir..."

uv venv --seed --python="$PYTHON_VERSION" $venv_dir
# `--python-preference only-managed` forces uv to use a relocatable
# python-build-standalone interpreter and NEVER a system one.
uv venv --seed --python-preference only-managed --python="$PYTHON_VERSION" $venv_dir
source $venv_dir/bin/activate

uv pip install -e .
Expand Down
Loading