Initial commit

This commit is contained in:
Valentin Niess
2020-03-29 11:59:23 +02:00
commit dc3acadb9a
24 changed files with 1735 additions and 0 deletions

9
python_appimage/data/apprun.sh Executable file
View File

@@ -0,0 +1,9 @@
#! /bin/bash
# Export APPRUN if running from an extracted image
self="$(readlink -f -- $0)"
here="${self%/*}"
APPDIR="${APPDIR:-${here}}"
# Call the python wrapper
"${APPDIR}/usr/bin/python{{version}}" "$@"

View File

@@ -0,0 +1,45 @@
#!/bin/bash
SCRIPT="$(readlink -f -- $0)"
SCRIPTPATH="$(dirname $SCRIPT)"
APPDIR="${APPDIR:-$SCRIPTPATH/../..}"
# Configure the environment
if [ -d "${APPDIR}/usr/share/tcltk" ]; then
export TCL_LIBRARY="$(ls -d ${APPDIR}/usr/share/tcltk/tcl* | tail -1)"
export TK_LIBRARY="$(ls -d ${APPDIR}/usr/share/tcltk/tk* | tail -1)"
export TKPATH="${TK_LIBRARY}"
fi
# Resolve symlinks within the image
prefix="opt/{{PYTHON}}"
nickname="{{PYTHON}}"
executable="${APPDIR}/${prefix}/bin/${nickname}"
if [ -L "${executable}" ]; then
nickname="$(basename $(readlink -f ${executable}))"
fi
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/${prefix}/bin/${nickname}" "$@"
exit "$?"
fi
done
# But don't resolve symlinks from outside!
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}/${prefix}" exec -a "${executable}" "$APPDIR/${prefix}/bin/${nickname}" "$@")
exit "$?"

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>python{{fullversion}}</id>
<metadata_license>Python-2.0</metadata_license>
<project_license>Python-2.0</project_license>
<name>Python {{version}}</name>
<summary>A Python {{version}} runtime</summary>
<description>
<p> A relocated Python {{version}} installation running from an
AppImage.
</p>
</description>
<launchable type="desktop-id">python.desktop</launchable>
<url type="homepage">https://python.org</url>
<provides>
<binary>python{{version}}</binary>
</provides>
</component>

View File

@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=python{{fullversion}}
Exec=python{{version}}
Comment=A Python {{version}} runtime
Icon=python
Categories=Development;
Terminal=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,26 @@
"""Hook for cleaning the paths detected by Python
"""
import os
import sys
def clean_path():
site_packages = "/usr/local/lib/python{:}.{:}/site-packages".format(
*sys.version_info[:2])
binaries_path = "/usr/local/bin"
env_path = os.getenv("PYTHONPATH")
if env_path is None:
env_path = []
else:
env_path = [os.path.realpath(path) for path in env_path.split(":")]
if ((os.path.dirname(sys.executable) != binaries_path) and
(site_packages not in env_path)):
# Remove the builtin site-packages from the path
try:
sys.path.remove(site_packages)
except ValueError:
pass
clean_path()