mirror of
https://github.com/niess/python-appimage.git
synced 2026-03-14 04:10:15 +01:00
Initial commit
This commit is contained in:
9
python_appimage/data/apprun.sh
Executable file
9
python_appimage/data/apprun.sh
Executable 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}}" "$@"
|
||||
45
python_appimage/data/python-wrapper.sh
Executable file
45
python_appimage/data/python-wrapper.sh
Executable 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 "$?"
|
||||
18
python_appimage/data/python.appdata.xml
Normal file
18
python_appimage/data/python.appdata.xml
Normal 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>
|
||||
8
python_appimage/data/python.desktop
Normal file
8
python_appimage/data/python.desktop
Normal 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
|
||||
BIN
python_appimage/data/python.png
Normal file
BIN
python_appimage/data/python.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
26
python_appimage/data/sitecustomize.py
Normal file
26
python_appimage/data/sitecustomize.py
Normal 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()
|
||||
Reference in New Issue
Block a user