-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1400 from pybamm-team/issue-1296-fix-macos-install
Add new workflow to build macos wheels
- Loading branch information
Showing
6 changed files
with
144 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: master | ||
workflow_dispatch: | ||
inputs: | ||
target: | ||
description: 'Deployment target. Can be "pypi" or "testpypi"' | ||
default: 'pypi' | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macOS-10.15, ubuntu-20.04] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Used to host cibuildwheel | ||
- uses: actions/setup-python@v2 | ||
|
||
- name: Install cibuildwheel | ||
run: python -m pip install cibuildwheel==1.9.0 | ||
|
||
- name: Install sundials on macOS | ||
if: matrix.os == 'macOS-10.15' | ||
run: | | ||
brew update | ||
brew install sundials | ||
- name: Clone pybind11 repo | ||
run: git clone https://github.com/pybind/pybind11.git | ||
|
||
- name: Build wheels | ||
run: python -m cibuildwheel --output-dir wheelhouse | ||
env: | ||
CIBW_BEFORE_ALL_LINUX: "bash build_manylinux_wheels/install_sundials.sh 5.8.1 5.7.0" | ||
CIBW_BEFORE_BUILD_LINUX: "python -m pip install cmake" | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse/*.whl | ||
|
||
|
||
publish-pypi: | ||
name: Upload wheels to PyPI | ||
needs: build_wheels | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download wheels | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: wheels | ||
|
||
- name: Publish wheels on PyPI | ||
if: ${{ github.events.inputs.target }} == 'pypi' | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
packages_dir: wheels/ | ||
|
||
- name: Publish wheels on TestPyPI | ||
if: ${{ github.events.inputs.target }} == 'testpypi' | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.TESTPYPI_TOKEN }} | ||
packages_dir: wheels/ | ||
repository_url: https://test.pypi.org/legacy/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,80 @@ | ||
#!/bin/bash | ||
|
||
mkdir /deps | ||
wget https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v5.7.2.tar.gz . | ||
wget https://computing.llnl.gov/projects/sundials/download/sundials-5.3.0.tar.gz . | ||
tar -xf v5.7.2.tar.gz --directory /deps | ||
tar -xf sundials-5.3.0.tar.gz --directory /deps | ||
rm v5.7.2.tar.gz | ||
rm sundials-5.3.0.tar.gz | ||
# This script installs both SuiteSparse | ||
# (https://people.engr.tamu.edu/davis/suitesparse.html) and Sundials | ||
# (https://computing.llnl.gov/projects/sundials) from source. For each | ||
# two library: | ||
# - Archive downloaded and source code extrated in current working | ||
# directory. | ||
# - Library is built and installed. | ||
# | ||
# Usage: ./install_sundials.sh suitesparse_version sundials_version | ||
|
||
SUITESPARSE_DIR=/deps/SuiteSparse-5.7.2 | ||
SUNDIALS_DIR=/deps/sundials-5.3.0 | ||
function prepend_python_bin_dir_to_PATH { | ||
python_bin_dir_cmd="print(os.path.split(sys.executable)[0])" | ||
python_bin_dir=$(python -c "import sys, os;$python_bin_dir_cmd") | ||
export PATH=$python_bin_dir:$PATH | ||
} | ||
|
||
function download { | ||
ROOT_ADDR=$1 | ||
FILENAME=$2 | ||
|
||
wget -q $ROOT_ADDR/$FILENAME | ||
} | ||
|
||
function extract { | ||
tar -xf $1 | ||
} | ||
|
||
SUITESPARSE_VERSION=$1 | ||
SUNDIALS_VERSION=$2 | ||
|
||
SUITESPARSE_ROOT_ADDR=https://github.com/LLNL/sundials/releases/download/v$SUNDIALS_VERSION | ||
SUNDIALS_ROOT_ADDR=https://computing.llnl.gov/projects/sundials/download | ||
|
||
SUITESPARSE_ARCHIVE_NAME=v$SUITESPARSE_VERSION.tar.gz | ||
SUNDIALS_ARCHIVE_NAME=sundials-$SUNDIALS_VERSION.tar.gz | ||
|
||
yum -y update | ||
yum -y install wget | ||
download $SUITESPARSE_ROOT_ADDR $SUITESPARSE_ARCHIVE_NAME | ||
download $SUNDIALS_ROOT_ADDR $SUNDIALS_ARCHIVE_NAME | ||
extract $SUITESPARSE_ARCHIVE_NAME | ||
extract $SUNDIALS_ARCHIVE_NAME | ||
|
||
### Compile and install SUITESPARSE ### | ||
# SuiteSparse is required to compile SUNDIALS's | ||
# KLU solver. | ||
|
||
SUITESPARSE_DIR=SuiteSparse-$SUITESPARSE_VERSION | ||
for dir in SuiteSparse_config AMD COLAMD BTF KLU | ||
do | ||
cd $SUITESPARSE_DIR/$dir; | ||
make library | ||
make install INSTALL=/usr | ||
cd ../ | ||
make -C $SUITESPARSE_DIR/$dir library | ||
make -C $SUITESPARSE_DIR/$dir install INSTALL=/usr | ||
done | ||
|
||
### Compile and install SUNDIALS ### | ||
|
||
# Building cmake requires cmake >= 3.5 | ||
python -m pip install cmake | ||
prepend_python_bin_dir_to_PATH | ||
|
||
# Building SUNDIALS requires a BLAS library | ||
yum -y install openblas-devel | ||
|
||
mkdir -p build_sundials | ||
cd build_sundials | ||
KLU_INCLUDE_DIR=/usr/include | ||
KLU_LIBRARY_DIR=/usr/lib | ||
mkdir -p /deps/build_sundials | ||
cd /deps/build_sundials | ||
cmake -DLAPACK_ENABLE=ON\ | ||
SUNDIALS_DIR=sundials-$SUNDIALS_VERSION | ||
cmake -DENABLE_LAPACK=ON\ | ||
-DSUNDIALS_INDEX_SIZE=32\ | ||
-DEXAMPLES_ENABLE:BOOL=OFF\ | ||
-DKLU_ENABLE=ON\ | ||
-DENABLE_KLU=ON\ | ||
-DKLU_INCLUDE_DIR=$KLU_INCLUDE_DIR\ | ||
-DKLU_LIBRARY_DIR=$KLU_LIBRARY_DIR\ | ||
-DCMAKE_INSTALL_PREFIX=/usr\ | ||
$SUNDIALS_DIR | ||
../$SUNDIALS_DIR | ||
make install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters