From 2c5b37763c046495f4e5f395a272fd79f8c7829e Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Wed, 30 Aug 2023 12:14:02 -0400 Subject: [PATCH] Made several changes to get a working version of the code on MacOS 11.0. Switched back to a shared library build for portability --- buildscripts/_build_getopts.sh | 24 +++++++++--- buildscripts/build_all.sh | 22 ----------- buildscripts/build_hdf5.sh | 5 ++- buildscripts/build_netcdf-c.sh | 11 +++--- buildscripts/build_netcdf-fortran.sh | 5 ++- buildscripts/build_swiftest.sh | 9 +++-- buildscripts/build_zlib.sh | 5 ++- buildscripts/set_compilers.sh | 56 +--------------------------- pyproject.toml | 11 +----- 9 files changed, 43 insertions(+), 105 deletions(-) delete mode 100755 buildscripts/build_all.sh diff --git a/buildscripts/_build_getopts.sh b/buildscripts/_build_getopts.sh index 9ccfde135..3d82f380e 100755 --- a/buildscripts/_build_getopts.sh +++ b/buildscripts/_build_getopts.sh @@ -14,10 +14,19 @@ SCRIPT_DIR=$(realpath $(dirname $0)) ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) # Parse arguments -USTMT="Usage: ${0} <-d /path/to/dependency/source> [-p /prefix/path|{/usr/local}] [-m MACOSX_DEPLOYMENT_TARGET|{10.9}]" -PREFIX=/usr/local -DEPENDENCY_DIR="${ROOT_DIR}/_dependencies" -MACOSX_DEPLOYMENT_TARGET="10.9" +USTMT="Usage: ${0} [-d /path/to/dependency/source] [-p /prefix/path] [-m MACOSX_DEPLOYMENT_TARGET|{11.0}]" +MACOSX_DEPLOYMENT_TARGET="11.0" + +read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) +BUILD_DIR=${BUILD_DIR:-$(mktemp -ut swiftest_build)} +if [ $OS = "MacOSX" ]; then + PREFIX=${PREFIX:-${BUILD_DIR}/${OS}${MACOSX_DEPLOYMENT_TARGET}/${ARCH}} +else + PREFIX=${PREFIX:-${BUILD_DIR}/${OS}/${ARCH}} +fi + +DEPENDENCY_DIR=${DEPENDENCY_DIR:-${BUILD_DIR}/downloads} + while getopts ":d:p:m:h" ARG; do case "${ARG}" in d) @@ -45,7 +54,12 @@ while getopts ":d:p:m:h" ARG; do esac done -read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) +if [ $OS = "MacOSX" ]; then + printf "MACOSX_DEPLOYMENT_TARGET: ${MACOSX_DEPLOYMENT_TARGET}\n" +fi +printf "DEPENDENCY_DIR: ${DEPENDENCY_DIR}\n" +printf "PREFIX : ${PREFIX}\n" + if [ -z ${DEPENDENCY_ENV_VARS+x} ]; then . ${SCRIPT_DIR}/set_compilers.sh diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh deleted file mode 100755 index d93933abe..000000000 --- a/buildscripts/build_all.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# This script will generate cross-platform wheels for the Swiftest Python package using Docker. If it is called from MacOS it will -# also generate a Mac build. -# -# 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 -set -a -SCRIPT_DIR=$(realpath $(dirname $0)) -ARGS=$@ -. ${SCRIPT_DIR}/_build_getopts.sh ${ARGS} - -set -e -${SCRIPT_DIR}/build_dependencies.sh ${ARGS} -${SCRIPT_DIR}/build_swiftest.sh ${ARGS} \ No newline at end of file diff --git a/buildscripts/build_hdf5.sh b/buildscripts/build_hdf5.sh index 9f170e0a1..fffd91b47 100755 --- a/buildscripts/build_hdf5.sh +++ b/buildscripts/build_hdf5.sh @@ -17,7 +17,7 @@ ARGS=$@ printf "\n" printf "*********************************************************\n" -printf "* BUILDING HDF5 STATIC LIBRARY *\n" +printf "* BUILDING HDF5 LIBRARY *\n" printf "*********************************************************\n" printf "LIBS: ${LIBS}\n" printf "CFLAGS: ${CFLAGS}\n" @@ -35,7 +35,8 @@ if [ $OS = "MacOSX" ]; then printf "echo arm-apple-darwin" > bin/config.sub fi fi -COPTS="--disable-shared --enable-build-mode=production --enable-tests=no --enable-tools=no --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}" +#COPTS="--disable-shared --enable-build-mode=production --enable-tests=no --enable-tools=no --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}" +COPTS="--enable-build-mode=production --enable-tests=no --enable-tools=no --disable-fortran --disable-java --disable-cxx --prefix=${PREFIX} --with-zlib=${PREFIX}" ./configure ${COPTS} make if [ -w ${PREFIX} ]; then diff --git a/buildscripts/build_netcdf-c.sh b/buildscripts/build_netcdf-c.sh index 82bc78380..9fe7a913e 100755 --- a/buildscripts/build_netcdf-c.sh +++ b/buildscripts/build_netcdf-c.sh @@ -18,7 +18,7 @@ ARGS=$@ printf "\n" printf "*********************************************************\n" -printf "* BUILDING NETCDF-C STATIC LIBRARY *\n" +printf "* BUILDING NETCDF-C LIBRARY *\n" printf "*********************************************************\n" printf "LIBS: ${LIBS}\n" printf "CFLAGS: ${CFLAGS}\n" @@ -30,10 +30,11 @@ printf "HDF5_ROOT: ${HDF5_ROOT}\n" printf "*********************************************************\n" cd ${DEPENDENCY_DIR}/netcdf-c-* -COPTS="--disable-shared --disable-dap --disable-byterange --disable-testsets --prefix=${PREFIX}" -if [ ! $OS = "MacOSX" ]; then - COPTS="${COPTS} --disable-libxml2" -fi +#COPTS="--disable-shared --disable-dap --disable-byterange --disable-testsets --prefix=${PREFIX}" +COPTS="--disable-testsets --prefix=${PREFIX}" +#if [ ! $OS = "MacOSX" ]; then +# COPTS="${COPTS} --disable-libxml2" +#fi printf "COPTS: ${COPTS}\n" ./configure $COPTS make && make check diff --git a/buildscripts/build_netcdf-fortran.sh b/buildscripts/build_netcdf-fortran.sh index 9e9a877cd..cb2ad8a8e 100755 --- a/buildscripts/build_netcdf-fortran.sh +++ b/buildscripts/build_netcdf-fortran.sh @@ -19,7 +19,7 @@ LIBS="$(${PREFIX}/bin/nc-config --libs --static)" printf "\n" printf "*********************************************************\n" -printf "* BUILDING NETCDF-FORTRAN STATIC LIBRARY *\n" +printf "* BUILDING NETCDF-FORTRAN LIBRARY *\n" printf "*********************************************************\n" printf "LIBS: ${LIBS}\n" printf "CFLAGS: ${CFLAGS}\n" @@ -30,7 +30,8 @@ printf "LDFLAGS: ${LDFLAGS}\n" printf "*********************************************************\n" cd ${DEPENDENCY_DIR}/netcdf-fortran-* -./configure --disable-shared --with-pic --disable-zstandard-plugin --enable-large-file-tests=no --enable-filter-test=no --prefix=${PREFIX} +#./configure --disable-shared --with-pic --disable-zstandard-plugin --enable-large-file-tests=no --enable-filter-test=no --prefix=${PREFIX} +./configure --enable-large-file-tests=no --enable-filter-test=no --prefix=${PREFIX} make && make check i if [ -w ${PREFIX} ]; then make install diff --git a/buildscripts/build_swiftest.sh b/buildscripts/build_swiftest.sh index b3e3cdc87..41411762a 100755 --- a/buildscripts/build_swiftest.sh +++ b/buildscripts/build_swiftest.sh @@ -13,6 +13,7 @@ set -a if [ -z ${SCRIPT_DIR+x} ]; then SCRIPT_DIR=$(realpath $(dirname $0)); fi ARGS=$@ . ${SCRIPT_DIR}/_build_getopts.sh ${ARGS} +ARGS="-p ${PREFIX} -d ${DEPENDENCY_DIR} -m ${MACOSX_DEPLOYMENT_TARGET}" # Determine if we are in the correct directory (the script can either be run from the Swiftest project root directory or the # buildscripts directory) @@ -27,18 +28,20 @@ echo $OS $ARCH printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n\n" printf "Installing to ${PREFIX}\n" printf "Dependency libraries in ${PREFIX}\n" +${SCRIPT_DIR}/build_dependencies.sh ${ARGS} if [ $OS = "Linux" ]; then cibuildwheel --platform linux else - SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF" + SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=ON -DUSE_SIMD=OFF" SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_CONFIGURE_OPTIONS} -DMACHINE_CODE_VALUE=\"generic\"" OMPROOT=${DEVTOOLDIR}/MacOSX${MACOSX_DEPLOYMENT_TARGET}/${ARCH}/usr/local CPPFLAGS="${CPPFLAGS} -Xclang -fopenmp" LIBS="${LIBS} -lomp" - LDFLAGS="-Wl,-rpath,${OMPROOT}/lib" + LDFLAGS="-Wl,-rpath,${OMPROOT}/lib -Wl,-rpath,${ROOT_DIR}/lib" CPATH="${OMPROOT}/include:${CPATH}" - LD_LIBRARY_PATH="${OMPROOT}/lib:${LD_LIBRARY_PATH}" + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" + LIBRARY_PATH="${LD_LIBRARY_PATH}" cd $ROOT_DIR printf "\n" diff --git a/buildscripts/build_zlib.sh b/buildscripts/build_zlib.sh index d65cad4f6..928d07fe3 100755 --- a/buildscripts/build_zlib.sh +++ b/buildscripts/build_zlib.sh @@ -16,7 +16,7 @@ ARGS=$@ . ${SCRIPT_DIR}/_build_getopts.sh ${ARGS} printf "*********************************************************\n" -printf "* BUILDING ZLIB STATIC LIBRARY *\n" +printf "* BUILDING ZLIB LIBRARY *\n" printf "*********************************************************\n" printf "LIBS: ${LIBS}\n" printf "CFLAGS: ${CFLAGS}\n" @@ -27,7 +27,8 @@ printf "LDFLAGS: ${LDFLAGS}\n" printf "*********************************************************\n" cd ${DEPENDENCY_DIR}/zlib-* -./configure --prefix=${PREFIX} --static +#./configure --prefix=${PREFIX} --static +./configure --prefix=${PREFIX} make if [ -w ${PREFIX} ]; then make install diff --git a/buildscripts/set_compilers.sh b/buildscripts/set_compilers.sh index 10d3fac67..fff90cba5 100755 --- a/buildscripts/set_compilers.sh +++ b/buildscripts/set_compilers.sh @@ -15,7 +15,7 @@ # If not, see: https://www.gnu.org/licenses. # Parse arguments case "$OS" in - Intel|Linux|MacOSX) + Linux|MacOSX) ;; *) echo "Unknown compiler type: $OS" @@ -28,60 +28,6 @@ esac set -a # Only replace compiler definitions if they are not already set case $OS in - Intel) - if [ ! -v FC ]; then - if command -v ifx &> /dev/null; then - FC=$(command -v ifx) - elif command -v ifort &> /dev/null; then - FC=$(command -v mpiifort) - else - printf "Error. Cannot find valid Intel Fortran compiler.\n" - exit 1 - fi - fi - if [ ! -v F77 ]; then - F77="${FC}" - fi - - if [ ! -v CC ]; then - if command -v icx &> /dev/null; then - CC=$(command -v icx) - elif command -v icc &> /dev/null; then - CC=$(command -v icc) - else - printf "Error. Cannot find valid Intel C compiler.\n" - exit 1 - fi - fi - - if [ ! -v CXX ]; then - if command -v icpx &> /dev/null; then - CXX=$(command -v icpx) - elif command -v icpc &> /dev/null; then - CXX=$(command -v icpc) - else - printf "Error. Cannot find valid Intel C++ compiler.\n" - exit 1 - fi - fi - - if command -v mpiifort &> /dev/null; then - I_MPI_F90=${FC} - FC=$(command -v mpiifort) - fi - - if command -v mpiicc &> /dev/null; then - I_MPI_CC =${CC} - CC=$(command -v mpiicc) - fi - - if command -v mpiicpc &> /dev/null; then - I_MPI_CXX =${CXX} - CXX=$(command -v mpiicpc) - fi - - CPP=${CPP:-$HOMEBRE_PREFIX/bin/cpp-13} - ;; Linux) FC=${FC:-$(command -v gfortran)} CC=${CC:-$(command -v gcc)} diff --git a/pyproject.toml b/pyproject.toml index d81ff9775..c8bb85fb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ requires = [ build-backend = "setuptools.build_meta" [tool.cibuildwheel] -environment = {SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=OFF"} +environment = {SKBUILD_CONFIGURE_OPTIONS="-DBUILD_SHARED_LIBS=ON"} test-command = "pytest {package}/tests" test-requires = ['pytest','cython'] test-skip = "cp312-*" @@ -20,12 +20,5 @@ skip = "pp* *i686 *-manylinux_i686 *_ppc64le *_s390x *-musllinux* *-win32" environment = {FFLAGS="${FFLAGS} -fPIC", CFLAGS="${CFLAGS} -fPIC", LDFLAGS="${LDFLAGS} -fPIE", LIBS="-lgomp"} before-all = [ "yum install doxygen -y || apt-get install doxygen -y", - "buildscripts/build_dependencies.sh -d /_dependencies -p /usr/local", + "buildscripts/build_dependencies.sh -p /usr/local", ] - -[tool.cibuildwheel.macos] -before-all = [ - "buildscripts/build_dependencies.sh -d ${TMPDIR} -p ${TMPDIR} -m ${MACOSX_DEPLOYMENT_TARGET}" -] - - \ No newline at end of file