#!/bin/bash # Abort if an error occurs set -e PYENVOSTR='Default' BASEDIR=`pwd` SASKTRANCORECOMPONENTSDIR=$BASEDIR/../SasktranCoreComponents THIRDPARTYINCLUDE=~/thirdparty/include THIRDPARTYLIB=~/thirdparty/lib INSTALLDIR=~/localinstall MANYLINUXBUILD='no' PYENV="" DEBUG='no' CLEAN='no' while getopts "b:i:l:p:s:mchg" opt; do case $opt in m) MANYLINUXBUILD="yes" ;; b) INSTALLDIR=$OPTARG ;; i) THIRDPARTYINCLUDE=$OPTARG ;; p) PYENV=$OPTARG ;; s) SASKTRANCORECOMPONENTSDIR=$OPTARG ;; l) THIRDPARTYLIB=$OPTARG ;; c) CLEAN="yes" ;; g) DEBUG="yes" ;; h) echo "* buildpratmo -b -s -i -m -p -g -c -h" echo "* " echo "* Options:" echo "* -b : Install libraries, executables, caches registry under this folder" echo "* default is ~/localinstall" echo "* -i : Directories used to search for header files of third party software, colon separated list, default is ~/thirdparty/include" echo "* -l : Directories used to search for third party libraries, colon separated list, default is ~/thirdparty/lib" echo "* -p : Build the wheel using the specified python environment" echo "* uses 'source activate ' and 'source deactivate', default uses current python environment" echo "* -m : Build the manylinux python wheel. You should be in a suitable Docker environment, default no" echo "* -s : The location of the SasktranCoreComponents folder" echo "* default is ../SasktranCoreComponents" echo "* -c : clean the projects as they are built. Default is not to clean." echo "* -g : Build debug versions. Note that you should also use option -c to ensure" echo "* all objects are rebuilt in debug mode" echo "* -h : print this message and exit" echo "* " echo "***********************************************************************************************************" exit ;; \?) echo "Invalid option: -$OPTARG" >&2 exit ;; esac done shift "$((OPTIND-1))" # Shift off the options and optional --. PRATMO_VERSION_WITHSPACE=$(sed -n '//{s:[:space:]*\([-0-9\.a-zA-Z_]*\)[:space:]*:\1: p}' ./pratmo_version.props) PRATMO_VERSION="$(echo -e "${PRATMO_VERSION_WITHSPACE}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" if [ -z "$PYENV" ] then PYENVOSTR="Current Environment" else PYENVOSTR="$PYENV" fi echo "* Options Used for Build" echo "* ----------------------" echo "* Installation Directory = $INSTALLDIR" echo "* Third Party Includes = $THIRDPARTYINCLUDE" echo "* Third Party Includes = $THIRDPARTYLIBRARY" echo "* CLEAN projects = $CLEAN" echo "* DEBUG code = $DEBUG" echo "* PRATMO Version = $PRATMO_VERSION" echo "* Python Environment = $PYENVOSTR" echo "* Python manylinux = $MANYLINUXBUILD" echo "* Sasktran Core Compnts = $SASKTRANCORECOMPONENTSDIR" echo "***********************************************************************************************************" echo " " CPLUS_INCLUDE_PATH=$BASEDIR/sources:$BASEDIR/sources/Pratmo CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_BaseCode/nxbase CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_BaseCode/lapack CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_BaseCode/atombase CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_SasktranIF CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_SasktranV3 CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_skclimatology CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_skopticalproperties CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_BaseCode/nxhdf/nxnetcdfio CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_BaseCode/nxhdf/nxhdfeos CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SASKTRANCORECOMPONENTSDIR/Repos_BaseCode/nxhdf/nxhdfeos5 CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$THIRDPARTYINCLUDE CORE_INCLUDE=$CPLUS_INCLUDE_PATH LIBRARY_PATH=$INSTALLDIR/lib/Release:$THIRDPARTYLIB:$LIBRARY_PATH LD_LIBRARY_PATH=$LIBRARY_PATH LD_RUN_PATH=$THIRDPARTYLIB:$LD_RUN_PATH export CPLUS_INCLUDE_PATH LIBRARY_PATH LD_LIBRARY_PATH LD_RUN_PATH PRATMO_VERSION if [ "$PYENVOSTR" != "Default" ]; then echo "Activating Anaconda Python environment $PYENVOSTR" source activate $PYENVOSTR fi # Load in the modified environment variables INCLUDE=$CPLUS_INCLUDE_PATH C_INCLUDE_PATH=$CPLUS_INCLUDE_PATH LDFLAGS="-L$INSTALLDIR/lib/Release" F77=gfortran export INCLUDE CPLUS_INCLUDE_PATH F77 C_INCLUDE_PATH LDFLAGS #echo "The following environment variable shave been created and/or modifified" #echo "INCLUDE = $INCLUDE" #echo "CPLUS_INCLUDE_PATH = $CPLUS_INCLUDE_PATH" #echo "F77 = $F77" #echo "C_INCLUDE_PATH = $C_INCLUDE_PATH" #echo "LDFLAGS = $LDFLAGS" chmod u+x configure ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG pratmoversion=$PRATMO_VERSION if [ "$CLEAN" = "yes" ]; then echo Cleaning Repos_Pratmo make clean fi make make install PYVER=`python -c "import sys;print(sys.version_info.major*10+sys.version_info.minor)"` WHEELNAME=$(ls $INSTALLDIR/pythonwheel/pratmo-$PRATMO_VERSION-cp$PYVER*-linux_*.whl) if [ "$PYENVOSTR" != "Default" ]; then echo "Deactivating Anaconda Python environment $PYENVOSTR" source deactivate $PYENVOSTR fi if [ "$MANYLINUXBUILD" = "yes" ]; then echo "Making the manylinux python wheel" THISDIR=`pwd` cd $INSTALLDIR/pythonwheel NAME=`ls pratmo*cp$PYVER*-linux_*.whl` auditwheel repair $WHEELNAME cp ./wheelhouse/*.whl ./ WHEELNAME=$(ls pratmo-$PRATMO_VERSION-cp$PYVER*-manylinux*.whl) cd $THISDIR fi echo " " echo "__ ___ _ _ _ " echo "\ \ / / |__ ___ ___ | | | | ___ ___ | | " echo " \ \ /\ / /| '_ \ / _ \ / _ \ | |_| |/ _ \ / _ \| | " echo " \ V V / | | | | (_) | (_) | | _ | (_) | (_) |_| " echo " \_/\_/ |_| |_|\___/ \___/ |_| |_|\___/ \___/(_) " echo " " echo " _____ _ ____ _ _ " echo "|_ _| |__ ___ | _ \ _ _| |_| |__ ___ _ __ " echo " | | | '_ \ / _ \ | |_) | | | | __| '_ \ / _ \| '_ \ " echo " | | | | | | __/ | __/| |_| | |_| | | | (_) | | | | " echo " |_| |_| |_|\___| |_| \__, |\__|_| |_|\___/|_| |_| " echo " |___/ " echo "__ ___ _ ___ ____ _ _ _ " echo "\ \ / / |__ ___ ___| | |_ _|___ | __ ) _ _(_) | |_ " echo " \ \ /\ / /| '_ \ / _ \/ _ \ | | |/ __| | _ \| | | | | | __| " echo " \ V V / | | | | __/ __/ | | |\__ \ | |_) | |_| | | | |_ " echo " \_/\_/ |_| |_|\___|\___|_| |___|___/ |____/ \__,_|_|_|\__| " echo " " echo " -------------------------------------------------------------- " echo " ____ _ _ _ " echo "| _ \ ___ __ _ __| | | |_| |__ ___ " echo "| |_) / _ \/ _ |/ _ | | __| '_ \ / _ \ " echo "| _ < __/ (_| | (_| | | |_| | | | __/ " echo "|_| \_\___|\__,_|\__,_| \__|_| |_|\___| " echo " " echo " _ _ _ _ " echo "(_)_ __ ___| |_ _ __ _ _ ___| |_(_) ___ _ __ ___ " echo "| | '_ \/ __| __| '__| | | |/ __| __| |/ _ \| '_ \/ __| " echo "| | | | \__ \ |_| | | |_| | (__| |_| | (_) | | | \__ \ " echo "|_|_| |_|___/\__|_| \__,_|\___|\__|_|\___/|_| |_|___/ " echo " " echo " _ _ _ " echo "| |__ ___| | _____ _| | " echo "| '_ \ / _ \ |/ _ \ \ /\ / / | " echo "| |_) | __/ | (_) \ V V /|_| " echo "|_.__/ \___|_|\___/ \_/\_/ (_) " echo " " echo " ---------------------------------------------------------------------------" echo " " echo " Here is a recap of the options used for the build" echo " -------------------------------------------------" echo " Python Wheel at = $INSTALLDIR/pythonwheel/$WHEELNAME" echo " Third Party Includes = $THIRDPARTYINCLUDE" echo " Third Party libraries = $THIRDPARTYLIB" echo " CLEAN projects = $CLEAN" echo " DEBUG code = $DEBUG" echo " Pratmo Code Version = $PRATMO_VERSION" echo " Python Environment = $PYENVOSTR" echo " " echo "FYI: " echo " 1. The python wheel for pratmo, Version $PRATMO_VERSION has been built." echo " 2. The wheel can be found in directory $INSTALLDIR/pythonwheel." echo " 3. The wheel was built using $PYENVOSTR" echo " 4. The wheel can be installed into any compatible python environment." echo " " echo " Wheel Installation Details:" echo " ---------------------------" echo " You can install the wheel into a python environment compatible with $PYENVOSTR." echo " " echo " > pip install --upgrade $WHEELNAME" echo " " echo " You must install sasktranif first as pratmo is a dependent upon sasktranif". echo " " echo "------------------------------------------------------------------------------" echo " "