aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2017-10-18 10:33:06 +0200
committerRobert Griebl <robert.griebl@pelagicore.com>2017-10-18 12:03:17 +0000
commit65854012dc821a3475d8a6ee854625e1894dffd1 (patch)
tree5c31fb2e77656e7131d091fdc47fca188c3e8634
parentfffab73c45d4da636889c0cdd9f02cb113ad7a37 (diff)
ivigenerator: Improve the deploy-virtualenv.sh script
On some linux systems the python executable is linked to a libpython.so file, which is not put into the virtualenv. This file needs to be copied as well and made sure that it is found when the binary is executed. Also the system module directory is not always located in <prefix>/lib. To find the correct locations we use the python sys module to print out all paths and search for the files in all starting with <prefix> Task-number: QTAUTO-289 Change-Id: I9b1077c89501803fa83dab02e8238fa48a005298 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rwxr-xr-xsrc/tools/ivigenerator/deploy-virtualenv.sh31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/tools/ivigenerator/deploy-virtualenv.sh b/src/tools/ivigenerator/deploy-virtualenv.sh
index b86f661..5d076e5 100755
--- a/src/tools/ivigenerator/deploy-virtualenv.sh
+++ b/src/tools/ivigenerator/deploy-virtualenv.sh
@@ -53,24 +53,33 @@ if [[ ! -e "$LIB_FOLDER/orig-prefix.txt" ]] ; then
exit 1
fi
-ORIG_PREFIX=$(<"$LIB_FOLDER"/orig-prefix.txt)
-ORIG_LIB=$ORIG_PREFIX/lib/$PYTHON_VERSION
-if [[ ! -d "$ORIG_LIB" ]] ; then
- echo "$ORIG_LIB doesn't exist"
- exit 1
+# If the python executable has a dependency towards a libpython
+# copy the file and add it as LD_LIBRARY_PATH to the activate script
+LIBPYTHON=`ldd $VIRTUALENV/bin/python | awk '{print $3}' | grep python`
+if [[ -e "$LIBPYTHON" ]] ; then
+ echo "copying $LIBPYTHON"
+ cp -Lf "$LIBPYTHON" "$LIB_FOLDER/"
+ echo "export LD_LIBRARY_PATH=`readlink -e $LIB_FOLDER/`" >> $VIRTUALENV/bin/activate
fi
+# Find all the locations used for the system python files
+# They are located in prefix, but we don't know the sub-folder (it is lib on most systems, but lib64 on some others)
+ORIG_PREFIX=$(<"$LIB_FOLDER"/orig-prefix.txt)
+ORIG_LIBS=`$VIRTUALENV/bin/python3 -c "import sys; print ('\n'.join(path for path in sys.path))" | grep $ORIG_PREFIX`
+
if [[ ! -e "$SCRIPT/deploy-virtualenv-files.txt" ]] ; then
echo "$SCRIPT/deploy-virtualenv-files.txt doesn't exist";
exit 1
fi
-echo "copying files from $ORIG_LIB to $LIB_FOLDER"
-FILES=$(<$SCRIPT/deploy-virtualenv-files.txt)
-for file in ${FILES} ; do
- expand_wildcard=($ORIG_LIB/$file)
- [ ! -e "$expand_wildcard" ] && continue;
- cp -af "$ORIG_LIB"/$file "$LIB_FOLDER/"
+for ORIG_LIB in ${ORIG_LIBS} ; do
+ echo "copying files from $ORIG_LIB to $LIB_FOLDER"
+ FILES=$(<$SCRIPT/deploy-virtualenv-files.txt)
+ for file in ${FILES} ; do
+ expand_wildcard=($ORIG_LIB/$file)
+ [ ! -e "$expand_wildcard" ] && continue;
+ cp -rLf "$ORIG_LIB"/$file "$LIB_FOLDER/"
+ done
done
if [ "$(readlink -- "$VIRTUALENV/lib64")" != "lib" ] ; then