mirror of
https://github.com/niess/python-appimage.git
synced 2026-03-14 04:10:15 +01:00
Relocate python wrapper
This commit is contained in:
@@ -1,18 +1,10 @@
|
||||
{{ shebang }}
|
||||
|
||||
# If running from an extracted image, then export ARGV0 and APPDIR
|
||||
# If running from an extracted image, then export APPDIR
|
||||
if [ -z "${APPIMAGE}" ]; then
|
||||
export ARGV0=$0
|
||||
|
||||
self="$(readlink -f -- $0)"
|
||||
here="${self%/*}"
|
||||
export APPDIR="${APPDIR:-${here}}"
|
||||
export APPDIR="${self%/*}"
|
||||
fi
|
||||
|
||||
# Resolve the calling command (preserving symbolic links).
|
||||
export APPIMAGE_COMMAND="$(command -v -- $ARGV0)"
|
||||
{{ tcltk-env }}
|
||||
{{ cert-file }}
|
||||
|
||||
# Call the entry point
|
||||
# Call the application entry point
|
||||
{{ entrypoint }}
|
||||
|
||||
19
python_appimage/data/python-wrapper.sh
Executable file
19
python_appimage/data/python-wrapper.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
{{ shebang }}
|
||||
|
||||
# If running from an extracted image, then export ARGV0 and APPDIR
|
||||
if [ -z "${APPIMAGE}" ]; then
|
||||
export ARGV0=$0
|
||||
|
||||
self="$(readlink -f -- $0)"
|
||||
here="${self%/*}"
|
||||
tmp="${here%/*}"
|
||||
export APPDIR="${tmp%/*}"
|
||||
fi
|
||||
|
||||
# Resolve the calling command (preserving symbolic links).
|
||||
export APPIMAGE_COMMAND="$(command -v -- $ARGV0)"
|
||||
{{ tcltk-env }}
|
||||
{{ cert-file }}
|
||||
|
||||
# Call Python
|
||||
{{ entrypoint }}
|
||||
@@ -16,6 +16,11 @@ def patch_pip_install():
|
||||
if not 'pip' in sys.modules:
|
||||
return
|
||||
|
||||
appdir = os.getenv('APPDIR')
|
||||
python_x_y = 'python{:}.{:}'.format(*sys.version_info[:2])
|
||||
if sys.prefix != '{:}/opt/{:}'.format(appdir, python_x_y):
|
||||
return
|
||||
|
||||
args = sys.argv[1:]
|
||||
if 'install' in args:
|
||||
for exe in os.listdir(sys.prefix + '/bin'):
|
||||
@@ -36,13 +41,15 @@ def patch_pip_install():
|
||||
continue
|
||||
|
||||
shebang, body = content.split(os.linesep, 1)
|
||||
shebang = shebang.split()
|
||||
python_x_y = os.path.basename(shebang.pop(0))
|
||||
if not python_x_y.startswith('python'):
|
||||
shebang = shebang.strip().split()
|
||||
executable = shebang.pop(0)
|
||||
if executable != sys.executable:
|
||||
head, altbody = body.split(os.linesep, 1)
|
||||
if head.startswith("'''exec' /"): # Patch for alt shebang
|
||||
body = altbody.split(os.linesep, 1)[1]
|
||||
python_x_y = os.path.basename(head.split()[1])
|
||||
executable = head.split()[1]
|
||||
if executable != sys.executable:
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user