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
181 changes: 0 additions & 181 deletions recipes/numpy/patches/mobile-1.26.0.patch

This file was deleted.

101 changes: 100 additions & 1 deletion recipes/numpy/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,101 @@
package:
name: numpy
name: numpy
# version: "" # Optional: leave empty to use latest

# Pip dependencies needed for building numpy
# Based on void-linux and conda-forge configurations:
# - Cython: Required for building numpy's extension modules
# - meson-python: Build backend (numpy uses meson build system since 1.26+)
# - build: PEP 517 build frontend (conda-forge uses python -m build)
pip_dependencies:
- Cython
- meson-python
- build

host_dependencies:
- python3-dev
- cmake

# Environment variables for the build
# PKG_CONFIG="" prevents finding host system libraries during cross-compilation
# This is critical for mobile cross-compilation to avoid linking against host libs
cibw_environment:
LDFLAGS: "-lm"
# PKG_CONFIG: ""
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out PKG_CONFIG setting creates ambiguity about whether it should be enabled. According to the comment on line 20-21, setting PKG_CONFIG="" is "critical for mobile cross-compilation to avoid linking against host libs", but it's currently disabled. This could lead to cross-compilation issues where host libraries are incorrectly detected. Either enable this setting or update the comment to explain why it's disabled.

Suggested change
# PKG_CONFIG: ""
PKG_CONFIG: ""

Copilot uses AI. Check for mistakes.

# Build script to set up cross-compilation
# For mobile platforms, we create a builddir and meson cross file
cibw_before_all: |
# Create build directory following conda-forge pattern
mkdir -p builddir
echo "Setting up numpy build for $CIBW_PLATFORM..."

# Create meson cross file for mobile platforms
if [ "$CIBW_PLATFORM" = "android" ] || [ "$CIBW_PLATFORM" = "ios" ]; then
echo "Building for mobile platform: $CIBW_PLATFORM with architecture: $CIBW_ARCHS"
echo "Using no-BLAS mode for simplified mobile builds"

# Determine CPU architecture for meson cross file
case "$CIBW_ARCHS" in
arm64*|aarch64)
CPU="aarch64"
CPU_FAMILY="aarch64"
;;
x86_64)
CPU="x86_64"
CPU_FAMILY="x86_64"
;;
armv7*|arm)
CPU="armv7"
CPU_FAMILY="arm"
;;
x86|i686)
CPU="i686"
CPU_FAMILY="x86"
;;
*)
CPU="$CIBW_ARCHS"
CPU_FAMILY="$CIBW_ARCHS"
;;
esac

# Create meson cross file with sanity checks disabled
# Using /tmp for cross-platform compatibility
CROSS_FILE="/tmp/numpy_meson_cross.txt"
cat > "$CROSS_FILE" << 'CROSSEOF'
[binaries]
c = '${CC:-cc}'
cpp = '${CXX:-c++}'

[host_machine]
system = '$CIBW_PLATFORM'
cpu_family = '$CPU_FAMILY'
cpu = '$CPU'
endian = 'little'

[properties]
skip_sanity_check = true
longdouble_format = 'IEEE_DOUBLE_LE'
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The longdouble_format is hardcoded to 'IEEE_DOUBLE_LE' for all architectures, but this may not be correct for x86_64 platforms which typically use IEEE_QUAD_LE or INTEL_EXTENDED_LE for long double. This should be set based on the CPU_FAMILY to ensure correct floating-point behavior.

Copilot uses AI. Check for mistakes.
CROSSEOF
Comment on lines +65 to +79
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation in the heredoc is inconsistent with standard practice. Lines 66-78 have two spaces of indentation which will be written to the meson cross file. Meson INI-style files typically don't have leading whitespace in section content. This may cause meson to fail parsing the cross file. The heredoc content should start at column 0 or use a <<- operator with tabs for stripping.

Suggested change
cat > "$CROSS_FILE" << 'CROSSEOF'
[binaries]
c = '${CC:-cc}'
cpp = '${CXX:-c++}'
[host_machine]
system = '$CIBW_PLATFORM'
cpu_family = '$CPU_FAMILY'
cpu = '$CPU'
endian = 'little'
[properties]
skip_sanity_check = true
longdouble_format = 'IEEE_DOUBLE_LE'
CROSSEOF
cat > "$CROSS_FILE" <<- 'CROSSEOF'
[binaries]
c = '${CC:-cc}'
cpp = '${CXX:-c++}'
[host_machine]
system = '$CIBW_PLATFORM'
cpu_family = '$CPU_FAMILY'
cpu = '$CPU'
endian = 'little'
[properties]
skip_sanity_check = true
longdouble_format = 'IEEE_DOUBLE_LE'
CROSSEOF

Copilot uses AI. Check for mistakes.

