mirror of
https://github.com/niess/python-appimage.git
synced 2026-03-14 12:20:14 +01:00
Relocate the Python wrapper as entrypoint
This commit is contained in:
25
python_appimage/data/entrypoint.sh
Executable file
25
python_appimage/data/entrypoint.sh
Executable 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 "$?"
|
||||
Reference in New Issue
Block a user