Skip to content

Commit

Permalink
Update gui.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaltais committed Jun 23, 2023
1 parent 6e85331 commit 5d51b7e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# If it is run with the sudo command, get the complete LD_LIBRARY_PATH environment variable of the system and assign it to the current environment,
# because it will be used later.
if [ -n "$SUDO_USER" ] || [ -n "$SUDO_COMMAND" ] ; then
if [ -n "$SUDO_USER" ] || [ -n "$SUDO_COMMAND" ]; then
echo "The sudo command resets the non-essential environment variables, we keep the LD_LIBRARY_PATH variable."
export LD_LIBRARY_PATH=$(sudo -i printenv LD_LIBRARY_PATH)
fi
Expand All @@ -11,18 +11,23 @@ fi
SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd)

# Step into GUI local directory
cd "$SCRIPT_DIR"
cd "$SCRIPT_DIR" || exit 1

# Activate the virtual environment
source "$SCRIPT_DIR/venv/bin/activate"
source "$SCRIPT_DIR/venv/bin/activate" || exit 1

# If the requirements are validated, run the kohya_gui.py script with the command-line arguments
# Determine the requirements file based on the system
if [[ "$OSTYPE" == "darwin"* ]]; then
if python "$SCRIPT_DIR"/setup/validate_requirements.py -r "$SCRIPT_DIR"/requirements_macos.txt; then
python "$SCRIPT_DIR/kohya_gui.py" "$@"
if [[ "$(uname -m)" == "arm64" ]]; then
REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_macos_arm64.txt"
else
REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_macos_amd64.txt"
fi
else
if python "$SCRIPT_DIR"/setup/validate_requirements.py -r "$SCRIPT_DIR"/requirements_linux.txt; then
python "$SCRIPT_DIR/kohya_gui.py" "$@"
fi
REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_linux.txt"
fi

# Validate the requirements and run the script if successful
if python "$SCRIPT_DIR/setup/validate_requirements.py" -r "$REQUIREMENTS_FILE"; then
python "$SCRIPT_DIR/kohya_gui.py" "$@"
fi

0 comments on commit 5d51b7e

Please sign in to comment.