Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions Import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ then

fi
else
num=0
dialog --checklist "Select Tools to import with <spacebar>, 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 <spacebar>, 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
Expand Down
5 changes: 3 additions & 2 deletions PythonScript/Import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
115 changes: 60 additions & 55 deletions PythonScript/Install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]}" )"

Expand Down Expand Up @@ -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}"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions PythonScript/PythonScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Python.h>

#include "Tool.h"
#include "DataModel.h"

class PythonScript: public Tool {

Expand Down
3 changes: 0 additions & 3 deletions PythonScript/Templates/PyTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions PythonScript/Tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down