Skip to content

Use absolute paths for CMake dependency locations. #65

Use absolute paths for CMake dependency locations.

Use absolute paths for CMake dependency locations. #65

name: Build Windows ARM64 wheels
on: [push]
env:
MLPACK_COMMIT: 4.3.0
CIBW_TEST_COMMAND: python -c 'import mlpack; import numpy as np; x = np.random.rand(100, 10); o = mlpack.pca(input_=x, new_dimensionality=5, verbose=True)'
jobs:
windows_arm_build_wheels:
# Note: this job is currently disabled, because we cannot install any ARM64
# version of LAPACK. Ideally, we can enable this when we have vcpkg support
# for ARM64 gfortran.
if: ${{ false }}
name: Build wheel for ${{ matrix.py_ver }}-win_arm64
runs-on: windows-latest
strategy:
matrix:
py_ver: [cp39, cp310, cp311]
env:
CIBW_BUILD: ${{ matrix.py_ver }}-win_arm64
steps:
- uses: actions/checkout@v3
- name: "Set up Visual Studio"
uses: microsoft/[email protected]
with:
vs-version: '16'
- uses: lukka/get-cmake@latest
- name: Setup vcpkg
uses: lukka/run-vcpkg@v10
with:
# I guess this will go out of date...
vcpkgGitCommitId: 'bdf073a835ebea07e1d039cd9cff4f650014e4ce'
- name: Install OpenBLAS via vcpkg
run: vcpkg install openblas:arm64-windows lapack-reference:arm64-windows
- name: Download Armadillo
shell: bash
run: |
curl -O -L https://files.mlpack.org/armadillo-11.4.1.tar.gz
tar -xvzf armadillo-11.4.1.tar.gz
- name: Configure and build Armadillo
shell: powershell
run: |
$rootdir = $pwd
cd armadillo-11.4.1/
cmake -G "Visual Studio 17 2022" `
-A "ARM64" `
-DBLAS_LIBRARY:FILEPATH="C:\vcpkg\packages\openblas_arm64-windows\lib\openblas.lib" `
-DLAPACK_LIBRARY:FILEPATH="C:\vcpkg\packages\openblas_arm64-windows\lib\openblas.lib" `
-DBUILD_SHARED_LIBS=OFF `
-DCMAKE_BUILD_TYPE=Release .
cmake --build . --target armadillo --config Release
- name: Download ensmallen
shell: bash
run: |
curl -O -L https://www.ensmallen.org/files/ensmallen-2.19.0.tar.gz
tar -xvzf ensmallen-2.19.0.tar.gz
# No build needed---it's header-only.
- name: Download cereal
shell: bash
run: |
curl -O -L https://github.com/USCILab/cereal/archive/refs/tags/v1.3.2.tar.gz
tar -xvzf v1.3.2.tar.gz
- name: Download STB
shell: bash
run: |
curl -O -L https://www.mlpack.org/files/stb.tar.gz
tar -xvzf stb.tar.gz
- name: Install Python dependencies
run: python -m pip install cython numpy pandas
- name: Clone mlpack
shell: bash
run: |
git clone https://github.com/mlpack/mlpack
cd mlpack
git checkout $MLPACK_VERSION
# Apply patches to install Python headers and fix STB detection.
cp ../ConfigureFileOnly.cmake CMake/
cp ../mlpack.pc.in src/mlpack/bindings/python/
patch -p1 < ../python-install-headers.patch
patch -p1 < ../stb-cmake-fix.patch
- name: Generate setup.py
shell: powershell
run: |
$rootdir = $pwd
cd mlpack
mkdir build
cd build
cmake -G "Visual Studio 17 2022" `
-DBLAS_LIBRARIES:FILEPATH="C:\vcpkg\packages\openblas_arm64-windows\lib\openblas.lib" `
-DLAPACK_LIBRARIES:FILEPATH="C:\vcpkg\packages\openblas_arm64-windows\lib\openblas.lib" `
-DARMADILLO_INCLUDE_DIR="$rootdir\armadillo-11.4.1\tmp\include" `
-DARMADILLO_LIBRARY="$rootdir\armadillo-11.4.1\Release\armadillo.lib" `
-DCEREAL_INCLUDE_DIR="$rootdir\cereal-1.3.2\include" `
-DENSMALLEN_INCLUDE_DIR="$rootdir\ensmallen-2.19.0\include\" `
-DBUILD_JULIA_BINDINGS=OFF `
-DBUILD_PYTHON_BINDINGS=ON `
-DCMAKE_BUILD_TYPE=Release ..
cmake --build . --target python_configured --config Release
- name: Build wheel
uses: pypa/[email protected]
with:
package-dir: mlpack/build/src/mlpack/bindings/python/
env:
CIBW_ARCHS_WINDOWS: "ARM64"
CIBW_BEFORE_BUILD: "build_mlpack.bat"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair --add-path C:/vcpkg/packages/openblas_arm64-windows/bin/ -w {dest_dir} {wheel}"
VS_GENERATOR: "Visual Studio 17 2022"
WIN_ARCH: "ARM64"
OPENBLAS_LIB: "C:/vcpkg/packages/openblas_arm64-windows/lib/openblas.lib"
OPENBLAS_DLL: "C:/vcpkg/packages/openblas_arm64-windows/bin/openblas.dll"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl