Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 56f48b0f authored by hhakim's avatar hhakim
Browse files

Enhance deb/rpm post-installation script for python wrapper (more info and verifs).

[skip ci]
parent daa2823d
No related branches found
No related tags found
No related merge requests found
......@@ -8,19 +8,36 @@ uid=$(id -u)
[[ -z "$FAUST_PY_WRAPPER_PATH" ]] && echo "USAGE: $0 <path>" && exit 2
[[ ! -d "$FAUST_PY_WRAPPER_PATH" ]] && echo "ERROR: directory $FAUST_PY_WRAPPER_PATH doesn't exist" && exit 3
SUPPORTED_PY3=6
function link_py_files(){
PY_MAJOR_VER=$1
PY_MAJOR_MINOR_VER=$(python$PY_MAJOR_VER --version 2>&1 | sed -e 's/.*[[:blank:]]\{1,\}\([[:digit:]]\.[[:digit:]]\)\.[[:digit:]]\{1,\}/\1/')
PY_SITE_PACKAGES_PATH=$(python$PY_MAJOR_VER -c 'import os,site,re;print([path for path in site.getsitepackages() if re.match(".*"+os.path.sep+"site-packages$", path) and os.path.exists(path) ][0])')
# on fedora python package path are suffixed by site-packages, on ubuntu it's rather dist-packages (TODO: on centos ? on debian ?)
PY_SITE_PACKAGES_PATH=$(python$PY_MAJOR_VER -c 'import os,site,re;print([path for path in site.getsitepackages() if (re.match(".*"+os.path.sep+"site-packages$", path) or re.match(".*"+os.path.sep+"dist-packages$", path)) and os.path.exists(path) ][0])')
[[ ! -d ${PY_SITE_PACKAGES_PATH} ]] && echo -e "\033[1mWARNING\033[0m: couldn't link the Faust py wrapper for python$PY_MAJOR_VER to your system. Either python$PY_MAJOR_VER is not installed on your system and that's pretty normal or it failed for another reason and you'll have to add Faust to your PYTHONPATH manually for using it (see the documentation)." >&2 && return 1
PYFILES=${FAUST_PY_WRAPPER_PATH}/FaustPy.py
[[ "$PY_MAJOR_MINOR_VER" = 3* ]] && PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.cpython-3*so" || \
PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.so"
[[ -n "$DEBUG" ]] && echo PY_MAJOR_VER=$PY_MAJOR_MINOR_VER
if [[ "$PY_MAJOR_VER" = 3* ]]
then
[[ ! "$PY_MAJOR_MINOR_VER" = 3.$SUPPORTED_PY3 ]] && echo -e "\033[1mWARNING\033[0m: your python3 version ($PY_MAJOR_MINOR_VER) is not supported by Faust (only 3.$SUPPORTED_PY3 is supported). Please rely on Faust for python2." && return 2 || PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.cpython-3${SUPPORTED_PY3}m-x86_64-linux-gnu.so"
else #py2
PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.so"
fi
[[ -n "$DEBUG" ]] && echo PYFILES=$PYFILES
local PYLINKS_FAIL_COUNT
typeset -i PYLINKS_FAIL_COUNT=0
for PYFILE in $PYFILES
do
PYLINK="${PY_SITE_PACKAGES_PATH}/$(basename "$PYFILE")"
[[ -n "$DEBUG" ]] && echo ln -sf "$PYFILE" "${PY_SITE_PACKAGES_PATH}/"
[[ -n "$DEBUG" ]] && echo PYLINK=$PYLINK
[[ -r "${PYLINK}" ]] && rm -f "$PYLINK"
[[ -r "$PYFILE" ]] && ln -sf "$PYFILE" "${PY_SITE_PACKAGES_PATH}/"
done && echo "Linked py wrapper version $PY_MAJOR_VER into ${PY_SITE_PACKAGES_PATH}."
[[ ! -r "$PYLINK" ]] && PYLINKS_FAIL_COUNT+=1
[[ -n "$DEBUG" ]] && echo PYLINKS_FAIL_COUNT=$PYLINKS_FAIL_COUNT
done
[[ $PYLINKS_FAIL_COUNT = 0 ]] && echo -e "\033[1mNOTICE\033[0m: Linked py wrapper for python$PY_MAJOR_VER into ${PY_SITE_PACKAGES_PATH}. Installation's ok for python$PY_MAJOR_MINOR_VER."
}
for V in 2 3
......@@ -28,5 +45,5 @@ do
which python$V 2>&1 > /dev/null && link_py_files $V
done
exit 0 # to avoid exit failure result when only one version of py is found (or it'll make the macOS installer fail)
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment