Skip to content

Commit

Permalink
Merge pull request #297 from h-vetinari/rc
Browse files Browse the repository at this point in the history
numpy v1.26.0 with meson
  • Loading branch information
h-vetinari committed Sep 17, 2023
2 parents 14809f1 + 6b14b33 commit 05d6fd4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 49 deletions.
34 changes: 14 additions & 20 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
(
echo [DEFAULT]
echo library_dirs = %LIBRARY_LIB%
echo include_dirs = %LIBRARY_INC%
echo [lapack]
echo libraries = lapack,blas
echo [blas]
echo libraries = cblas,blas
echo [cblas]
echo libraries = cblas,blas
) > site.cfg
@echo on

set "NPY_LAPACK_ORDER=lapack"
set "NPY_BLAS_ORDER=blas"
mkdir builddir

%PYTHON% -m pip install --no-deps --ignore-installed -v .
if errorlevel 1 exit 1
:: -wnx flags mean: --wheel --no-isolation --skip-dependency-check
%PYTHON% -m build -w -n -x ^
-Cbuilddir=builddir ^
-Csetup-args=-Dblas=blas ^
-Csetup-args=-Dlapack=lapack
if %ERRORLEVEL% neq 0 exit 1

XCOPY %RECIPE_DIR%\f2py.bat %SCRIPTS% /s /e
if errorlevel 1 exit 1

del %SCRIPTS%\f2py.exe
if errorlevel 1 exit 1
:: `pip install dist\numpy*.whl` does not work on windows,
:: so use a loop; there's only one wheel in dist/ anyway
for /f %%f in ('dir /b /S .\dist') do (
pip install %%f
if %ERRORLEVEL% neq 0 exit 1
)
45 changes: 27 additions & 18 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
#!/bin/bash
set -ex

set -x
# necessary for cross-compilation to point to the right env
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig

# numpy distutils don't use the env variables.
if [[ ! -f $BUILD_PREFIX/bin/ranlib ]]; then
ln -s $RANLIB $BUILD_PREFIX/bin/ranlib
ln -s $AR $BUILD_PREFIX/bin/ar
fi
mkdir builddir

cat > site.cfg <<EOF
[DEFAULT]
library_dirs = $PREFIX/lib
include_dirs = $PREFIX/include
# HACK: extend $CONDA_PREFIX/meson_cross_file that's created in
# https://github.com/conda-forge/ctng-compiler-activation-feedstock/blob/main/recipe/activate-gcc.sh
# https://github.com/conda-forge/clang-compiler-activation-feedstock/blob/main/recipe/activate-clang.sh
# to use host python; requires that [binaries] section is last in meson_cross_file
echo "python = '${PREFIX}/bin/python'" >> ${CONDA_PREFIX}/meson_cross_file.txt

[lapack]
libraries = lapack,blas
if [[ $target_platform == "osx-arm64" ]]; then
# currently cannot properly detect long double format
# on osx-arm64 when cross-compiling in QEMU, see
# https://github.com/numpy/numpy/pull/24414
echo "[properties]" >> ${CONDA_PREFIX}/meson_cross_file.txt
echo "longdouble_format = 'IEEE_DOUBLE_LE'" >> ${CONDA_PREFIX}/meson_cross_file.txt
fi

[blas]
libraries = cblas,blas
EOF
# meson-python already sets up a -Dbuildtype=release argument to meson, so
# we need to strip --buildtype out of MESON_ARGS or fail due to redundancy
MESON_ARGS_REDUCED="$(echo $MESON_ARGS | sed 's/--buildtype release //g')"

export NPY_LAPACK_ORDER=lapack
export NPY_BLAS_ORDER=blas
# -wnx flags mean: --wheel --no-isolation --skip-dependency-check
$PYTHON -m build -w -n -x \
-Cbuilddir=builddir \
-Csetup-args=-Dblas=blas \
-Csetup-args=-Dlapack=lapack \
-Csetup-args=${MESON_ARGS_REDUCED// / -Csetup-args=} \
|| (cat builddir/meson-logs/meson-log.txt && exit 1)

$PYTHON -m pip install --no-deps --ignore-installed -v .
pip install dist/numpy*.whl
35 changes: 24 additions & 11 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "1.25.2" %}
{% set version = "1.26.0" %}

package:
name: numpy
Expand All @@ -9,7 +9,7 @@ package:

source:
- url: https://github.com/numpy/numpy/releases/download/v{{ version }}/numpy-{{ version }}.tar.gz
sha256: fd608e19c8d7c55021dffd43bfe5492fab8cc105cc8986f813f8c3c048b38760
sha256: f93fc78fe8bf15afe2b8d6b6499f1c73953169fad1e9a8dd086cdff3190e7fdf
# the sources by upstream themselves (as opposed to automated by github) contain the
# svml submodule (which isn't in github tarball due to dear-github/dear-github#214);
# keep this for reference & debugging when necessary; for exact commit, see:
Expand All @@ -34,13 +34,24 @@ requirements:
- python # [build_platform != target_platform]
- cross-python_{{ target_platform }} # [build_platform != target_platform]
- cython # [build_platform != target_platform]
- setuptools <60.0.0 # [build_platform != target_platform]
- ninja # [build_platform != target_platform]
- pkg-config # [build_platform != target_platform]
- {{ compiler('c') }}
- {{ compiler('cxx') }}
host:
- setuptools <60.0.0
- python
# temporarily vendored by numpy
# - meson
# - meson-python
# deps of meson-python
- pyproject-metadata
- tomli # [py<=310]
- setuptools >=60 # [py==312]
# rest
- pip
- ninja
- pkg-config
- python
- python-build
- cython
- libblas
- libcblas
Expand Down Expand Up @@ -68,12 +79,15 @@ test:
- cffi # [py<=39 and python_impl != "pypy"]
- cython
- hypothesis
- meson
- pytz
- setuptools <60.0.0
- setuptools <60.0.0 # [py<=311]
- setuptools # [py==312]
- typing_extensions
# some linux tests need a C compiler;
# some linux tests need a C/C++ compiler;
# extra f2py tests need a fortran compiler
- {{ compiler('c') }} # [linux]
- {{ compiler('cxx') }} # [linux]
- {{ compiler('fortran') }} # [linux]
commands:
- f2py -h
Expand All @@ -92,10 +106,9 @@ test:
- numpy.array_api
- numpy.array_api.linalg
- numpy.ctypeslib
- numpy.distutils
- numpy.doc
- numpy.doc.constants
- numpy.doc.ufuncs
- numpy.distutils # [py<312]
- numpy.dtypes
- numpy.exceptions
- numpy.f2py
- numpy.fft
- numpy.lib
Expand Down

0 comments on commit 05d6fd4

Please sign in to comment.