# Substitute variables in the cross file
sed -i "s/\${CC:-cc}/${CC:-cc}/g" "$CROSS_FILE"
sed -i "s/\${CXX:-c++}/${CXX:-c++}/g" "$CROSS_FILE"
Comment on lines +67 to +83
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable substitution approach is fragile. The sed command tries to replace '${CC:-cc}' with the value of ${CC:-cc}, but this won't work as expected. If CC is unset, ${CC:-cc} expands to 'cc', but the meson cross file will contain 'c = 'cc'' (with quotes), when it should contain just 'c = cc' (without inner quotes) or 'c = 'cc'' depending on meson's requirements. Consider testing whether the quotes in the heredoc template (lines 67-68) are correct for the final output.

Copilot uses AI. Check for mistakes.
sed -i "s/\$CIBW_PLATFORM/$CIBW_PLATFORM/g" "$CROSS_FILE"
sed -i "s/\$CPU_FAMILY/$CPU_FAMILY/g" "$CROSS_FILE"
sed -i "s/\$CPU/$CPU/g" "$CROSS_FILE"
Comment on lines +81 to +86
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sed -i command may not work on macOS/iOS build environments. macOS sed requires a backup extension argument with -i (e.g., sed -i '' or sed -i.bak). Consider using a portable approach that works across both Linux and macOS, such as creating a temporary file or using a different method for variable substitution.

Suggested change
# Substitute variables in the cross file
sed -i "s/\${CC:-cc}/${CC:-cc}/g" "$CROSS_FILE"
sed -i "s/\${CXX:-c++}/${CXX:-c++}/g" "$CROSS_FILE"
sed -i "s/\$CIBW_PLATFORM/$CIBW_PLATFORM/g" "$CROSS_FILE"
sed -i "s/\$CPU_FAMILY/$CPU_FAMILY/g" "$CROSS_FILE"
sed -i "s/\$CPU/$CPU/g" "$CROSS_FILE"
# Substitute variables in the cross file (portable across macOS and Linux)
sed "s/\${CC:-cc}/${CC:-cc}/g" "$CROSS_FILE" > "$CROSS_FILE.tmp" && mv "$CROSS_FILE.tmp" "$CROSS_FILE"
sed "s/\${CXX:-c++}/${CXX:-c++}/g" "$CROSS_FILE" > "$CROSS_FILE.tmp" && mv "$CROSS_FILE.tmp" "$CROSS_FILE"
sed "s/\$CIBW_PLATFORM/$CIBW_PLATFORM/g" "$CROSS_FILE" > "$CROSS_FILE.tmp" && mv "$CROSS_FILE.tmp" "$CROSS_FILE"
sed "s/\$CPU_FAMILY/$CPU_FAMILY/g" "$CROSS_FILE" > "$CROSS_FILE.tmp" && mv "$CROSS_FILE.tmp" "$CROSS_FILE"
sed "s/\$CPU/$CPU/g" "$CROSS_FILE" > "$CROSS_FILE.tmp" && mv "$CROSS_FILE.tmp" "$CROSS_FILE"

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +86
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heredoc template uses single quotes ('CROSSEOF') to prevent variable expansion, but then the content has shell variable syntax like '${CC:-cc}' and '$CIBW_PLATFORM'. These won't be expanded during heredoc creation and will be written literally. The sed commands then try to replace these literal strings, but the regex pattern won't correctly match '${CC:-cc}' due to special regex characters. Consider using envsubst or a more robust variable substitution approach, or switch to a heredoc without quotes to allow direct shell expansion.

Copilot uses AI. Check for mistakes.

echo "Created meson cross file at $CROSS_FILE:"
cat "$CROSS_FILE"
fi

# CIBW config settings to pass to meson-python
# Based on void-linux and conda-forge build configurations:
# - builddir=builddir: Use separate build directory (conda-forge pattern)
# - allow-noblas=true: Build without BLAS/LAPACK for simpler mobile builds
# - disable-svml=true: Disable Intel SVML for ARM portability (void-linux pattern)
# - Cross file at /tmp/numpy_meson_cross.txt with skip_sanity_check=true for mobile builds
#
# Note: Tests are skipped by default in cibuildwheel (no CIBW_TEST_COMMAND set)
# This matches the "disable sanity checks" requirement for mobile builds
cibw_config_settings: builddir=builddir setup-args=--cross-file=/tmp/numpy_meson_cross.txt setup-args=-Dallow-noblas=true setup-args=-Ddisable-svml=true
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cross file is created only when building for mobile platforms (android/ios), but the cibw_config_settings unconditionally references it with '--cross-file=/tmp/numpy_meson_cross.txt'. This will cause build failures on non-mobile platforms where the file doesn't exist. Consider making the cross-file reference conditional or creating a default cross file for all platforms.

Copilot uses AI. Check for mistakes.
Loading