Make muOS launcher prefer local venv
This commit is contained in:
@@ -4,11 +4,17 @@ set -eu
|
|||||||
|
|
||||||
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||||
|
|
||||||
|
log() {
|
||||||
|
printf '[mice-launcher] %s\n' "$*"
|
||||||
|
}
|
||||||
|
|
||||||
find_game_dir() {
|
find_game_dir() {
|
||||||
for candidate in \
|
for candidate in \
|
||||||
"$SCRIPT_DIR" \
|
|
||||||
"$SCRIPT_DIR/mice" \
|
"$SCRIPT_DIR/mice" \
|
||||||
|
"$SCRIPT_DIR" \
|
||||||
|
/mnt/mmc/ports/mice \
|
||||||
/roms/ports/mice \
|
/roms/ports/mice \
|
||||||
|
"$HOME/mice-current" \
|
||||||
/root/mice \
|
/root/mice \
|
||||||
"$HOME/mice"; do
|
"$HOME/mice"; do
|
||||||
if [ -f "$candidate/rats.py" ]; then
|
if [ -f "$candidate/rats.py" ]; then
|
||||||
@@ -19,12 +25,13 @@ find_game_dir() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
find_conda() {
|
find_python() {
|
||||||
for candidate in \
|
for candidate in \
|
||||||
/home/ark/miniconda3/bin/conda \
|
"$GAMEDIR/.venv/bin/python" \
|
||||||
/root/miniconda3/bin/conda \
|
"$HOME/miniconda3/bin/python" \
|
||||||
"$HOME/miniconda3/bin/conda" \
|
/root/miniconda3/bin/python \
|
||||||
/usr/bin/conda; do
|
/usr/bin/python3 \
|
||||||
|
/usr/bin/python; do
|
||||||
if [ -x "$candidate" ]; then
|
if [ -x "$candidate" ]; then
|
||||||
printf '%s\n' "$candidate"
|
printf '%s\n' "$candidate"
|
||||||
return 0
|
return 0
|
||||||
@@ -51,7 +58,15 @@ detect_keybindings_profile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GAMEDIR=$(find_game_dir)
|
GAMEDIR=$(find_game_dir)
|
||||||
CONDABIN=$(find_conda)
|
PYTHONBIN=$(find_python)
|
||||||
|
|
||||||
|
mkdir -p "$GAMEDIR/logs"
|
||||||
|
LOGFILE="$GAMEDIR/logs/launcher.log"
|
||||||
|
exec >>"$LOGFILE" 2>&1
|
||||||
|
|
||||||
|
log "script_dir=$SCRIPT_DIR"
|
||||||
|
log "game_dir=$GAMEDIR"
|
||||||
|
log "python=$PYTHONBIN"
|
||||||
|
|
||||||
export MICE_PROJECT_ROOT="$GAMEDIR"
|
export MICE_PROJECT_ROOT="$GAMEDIR"
|
||||||
|
|
||||||
@@ -60,8 +75,9 @@ if [ -z "${MICE_KEYBINDINGS_PROFILE:-}" ]; then
|
|||||||
export MICE_KEYBINDINGS_PROFILE
|
export MICE_KEYBINDINGS_PROFILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval "$($CONDABIN shell.bash hook)"
|
if [ -n "${MICE_KEYBINDINGS_PROFILE:-}" ]; then
|
||||||
conda activate myenv
|
log "keybindings_profile=$MICE_KEYBINDINGS_PROFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
cd "$GAMEDIR"
|
cd "$GAMEDIR"
|
||||||
python rats.py
|
exec "$PYTHONBIN" rats.py
|
||||||
|
|||||||
Reference in New Issue
Block a user