Skip to content

Documentation: The PMFE local install wrapper script #7

@maxieds

Description

@maxieds

Since I did not have a good place to stash this source, I will log the contents of the wrapper script I wrote to get the local installation of the PMFE utilities (and sage configuration + python3 libraries) up and running. Note that this is intended as documentation of an issue we had initially running on the newer machines on campus. It is also included below to serve as documentation for how other users of the PMFE code can setup / configure / compile the code locally:

#!/bin/bash

#### RunPMFECommand.sh : Wrapper to make it easy to setup the shared library 
####                     deps to run the PMFE executables and/or call the 
####                     PMFE python libraries from within sage-math.
#### Author:   Maxie D. Schmidt
#### Created:  For math-mulberry on 2020.09.10
#### Modified: 2020.10.05 -- Changes to support environment config and print wrapper script status to stderr

PMFEWrapperScriptPrint() {
        strMsg="$1"
        PMFEWrapperScriptHdr="   \033[0;32m>>\033[0m \033[0;35m[PMFE-WRAPPER-SCRIPT]\033[0m"
        echo -ne "${PMFEWrapperScriptHdr} ${strMsg}" 1>&2
}

GetVarNameString() {
        echo -ne "\033[0;33m\$${1}\033[0m"
}

PMFEWrapperScriptUsage() {
        PMFEWrapperScriptPrint "SCRIPT USAGE: $1 <pmfe-sage|pmfe-findmfe|pmfe-parametrizer|pmfe-scorer|pmfe-subopt|pmfe-tests||make-pmfe-source> [OPT-ARGS ...]\n"
        PMFEWrapperScriptPrint "RECOGNIZED ENV SETTINGS (run \`export VARNAME=\"value\"\` to set these options): \n"
        PMFEWrapperScriptPrint "    -> "$(GetVarNameString "PMFE_DATA_PATH")": Sets the default runtime files path directory\n"
        PMFEWrapperScriptPrint "                        (defaults to \"${DEFAULT_EXE_PATH}\" if unset)\n"
        PMFEWrapperScriptPrint "    -> "$(GetVarNameString "PMFE_DEBUG")":     Specifies whether to run the selected binary with gdb to view extra logs\n"
        PMFEWrapperScriptPrint "                        (set to \"1\" or \"true\" to enable)\n"
        exit -1
}

SCRIPT_DIR_PATH=`echo "$(readlink -f ${0})" | sed -e 's/\(.*\)\/\(.*\)\.sh$/\1/'`
DEFAULT_EXE_PATH=$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/pmfe)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/BoostLocalInstall/lib)
export PYTHONPATH=$PYTHONPATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/pmfe)
export SAGE_PATH=$SAGE_PATH:$PYTHONPATH
export DOT_SAGE=$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/SageInit)
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(readlink -f $SCRIPT_DIR_PATH/GTDMMBSoftware2020/gmp-6.2.0)

if [ $# -eq 0 ]; then
        PMFEWrapperScriptPrint "ERROR: Need to pass the argument of the PMFE utility binary name you wish to run!\n"
        PMFEWrapperScriptUsage $0
fi

EXE_PATH=$DEFAULT_EXE_PATH
ENV_PMFE_RUN_PATH=$(env | grep PMFE_DATA_PATH | sed -e 's/PMFE_DATA_PATH=//g')
if [[ "${ENV_PMFE_RUN_PATH}" != "" ]]; then
        EXE_PATH=$(readlink -f $ENV_PMFE_RUN_PATH)
fi
PMFEWrapperScriptPrint "Changing current working directory to \"${EXE_PATH}\" ...\n"
cd $EXE_PATH

debugCmdPrefix=""
pmfeDebuggingOptions=$(env | grep PMFE_DEBUG | sed -e 's/PMFE_DEBUG=//g')
if [[ "$pmfeDebuggingOptions" == "1" || "$pmfeDebuggingOptions" == "true" ]]; then
        PMFEWrapperScriptPrint "Running with debugging options to view integrated boost::log library output ...\n"
        PMFEWrapperScriptPrint "Once the utilty has run, type 'q' then 'y' to exit, or continue to debug ...\n"
        debugCmdPrefix="gdb -ex run --args "
fi

pmfeCmd=$1
pmfeCmdArgs="${@:2}"
validBinaryArg=0
case "${pmfeCmd}" in
        "pmfe-findmfe")      LD_LIBRARY_PATH=$LD_LIBRARY_PATH $debugCmdPrefix $DEFAULT_EXE_PATH/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;;
        "pmfe-parametrizer") LD_LIBRARY_PATH=$LD_LIBRARY_PATH $debugCmdPrefix $DEFAULT_EXE_PATH/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;;
        "pmfe-scorer")       LD_LIBRARY_PATH=$LD_LIBRARY_PATH $debugCmdPrefix $DEFAULT_EXE_PATH/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;;
        "pmfe-subopt")       LD_LIBRARY_PATH=$LD_LIBRARY_PATH $debugCmdPrefix $DEFAULT_EXE_PATH/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;;
        "pmfe-tests")        LD_LIBRARY_PATH=$LD_LIBRARY_PATH $debugCmdPrefix $DEFAULT_EXE_PATH/$pmfeCmd $pmfeCmdArgs ; validBinaryArg=1 ;;
        "pmfe-sage")         LD_LIBRARY_PATH=$LD_LIBRARY_PATH PYTHONPATH=$PYTHONPATH DOT_SAGE=$DOT_SAGE sage          ; validBinaryArg=1 ;;
        "make-pmfe-source")  PKG_CONFIG_PATH=$PKG_CONFIG_PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH make && \
                                find . -type d -exec chmod g+rwxs {} \+ && \
                                find . -type f -exec chmod g+rw {} \+ && \
                                find . -type f -perm /u+x -exec chmod g+x {} \+ && \
                                chgrp -R local-group-name . ; validBinaryArg=1 ;;
esac

if [[ "$validBinaryArg" != "1" ]]; then
        PMFEWrapperScriptPrint "ERROR: Invalid PMFE utility binary argument type specified!\n"
        PMFEWrapperScriptUsage $0
fi

exit 0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions