Relocate the Python wrapper as entrypoint

This commit is contained in:
Valentin Niess
2020-04-20 18:18:38 +02:00
parent b7cd6d0b85
commit 8378957adf
4 changed files with 37 additions and 62 deletions

View File

@@ -0,0 +1,25 @@
for opt in "$@"
do
[ "${opt:0:1}" != "-" ] && break
if [[ "${opt}" =~ "I" ]] || [[ "${opt}" =~ "E" ]]; then
# Environment variables are disabled ($PYTHONHOME). Let's run in a safe
# mode from the raw Python binary inside the AppImage
"$APPDIR/opt/{{ python }}/bin/{{ python }}" "$@"
exit "$?"
fi
done
# Get the executable name, i.e. the AppImage or the python binary if running from an
# extracted image
executable="${APPDIR}/opt/{{ python }}/{{ python }}"
if [[ "${ARGV0}" =~ "/" ]]; then
executable="$(cd $(dirname ${ARGV0}) && pwd)/$(basename ${ARGV0})"
elif [[ "${ARGV0}" != "" ]]; then
executable=$(which "${ARGV0}")
fi
# Wrap the call to Python in order to mimic a call from the source
# executable ($ARGV0), but potentially located outside of the Python
# install ($PYTHONHOME)
(PYTHONHOME="${APPDIR}/opt/{{ python }}" exec -a "${executable}" "$APPDIR/opt/{{ python }}/bin/{{ python }}" "$@")
exit "$?"