#!/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 -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, 'yes' or 'no'. You must 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 --. SK_SVN_DIR=$SASKTRANCORECOMPONENTSDIR OSIRIS_VERSION_WITHSPACE=$(sed -n '//{s:[:space:]*\([-0-9\.a-zA-Z_+]*\)[:space:]*:\1: p}' ./osiris_dhs_level1/enviros.props) OSIRIS_VERSION="$(echo -e "${OSIRIS_VERSION_WITHSPACE}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" echo "OSIRIS_VERSION = $OSIRIS_VERSION" #OSIRIS_VERSION="2.49" export OSIRIS_VERSION 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 = $THIRDPARTYLIB" echo "* CLEAN projects = $CLEAN" echo "* DEBUG code = $DEBUG" echo "* OSIRIS Version = $OSIRIS_VERSION" echo "* Python Environment = $PYENVOSTR" echo "* Python manylinux = $MANYLINUXBUILD" echo "* Sasktran Core Compnts = $SASKTRANCORECOMPONENTSDIR" echo "***********************************************************************************************************" echo " " CPLUS_INCLUDE_PATH=$BASEDIR/sources:$BASEDIR/osiris_dhs_level1:$BASEDIR/osiris_dhs_level1/odinosirislib:$THIRDPARTYINCLUDE CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$BASEDIR/osiris_dhs_level1/onyx 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 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 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 LIBRARY_PATH LD_LIBRARY_PATH LD_RUN_PATH SK_SVN_DIR chmod u+x configure echo ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG osirisversion=$OSIRIS_VERSION ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG osirisversion=$OSIRIS_VERSION if [ "$CLEAN" = "yes" ]; then echo Cleaning OSIRIS Level 1 make clean fi make SK_SVN_DIR=$SK_SVN_DIR make install PYVER=`python -c "import sys;print(sys.version_info.major*10+sys.version_info.minor)"` WHEELNAME=$(ls $INSTALLDIR/pythonwheel/osl1-$OSIRIS_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 for python $PYVER" THISDIR=`pwd` cd $INSTALLDIR/pythonwheel NAME=`ls osl1*cp$PYVER*-linux_*.whl` auditwheel repair -L purelib/osl1/.libs $NAME cp ./wheelhouse/*.whl ./ WHEELNAME=$(ls $INSTALLDIR/pythonwheel/osl1-$OSIRIS_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 " Temporary Installation Directory = $INSTALLDIR" echo " Third Party Includes = $THIRDPARTYINCLUDE" echo " Third Party libraries = $THIRDPARTYLIB" echo " CLEAN projects = $CLEAN" echo " DEBUG code = $DEBUG" echo " OSIRIS Version = $OSIRIS_VERSION" echo " Python Environment = $PYENVOSTR" echo " " if [ -z "$PYENV" ] then PYENVOSTR="the current python environment" else PYENVOSTR="python environment $PYENV" fi echo "FYI: " echo " 1. The python wheel for Osiris Level 1 services, Version $OSIRIS_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 must manually install the wheel into any python environment of your choice," echo " as long as it is compatible with $PYENVOSTR." echo " " echo " > pip install --upgrade $WHEELNAME" echo " " echo " " echo "------------------------------------------------------------------------------" echo " "