From 49bc204d6688f4bafaeced3052525e2cfe6d04bc Mon Sep 17 00:00:00 2001 From: biast12 Date: Sat, 16 Nov 2024 00:56:51 +0100 Subject: [PATCH] Linux: Add dev scripts --- build.sh | 36 ++++++++++++++++++++++++++++++++++++ setup_env.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100755 build.sh create mode 100755 setup_env.sh diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..0da230b1 --- /dev/null +++ b/build.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +dirpath=$(dirname "$(readlink -f "$0")") + +# Check if the virtual environment exists +if [ ! -d "$dirpath/env" ]; then + echo + echo "No virtual environment found! Run setup_env.sh to set it up first." + echo + read -p "Press any key to continue..." + exit 1 +fi + +# Check if pyinstaller is installed in the virtual environment +if [ ! -f "$dirpath/env/bin/pyinstaller" ]; then + echo + echo "Installing pyinstaller..." + "$dirpath/env/bin/pip" install pyinstaller + if [ $? -ne 0 ]; then + echo "Failed to install pyinstaller." + exit 1 + fi +fi + +# Run pyinstaller with the specified build spec file +echo +echo "Running pyinstaller..." +"$dirpath/env/bin/pyinstaller" "$dirpath/build.spec" +if [ $? -ne 0 ]; then + echo "PyInstaller build failed." + exit 1 +fi + +echo +echo "Build completed successfully." +read -p "Press any key to continue..." \ No newline at end of file diff --git a/setup_env.sh b/setup_env.sh new file mode 100755 index 00000000..5b0f7f3b --- /dev/null +++ b/setup_env.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +dirpath=$(dirname "$(readlink -f "$0")") + +# Check if git is installed +if ! command -v git &> /dev/null; then + echo "No git executable found in PATH!" + echo + read -p "Press any key to continue..." + exit 1 +fi + +# Check if the virtual environment exists +if [ ! -d "$dirpath/env" ]; then + echo + echo "Creating the env folder..." + python3 -m venv "$dirpath/env" + if [ $? -ne 0 ]; then + echo + echo "No python executable found in PATH or failed to create virtual environment!" + echo + read -p "Press any key to continue..." + exit 1 + fi +fi + +# Activate the virtual environment and install requirements +echo +echo "Installing requirements.txt..." +"$dirpath/env/bin/python" -m pip install -U pip +if [ $? -ne 0 ]; then + echo "Failed to upgrade pip." + exit 1 +fi + +"$dirpath/env/bin/pip" install wheel +if [ $? -ne 0 ]; then + echo "Failed to install wheel." + exit 1 +fi + +"$dirpath/env/bin/pip" install -r "$dirpath/requirements.txt" +if [ $? -ne 0 ]; then + echo "Failed to install requirements." + exit 1 +fi + +echo +echo "All done!" +echo +read -p "Press any key to continue..." \ No newline at end of file