From 48c64b1a21b79844f45b3a2c627d5015dafd8d6b Mon Sep 17 00:00:00 2001 From: brichards Date: Fri, 19 Jan 2024 11:56:50 +0000 Subject: [PATCH 1/2] updated for v3.0 --- SubToolChain/SubToolChain.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SubToolChain/SubToolChain.h b/SubToolChain/SubToolChain.h index 44ffed4..92045bb 100644 --- a/SubToolChain/SubToolChain.h +++ b/SubToolChain/SubToolChain.h @@ -5,8 +5,10 @@ #include #include "Tool.h" +#include "DataModel.h" +#include "ToolChain.h" -class ToolChain; +//class ToolChain; /** * \class SubToolChain From 0e27e20512f95dcd34f5f76dcb85af7ff3e9d6b0 Mon Sep 17 00:00:00 2001 From: Marcus O'Flaherty Date: Fri, 26 Jan 2024 17:57:44 +0000 Subject: [PATCH 2/2] updates to PythonTool imports for rocky 9 and ToolFrameworkCore v3 --- Import.sh | 21 ++++-- PythonScript/Import.sh | 5 +- PythonScript/Install.sh | 115 ++++++++++++++++--------------- PythonScript/PythonScript.h | 1 + PythonScript/Templates/PyTool.py | 3 - PythonScript/Tool.py | 7 +- 6 files changed, 81 insertions(+), 71 deletions(-) diff --git a/Import.sh b/Import.sh index c194647..1ba5d92 100755 --- a/Import.sh +++ b/Import.sh @@ -38,13 +38,20 @@ then fi else - num=0 - dialog --checklist "Select Tools to import with , Enter for OK and ESC for Cancel:" 0 0 0 \ - `for Tool in \`ls -d */|sed s:/::\` - do - echo "$Tool $num off " - num=$(expr 1 + $num) - done` 2> tmptools + echo "" > tmptools + if [ $# -gt 0 ]; then + for i in `seq 1 $#`; do + echo ${!i} >> tmptools + done + else + num=0 + dialog --checklist "Select Tools to import with , Enter for OK and ESC for Cancel:" 0 0 0 \ + `for Tool in \`ls -d */|sed s:/::\` + do + echo "$Tool $num off " + num=$(expr 1 + $num) + done` 2> tmptools + fi if [ $? -eq 0 ] then diff --git a/PythonScript/Import.sh b/PythonScript/Import.sh index 12f557e..ec90915 100755 --- a/PythonScript/Import.sh +++ b/PythonScript/Import.sh @@ -39,11 +39,12 @@ LIBFLAGS=$(python3-config --ldflags --embed &>/dev/null && echo "python3-config LIBLINE='MyToolsLib += `'"${LIBFLAGS}"'`' awk -i inplace -v "var=${LIBLINE}" '{print} /MyToolsLib/ && !x {print var; x=1}' ${ToolAppPath}/Makefile -# add the path to cppyy module to the Setup.sh +# add the path to cppyy module and the base python Tool class to the Setup.sh PACKAGEPATH=$(python3 -m pip show cppyy_backend | grep 'Location' | cut -d' ' -f 2) -cat << EOF >> ${TOOLFRAMEWORKDIR}/Setup.sh +cat << EOF >> ${ToolAppPath}/Setup.sh export PYTHONPATH=${PACKAGEPATH}:\$PYTHONPATH +export PYTHONPATH=${ToolAppPath}/UserTools/ImportedTools/TFToolPack/PythonScript:${PYTHONPATH} EOF diff --git a/PythonScript/Install.sh b/PythonScript/Install.sh index efe107d..3dfaef3 100755 --- a/PythonScript/Install.sh +++ b/PythonScript/Install.sh @@ -2,6 +2,58 @@ #set -x #set -e +# a function to check for presence of cppyy. New ROOT versions come with it. +# XXX for some reason this doesn't like the use of tab for whitespace!!! XXX +checkcppyy(){ + # a quick test, also trigger rebuilding of the pch + echo "the following test should print 0·1·2·3·4·5·6·7·8·9¶" + # especially no indents here or python complains + PYCMDS=" +import cppyy +from cppyy.gbl.std import vector +v = vector[int](range(10)) +for m in v: print(m, end=' ') +" + RESULT=$(echo "${PYCMDS}" | python3) + + # we need to do it twice as the first time it prints out a message about recompiling the header + RESULT=$(echo "${PYCMDS}" | python3) + + # trim whitespace + RESULT="$(echo -n ${RESULT} | xargs echo -n)" + echo $RESULT | sed 's/ /·/g;s/\t/→/g;s/\r/§/g;s/$/¶/g' # check whitespace + if [ "$RESULT" != "0 1 2 3 4 5 6 7 8 9" ]; then + echo "Test Failed! Check your installation of python3 and cppyy!" + return 1 + else + echo "Test Passed" + return 0 + fi +} + +echo "checking for pre-existing presence of cppyy" +checkcppyy +if [ $? -eq 0 ]; then + # if we already have it, we have no further actions to take in the Install script + echo "cppyy already installed. PyTool installation completed successfully" + exit 0 +fi + +# otherwise we need to install it +echo "failed to find existing (working) cppyy install; install one now?" +select result in Yes No; do + if [ "$result" == "Yes" ] || [ "$result" == "No" ]; then + if [ "$result" == "No" ]; then + echo "terminating."; + exit 1; + else + break; + fi + else + echo "please enter 1 or 2"; + fi +done + CURDIR=${PWD} # in case we need to return to it. unused. cd "$( dirname "${BASH_SOURCE[0]}" )" @@ -108,7 +160,8 @@ else else echo "Installing dependencies..." if [ ${REDHATLIKE} -eq 0 ]; then - yum install -y "${NEEDDEPS}" + # somehow 'yum install -y ${NEEDDEPS} doesnt work in a script + echo "${NEEDDEPS}" | xargs yum install -y INSTALLOK=$? elif [ ${DEBIANLIKE} -eq 0 ]; then apt-get install -y "${NEEDDEPS}" @@ -134,42 +187,7 @@ else fi fi -# a function to check for presence of cppyy. New ROOT versions come with it. -# XXX for some reason this doesn't like the use of tab for whitespace!!! XXX -checkcppyy(){ - # a quick test, also trigger rebuilding of the pch - echo "the following test should print 0·1·2·3·4·5·6·7·8·9¶" - # especially no indents here or python complains - PYCMDS=" -import cppyy -from cppyy.gbl.std import vector -v = vector[int](range(10)) -for m in v: print(m, end=' ') -" - RESULT=$(echo "${PYCMDS}" | python3) - - # we need to do it twice as the first time it prints out a message about recompiling the header - RESULT=$(echo "${PYCMDS}" | python3) - - # trim whitespace - RESULT="$(echo -n ${RESULT} | xargs echo -n)" - echo $RESULT | sed 's/ /·/g;s/\t/→/g;s/\r/§/g;s/$/¶/g' # check whitespace - if [ "$RESULT" != "0 1 2 3 4 5 6 7 8 9" ]; then - echo "Test Failed! Check your installation of python3 and cppyy!" - return 1 - else - echo "Test Passed" - return 0 - fi -} -echo "checking for pre-existing presence of cppyy" -checkcppyy -if [ $? -eq 0 ]; then - # if we already have it, we have no further actions to take. - echo "cppyy already installed. PyTool installation completed successfully" - exit 0 -fi # XXX TODO replace all this user-directory nonsense with # --prefix, --root or --target @@ -204,8 +222,12 @@ if [ ${GOTSUDO} -eq 1 ] && [ "$(whoami)" != "root" ]; then SUDOCMD="sudo " fi +# only offer to install to user home dir if user is not root +if [ "$(whoami)" != "root" ]; then + OPTIONS="${THISUSER}" +fi + # seems like we also need to be root to pip install system-wide -OPTIONS="${THISUSER}" if [ ${GOTSUDO} -eq 0 ] || [ "$(whoami)" == "root" ]; then OPTIONS="System ${OPTIONS}" fi @@ -289,25 +311,8 @@ $SUDOFLAGS python3 -m pip install $PIPFLAGS --upgrade pip # we'll also need wheel, or the CPyCppyy install will fail $SUDOFLAGS python3 -m pip install $PIPFLAGS wheel -# otherwise we need to install it -echo "failed to find existing (working) cppyy install; install one now?" -select result in Yes No; do - if [ "$result" == "Yes" ] || [ "$result" == "No" ]; then - if [ "$result" == "No" ]; then - echo "terminating."; - exit 1; - else - break; - fi - else - echo "please enter 1 or 2"; - fi -done - -# if we got here user said yes: proceed with cppyy installation - # setup installation environment -export STDCXX=11 +#export STDCXX=11 # https://github.com/root-project/root/issues/8281 #export EXTRA_CLING_ARGS='-nocudainc' export CLING_REBUID_PCH=1 export PATH=/home/${THISUSER}/.local/bin:$PATH diff --git a/PythonScript/PythonScript.h b/PythonScript/PythonScript.h index 6f6e298..c0eae74 100644 --- a/PythonScript/PythonScript.h +++ b/PythonScript/PythonScript.h @@ -6,6 +6,7 @@ #include #include "Tool.h" +#include "DataModel.h" class PythonScript: public Tool { diff --git a/PythonScript/Templates/PyTool.py b/PythonScript/Templates/PyTool.py index 4423167..bbeb9dc 100644 --- a/PythonScript/Templates/PyTool.py +++ b/PythonScript/Templates/PyTool.py @@ -4,9 +4,6 @@ class TestPython(Tool): - # declare member variables here - demovariable = 'TestString' - def Initialise(self): self.m_log.Log(__file__+" Initialising", self.v_debug, self.m_verbosity) self.m_variables.Print() diff --git a/PythonScript/Tool.py b/PythonScript/Tool.py index 8919e13..1a71cdd 100644 --- a/PythonScript/Tool.py +++ b/PythonScript/Tool.py @@ -7,13 +7,12 @@ std = cppyy.gbl.std # pull in classes from the DataModel cppyy.add_include_path('include') -cppyy.add_include_path('ToolDAQ/boost_1_66_0/install/include') -cppyy.add_include_path('ToolDAQ/zeromq-4.0.7/include') +cppyy.add_include_path('Dependencies/ToolFrameworkCore/include') cppyy.include('DataModel.h') cppyy.load_library('libDataModel.so') from cppyy.gbl import DataModel -from cppyy.gbl import Store -from cppyy.gbl import Logging +from cppyy.gbl.ToolFramework import Store +from cppyy.gbl.ToolFramework import Logging # import infrastructure for declaring an abstract base class from abc import ABC, abstractmethod