Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Restructured MacOS build scripts and prepared for GitHub actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Sep 7, 2023
1 parent e01eb63 commit 6aad712
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 134 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: swiftest

on: [push]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11, macos-12, macos-13]

steps:
- uses: actions/checkout@v3

- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
with:
package-dir: .
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ swiftest_driver.sh
!README.swifter
dump*
!**/.gitignore
!.github/workflows/build_wheels.yml
!setup.py
!examples/**
!swiftest/**
Expand Down
23 changes: 1 addition & 22 deletions buildscripts/_build_getopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ROOT_DIR=$(realpath ${SCRIPT_DIR}/..)

# Parse arguments
USTMT="Usage: ${0} [-d /path/to/dependency/source] [-p /prefix/path] [-m MACOSX_DEPLOYMENT_TARGET]"
MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"11.0"}
MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"$(sw_vers --ProductVersion)"}

while getopts ":d:p:m:h" ARG; do
case "${ARG}" in
Expand Down Expand Up @@ -49,27 +49,6 @@ BUILD_DIR=${BUILD_DIR:-$(mktemp -ut swiftest_build.XXXXXXXX)}
PREFIX=${PREFIX:-${ROOT_DIR}}
DEPENDENCY_DIR=${DEPENDENCY_DIR:-${BUILD_DIR}}

if [ -z ${DEPENDENCY_ENV_VARS+x} ]; then
. ${SCRIPT_DIR}/set_compilers.sh

LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}"
CPPFLAGS="${CPPFLAGS} -isystem ${PREFIX}/include"
LDFLAGS="${LDFLAGS} -L${PREFIX}/lib"
CPATH="${PREFIX}/include:${CPATH}"

HDF5_ROOT="${PREFIX}"
HDF5_LIBDIR="${HDF5_ROOT}/lib"
HDF5_INCLUDE_DIR="${HDF5_ROOT}/include"
HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin"
NCDIR="${PREFIX}"
NFDIR="${PREFIX}"
NETCDF_FORTRAN_HOME=${NFDIR}
NETCDF_INCLUDE=${NFDIR}/include
NETCDF_HOME=${NCDIR}

DEPENDENCY_ENV_VARS=true
fi

mkdir -p ${DEPENDENCY_DIR}
mkdir -p ${PREFIX}/lib
mkdir -p ${PREFIX}/include
Expand Down
5 changes: 5 additions & 0 deletions buildscripts/build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n"
printf "Installing to ${PREFIX}\n"
printf "\n"

# Get the OpenMP Libraries
if [ $OS == "MacOSX" ]; then
${SCRIPT_DIR}/get_lomp.sh ${ARGS}
fi

set -e
${SCRIPT_DIR}/build_zlib.sh ${ARGS}
${SCRIPT_DIR}/build_hdf5.sh ${ARGS}
Expand Down
44 changes: 0 additions & 44 deletions buildscripts/build_macwheels.sh

This file was deleted.

66 changes: 0 additions & 66 deletions buildscripts/build_swiftest.sh

This file was deleted.

83 changes: 83 additions & 0 deletions buildscripts/get_lomp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
# This script will download the correct OpenMP library for a given MacOS deployment target
#
# Copyright 2023 - David Minton
# This file is part of Swiftest.
# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.

# Determine the platform and architecture
SCRIPT_DIR=$(realpath $(dirname $0))
set -a
ARGS=$@
. ${SCRIPT_DIR}/_build_getopts.sh ${ARGS}
printf "MACOSX_DEPLOYMENT_TARGET: ${MACOSX_DEPLOYMENT_TARGET}\n"

TARGET_MAJOR=`echo $MACOSX_DEPLOYMENT_TARGET | cut -d. -f1`
TARGET_MINOR=`echo $MACOSX_DEPLOYMENT_TARGET | cut -d. -f2`
TARGET_REV=`echo $MACOSX_DEPLOYMENT_TARGET | cut -d. -f3`

#Figure out which version to get
case $TARGET_MAJOR in
13)
OMPVER="14.0.6"
DVER="20"
;;
12)
if ((TARGET_MINOR>=5)); then
OMPVER="14.0.6"
DVER="20"
else
OMPVER="13.0.0"
DVER="21"
fi
;;
11)
if ((TARGET_MINOR>=3)); then
OMPVER="12.0.1"
DVER="20"
else
OMPVER="11.0.1"
DVER="20"
fi
;;
10)
DVER="17"
case $TARGET_MINOR in
15)
case $TARGET_REV in
4)
OMPVER="10.0.0"
;;
2)
OMPVER="9.0.1"
;;
esac
;;
14)
case $TARGET_REV in
4)
OMPVER="8.0.1"
;;
3)
OMPVER="7.1.0"
;;
esac
;;
*)
OMPVER="7.1.0"
;;
esac
;;
esac

filename="openmp-${OMPVER}-darwin${DVER}-Release.tar.gz"
#Download and install the libraries
printf "Downloading ${filename}\n"
curl -O https://mac.r-project.org/openmp/${filename} && \
sudo tar fvxz ${filename} -C / && \
rm ${filename}
41 changes: 39 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,47 @@ test-requires = ['pytest']
skip = "cp312-* pp* *i686 *-manylinux_i686 *_ppc64le *_s390x *-musllinux* *-win32"
build-verbosity = 1

[tool.cibuildwheel.macos.environment]
ROOT_DIR="$(pwd)"
ARCH="$(uname -m)"
MACOSX_DEPLOYMENT_TARGET="$(sw_vers --ProductVersion)"
PREFIX="${ROOT_DIR}"
LD_LIBRARY_PATH="/usr/local/lib:${PREFIX}/lib:${HOMEBREW_PREFIX}/lib"
LDFLAGS="-Wl,-rpath,${ROOT_DIR}/lib -Wl,-rpath,${PREFIX}/lib -Wl,-rpath,/usr/local/lib -Wl,-no_compact_unwind -L${PREFIX}/lib"
CPATH="/usr/local/include:${PREFIX}/include:${HOMEBREW_PREFIX}/include:${ROOT_DIR}/include"
CPPFLAGS="-isystem ${PREFIX}/include -isystem /usr/local/include"
LIBS="-lomp"
CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -Wno-deprecated-non-prototype -arch ${ARCH}"
FCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -arch ${ARCH}"
FFFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} -arch ${ARCH}"
HDF5_ROOT="${PREFIX}"
HDF5_LIBDIR="${HDF5_ROOT}/lib"
HDF5_INCLUDE_DIR="${HDF5_ROOT}/include"
HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin"
NETCDF_FORTRAN_HOME="${PREFIX}"
NETCDF_INCLUDE="${PREFIX}"
NCDIR="${PREFIX}"
NFDIR="${PREFIX}"
FC="${HOMEBREW_PREFIX}/bin/gfortran-12"
CC="/usr/bin/clang"
CXX="/usr/bin/clang++"
CPP="/usr/bin/cpp"
AR="/usr/bin/ar"
NM="/usr/bin/nm"
RANLIB="/usr/bin/ranlib"

[tool.cibuildwheel.macos]
before-all = [
"LIBS=\"\" buildscripts/build_dependencies.sh -p ${PREFIX} -d ${TMPDIR}/swiftest.build -m ${MACOSX_DEPLOYMENT_TARGET}"
]

[tool.cibuildwheel.linux]
repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}"
environment = {NETCDF_FORTRAN_HOME="/usr/local", NETCDF_INCLUDE="/usr/local/include", LD_LIBRARY_PATH="/usr/local/lib:/project/lib", CPATH="/usr/local/include:/project/include"}
before-all = [
"yum install doxygen libxml2-devel libcurl-devel -y",
"buildscripts/build_dependencies.sh -p /usr/local"
]
[tool.cibuildwheel.linux.environment]
NETCDF_FORTRAN_HOME="/usr/local"
NETCDF_INCLUDE="/usr/local/include"
LD_LIBRARY_PATH="/usr/local/lib:/project/lib"
CPATH="/usr/local/include:/project/include"

0 comments on commit 6aad712

Please sign in to comment.