Skip to content

Commit

Permalink
adapted before build
Browse files Browse the repository at this point in the history
  • Loading branch information
Socrats committed Sep 30, 2023
1 parent 6a5d418 commit f0d26d8
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 58 deletions.
1 change: 1 addition & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ jobs:
CIBW_SKIP: "cp38-win32 cp39-win32 cp310-win32 cp311-win32"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_WINDOWS: "AMD64 x86"
CIBW_BEFORE_ALL_MACOS: bash build_tools/github/before_all_mac.sh
CIBW_BEFORE_BUILD_MACOS: bash build_tools/github/before_build_mac.sh
CIBW_BEFORE_ALL_LINUX: bash build_tools/github/download_eigen3.sh
CIBW_BEFORE_ALL_WINDOWS: bash build_tools/github/download_eigen3_windows.sh
Expand Down
103 changes: 61 additions & 42 deletions build_tools/github/before_all_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,68 @@
set -e
set -x

# OpenMP is not present on macOS by default
if [[ $(uname) == "Darwin" ]]; then
# Make sure to use a libomp version binary compatible with the oldest
# supported version of the macos SDK as libomp will be vendored into the
# scikit-learn wheels for macos.
python -m pip install --upgrade --user pip cmake

if [[ "$CIBW_BUILD" == *-macosx_arm64 ]]; then
if [[ $(uname -m) == "x86_64" ]]; then
# arm64 builds must cross compile because the CI instance is x86
# This turns off the computation of the test program in
# sklearn/_build_utils/pre_build_helpers.py
export PYTHON_CROSSENV=1
fi
# SciPy requires 12.0 on arm to prevent kernel panics
# https://github.com/scipy/scipy/issues/14688
# We use the same deployment target to match SciPy.
export MACOSX_DEPLOYMENT_TARGET=12.0
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2"
else
export MACOSX_DEPLOYMENT_TARGET=10.15
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2"
fi

sudo conda create -n build $OPENMP_URL
PREFIX="$CONDA_HOME/envs/build"

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
export CFLAGS="$CFLAGS -I$PREFIX/include"
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"
export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"

if [[ $(uname -m) == "arm64" && "$CIBW_BUILD" == "cp38-macosx_arm64" ]]; then
# Enables native building and testing for macosx arm on Python 3.8. For details see:
# https://cibuildwheel.readthedocs.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64
curl -o /tmp/Python38.pkg https://www.python.org/ftp/python/3.8.10/python-3.8.10-macos11.pkg
sudo installer -pkg /tmp/Python38.pkg -target /
sh "/Applications/Python 3.8/Install Certificates.command"
fi
fi

brew install eigen
brew install gfortran
brew install openblas
brew install libomp
brew install boost

# First we download the correct eigen3 version
curl -O https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz
tar xf eigen-3.3.9.tar.gz
mv eigen-3.3.9 eigen3

# Install eigen 3
cd eigen3
mkdir "build"
cd build
cmake ..
make install

## OpenMP is not present on macOS by default
#if [[ $(uname) == "Darwin" ]]; then
# # Make sure to use a libomp version binary compatible with the oldest
# # supported version of the macos SDK as libomp will be vendored into the
# # scikit-learn wheels for macos.
#
# if [[ "$CIBW_BUILD" == *-macosx_arm64 ]]; then
# if [[ $(uname -m) == "x86_64" ]]; then
# # arm64 builds must cross compile because the CI instance is x86
# # This turns off the computation of the test program in
# # sklearn/_build_utils/pre_build_helpers.py
# export PYTHON_CROSSENV=1
# fi
# # SciPy requires 12.0 on arm to prevent kernel panics
# # https://github.com/scipy/scipy/issues/14688
# # We use the same deployment target to match SciPy.
# export MACOSX_DEPLOYMENT_TARGET=12.0
# OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2"
# else
# export MACOSX_DEPLOYMENT_TARGET=10.15
# OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2"
# fi
#
# sudo conda create -n build $OPENMP_URL
# PREFIX="$CONDA_HOME/envs/build"
#
# export CC=/usr/bin/clang
# export CXX=/usr/bin/clang++
# export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
# export CFLAGS="$CFLAGS -I$PREFIX/include"
# export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"
# export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"
#
# if [[ $(uname -m) == "arm64" && "$CIBW_BUILD" == "cp38-macosx_arm64" ]]; then
# # Enables native building and testing for macosx arm on Python 3.8. For details see:
# # https://cibuildwheel.readthedocs.io/en/stable/faq/#macos-building-cpython-38-wheels-on-arm64
# curl -o /tmp/Python38.pkg https://www.python.org/ftp/python/3.8.10/python-3.8.10-macos11.pkg
# sudo installer -pkg /tmp/Python38.pkg -target /
# sh "/Applications/Python 3.8/Install Certificates.command"
# fi
#fi
#
#brew install eigen
#brew install gfortran
#brew install openblas
#brew install boost
32 changes: 16 additions & 16 deletions build_tools/github/before_build_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
set -e
set -x

python -m pip install --upgrade --user pip cmake
#python -m pip install --upgrade --user pip cmake

# Install extra libraries for parallel processing
brew install gfortran
brew install openblas
brew install libomp
brew install boost
#brew install gfortran
#brew install openblas
#brew install libomp
#brew install boost

if [[ $(uname) == "Darwin" ]]; then
if [[ "$CIBW_BUILD" == *-macosx_arm64 || "$CIBW_BUILD" == *-macosx_universal2:arm64 ]]; then
Expand All @@ -25,14 +25,14 @@ if [[ $(uname) == "Darwin" ]]; then
fi
fi

# First we download the correct eigen3 version
curl -O https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz
tar xf eigen-3.3.9.tar.gz
mv eigen-3.3.9 eigen3

# Install eigen 3
cd eigen3
mkdir "build"
cd build
cmake ..
make install
## First we download the correct eigen3 version
#curl -O https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz
#tar xf eigen-3.3.9.tar.gz
#mv eigen-3.3.9 eigen3
#
## Install eigen 3
#cd eigen3
#mkdir "build"
#cd build
#cmake ..
#make install

0 comments on commit f0d26d8

Please sign in to comment.