From 4f4ae26d2fe393de1e1b9bd5eac14ec4c4bb37ac Mon Sep 17 00:00:00 2001 From: biast12 Date: Sat, 16 Nov 2024 00:56:10 +0100 Subject: [PATCH 1/5] Windows: General improvements to dev scripts --- build.bat | 29 ++++++++++++++++++++++++----- setup_env.bat | 33 ++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/build.bat b/build.bat index 0fd6a093..fa888ddc 100644 --- a/build.bat +++ b/build.bat @@ -1,18 +1,37 @@ @echo off -cls -set dirpath=%~dp0 -if "%dirpath:~-1%" == "\" set dirpath=%dirpath:~0,-1% +REM Get the directory path of the script +set "dirpath=%~dp0" +if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" + +REM Check if the virtual environment exists if not exist "%dirpath%\env" ( echo: echo No virtual environment found! Run setup_env.bat to set it up first. echo: pause - exit + exit /b ) +REM Check if pyinstaller and pywin32 is installed in the virtual environment if not exist "%dirpath%\env\scripts\pyinstaller.exe" ( "%dirpath%\env\scripts\pip" install pyinstaller + if errorlevel 1 ( + echo Failed to install pyinstaller. + exit /b 1 + ) "%dirpath%\env\scripts\python" "%dirpath%\env\scripts\pywin32_postinstall.py" -install -silent + if errorlevel 1 ( + echo Failed to run pywin32_postinstall.py. + exit /b 1 + ) +) + +REM Run pyinstaller with the specified build spec file +"%dirpath%\env\scripts\pyinstaller" "%dirpath%\build.spec" +if errorlevel 1 ( + echo PyInstaller build failed. + exit /b 1 ) -"%dirpath%/env/scripts/pyinstaller" "%dirpath%\build.spec" + +echo Build completed successfully. \ No newline at end of file diff --git a/setup_env.bat b/setup_env.bat index 4ec1bf78..ee1abced 100644 --- a/setup_env.bat +++ b/setup_env.bat @@ -1,35 +1,54 @@ @echo off -cls -set dirpath=%~dp0 -if "%dirpath:~-1%" == "\" set dirpath=%dirpath:~0,-1% -git --version > nul +REM Get the directory path of the script +set "dirpath=%~dp0" +if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" + +REM Check if git is installed +git --version > nul 2>&1 if %errorlevel% NEQ 0 ( echo No git executable found in PATH! echo: pause - exit + exit /b 1 ) +REM Create the virtual environment if it doesn't exist if not exist "%dirpath%\env" ( echo: echo Creating the env folder... python -m venv "%dirpath%\env" if %errorlevel% NEQ 0 ( echo: - echo No python executable found in PATH! + echo No python executable found in PATH or failed to create virtual environment! echo: pause + exit /b 1 ) ) +REM Activate the virtual environment and install requirements echo: echo Installing requirements.txt... "%dirpath%\env\scripts\python" -m pip install -U pip +if %errorlevel% NEQ 0 ( + echo Failed to upgrade pip. + exit /b 1 +) + "%dirpath%\env\scripts\pip" install wheel +if %errorlevel% NEQ 0 ( + echo Failed to install wheel. + exit /b 1 +) + "%dirpath%\env\scripts\pip" install -r "%dirpath%\requirements.txt" +if %errorlevel% NEQ 0 ( + echo Failed to install requirements. + exit /b 1 +) echo: echo All done! echo: -pause +pause \ No newline at end of file From 49149964072dd7aca51c53c06fc1bb1cdbd58a44 Mon Sep 17 00:00:00 2001 From: biast12 Date: Sat, 16 Nov 2024 00:56:39 +0100 Subject: [PATCH 2/5] Linux: Move to Ayatana's AppIndicator The reference AppIndicator implementation has been deprecated/abandoned in newer distros. Co-Authored-By: Guilherme Silva <626206+guihkx@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- appimage/AppImageBuilder.yml | 2 +- build.spec | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 075600af..c4edd48f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,7 +130,7 @@ jobs: - name: Install system dependencies run: | sudo apt update - sudo apt install gir1.2-appindicator3-0.1 libgirepository1.0-dev python3-tk + sudo apt install libgirepository1.0-dev gir1.2-ayatanaappindicator3-0.1 libayatana-appindicator3-1 python3-tk - name: Install project dependencies run: | @@ -198,7 +198,7 @@ jobs: - name: Install system dependencies run: | sudo apt update - sudo apt install libgirepository1.0-dev python3-testresources + sudo apt install libgirepository1.0-dev gir1.2-ayatanaappindicator3-0.1 libayatana-appindicator3-1 python3-testresources - name: Download AppImage Builder run: | diff --git a/appimage/AppImageBuilder.yml b/appimage/AppImageBuilder.yml index 21bf1d63..8643207f 100644 --- a/appimage/AppImageBuilder.yml +++ b/appimage/AppImageBuilder.yml @@ -48,7 +48,7 @@ AppDir: key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x871920D1991BC93C include: - - gir1.2-appindicator3-0.1 + - gir1.2-ayatanaappindicator3-0.1 - python3-tk exclude: diff --git a/build.spec b/build.spec index 3b54c24f..81ab86a2 100644 --- a/build.spec +++ b/build.spec @@ -4,6 +4,7 @@ from __future__ import annotations import sys from pathlib import Path from typing import Any, TYPE_CHECKING +import platform SELF_PATH = str(Path(".").resolve()) if SELF_PATH not in sys.path: @@ -31,7 +32,7 @@ for lang_filepath in WORKING_DIR.joinpath("lang").glob("*.json"): if lang_filepath.stem != DEFAULT_LANG: to_add.append((lang_filepath, "lang", True)) -# ensure the required to-be-added data exists +# Ensure the required to-be-added data exists datas: list[tuple[Path, str]] = [] for source_path, dest_path, required in to_add: if source_path.exists(): @@ -51,8 +52,10 @@ hiddenimports: list[str] = [ if sys.platform == "linux": # Needed files for better system tray support on Linux via pystray (AppIndicator backend). - datas.append((Path("/usr/lib/girepository-1.0/AppIndicator3-0.1.typelib"), "gi_typelibs")) - binaries.append((Path("/lib/x86_64-linux-gnu/libappindicator3.so.1"), ".")) + arch = platform.machine() + datas.append((Path(f"/usr/lib/{arch}-linux-gnu/girepository-1.0/AyatanaAppIndicator3-0.1.typelib"), "gi_typelibs")) + binaries.append((Path(f"/usr/lib/{arch}-linux-gnu/libayatana-appindicator3.so.1"), ".")) + hiddenimports.extend([ "gi.repository.Gtk", "gi.repository.GObject", From 49bc204d6688f4bafaeced3052525e2cfe6d04bc Mon Sep 17 00:00:00 2001 From: biast12 Date: Sat, 16 Nov 2024 00:56:51 +0100 Subject: [PATCH 3/5] 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 From 510814ebfda16e50c15a80bdcd2b3259465ecd66 Mon Sep 17 00:00:00 2001 From: biast12 <53872542+biast12@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:31:36 +0100 Subject: [PATCH 4/5] Fix reviews --- build.bat | 74 ++++++++-------- build.sh | 2 +- build.spec | 234 +++++++++++++++++++++++++------------------------- setup_env.bat | 100 ++++++++++----------- setup_env.sh | 10 +-- 5 files changed, 202 insertions(+), 218 deletions(-) mode change 100644 => 100755 build.bat mode change 100644 => 100755 build.spec mode change 100644 => 100755 setup_env.bat diff --git a/build.bat b/build.bat old mode 100644 new mode 100755 index fa888ddc..78c830c9 --- a/build.bat +++ b/build.bat @@ -1,37 +1,37 @@ -@echo off - -REM Get the directory path of the script -set "dirpath=%~dp0" -if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" - -REM Check if the virtual environment exists -if not exist "%dirpath%\env" ( - echo: - echo No virtual environment found! Run setup_env.bat to set it up first. - echo: - pause - exit /b -) - -REM Check if pyinstaller and pywin32 is installed in the virtual environment -if not exist "%dirpath%\env\scripts\pyinstaller.exe" ( - "%dirpath%\env\scripts\pip" install pyinstaller - if errorlevel 1 ( - echo Failed to install pyinstaller. - exit /b 1 - ) - "%dirpath%\env\scripts\python" "%dirpath%\env\scripts\pywin32_postinstall.py" -install -silent - if errorlevel 1 ( - echo Failed to run pywin32_postinstall.py. - exit /b 1 - ) -) - -REM Run pyinstaller with the specified build spec file -"%dirpath%\env\scripts\pyinstaller" "%dirpath%\build.spec" -if errorlevel 1 ( - echo PyInstaller build failed. - exit /b 1 -) - -echo Build completed successfully. \ No newline at end of file +@echo off + +REM Get the directory path of the script +set "dirpath=%~dp0" +if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" + +REM Check if the virtual environment exists +if not exist "%dirpath%\env" ( + echo: + echo No virtual environment found! Run setup_env.bat to set it up first. + echo: + pause + exit /b 1 +) + +REM Check if pyinstaller and pywin32 is installed in the virtual environment +if not exist "%dirpath%\env\scripts\pyinstaller.exe" ( + "%dirpath%\env\scripts\pip" install pyinstaller + if errorlevel 1 ( + echo Failed to install pyinstaller. + exit /b 1 + ) + "%dirpath%\env\scripts\python" "%dirpath%\env\scripts\pywin32_postinstall.py" -install -silent + if errorlevel 1 ( + echo Failed to run pywin32_postinstall.py. + exit /b 1 + ) +) + +REM Run pyinstaller with the specified build spec file +"%dirpath%\env\scripts\pyinstaller" "%dirpath%\build.spec" +if errorlevel 1 ( + echo PyInstaller build failed. + exit /b 1 +) + +echo Build completed successfully. diff --git a/build.sh b/build.sh index 0da230b1..8648ff46 100755 --- a/build.sh +++ b/build.sh @@ -33,4 +33,4 @@ fi echo echo "Build completed successfully." -read -p "Press any key to continue..." \ No newline at end of file +read -p "Press any key to continue..." diff --git a/build.spec b/build.spec old mode 100644 new mode 100755 index 81ab86a2..270b3e67 --- a/build.spec +++ b/build.spec @@ -1,117 +1,117 @@ -# -*- mode: python ; coding: utf-8 -*- -from __future__ import annotations - -import sys -from pathlib import Path -from typing import Any, TYPE_CHECKING -import platform - -SELF_PATH = str(Path(".").resolve()) -if SELF_PATH not in sys.path: - sys.path.insert(0, SELF_PATH) - -from constants import WORKING_DIR, SITE_PACKAGES_PATH, DEFAULT_LANG - -if TYPE_CHECKING: - from PyInstaller.building.api import PYZ, EXE - from PyInstaller.building.build_main import Analysis - -# (source_path, dest_path, required) -to_add: list[tuple[Path, str, bool]] = [ - # icon files - (Path("icons/pickaxe.ico"), "./icons", True), - (Path("icons/active.ico"), "./icons", True), - (Path("icons/idle.ico"), "./icons", True), - (Path("icons/error.ico"), "./icons", True), - (Path("icons/maint.ico"), "./icons", True), - # SeleniumWire HTTPS/SSL cert file and key - (Path(SITE_PACKAGES_PATH, "seleniumwire/ca.crt"), "./seleniumwire", False), - (Path(SITE_PACKAGES_PATH, "seleniumwire/ca.key"), "./seleniumwire", False), -] -for lang_filepath in WORKING_DIR.joinpath("lang").glob("*.json"): - if lang_filepath.stem != DEFAULT_LANG: - to_add.append((lang_filepath, "lang", True)) - -# Ensure the required to-be-added data exists -datas: list[tuple[Path, str]] = [] -for source_path, dest_path, required in to_add: - if source_path.exists(): - datas.append((source_path, dest_path)) - elif required: - raise FileNotFoundError(str(source_path)) - -hooksconfig: dict[str, Any] = {} -binaries: list[tuple[Path, str]] = [] -hiddenimports: list[str] = [ - "PIL._tkinter_finder", - "setuptools._distutils.log", - "setuptools._distutils.dir_util", - "setuptools._distutils.file_util", - "setuptools._distutils.archive_util", -] - -if sys.platform == "linux": - # Needed files for better system tray support on Linux via pystray (AppIndicator backend). - arch = platform.machine() - datas.append((Path(f"/usr/lib/{arch}-linux-gnu/girepository-1.0/AyatanaAppIndicator3-0.1.typelib"), "gi_typelibs")) - binaries.append((Path(f"/usr/lib/{arch}-linux-gnu/libayatana-appindicator3.so.1"), ".")) - - hiddenimports.extend([ - "gi.repository.Gtk", - "gi.repository.GObject", - ]) - hooksconfig = { - "gi": { - "icons": [], - "themes": [], - "languages": ["en_US"] - } - } - -block_cipher = None -a = Analysis( - ["main.py"], - pathex=[], - datas=datas, - excludes=[], - hookspath=[], - noarchive=False, - runtime_hooks=[], - binaries=binaries, - cipher=block_cipher, - hooksconfig=hooksconfig, - hiddenimports=hiddenimports, - win_private_assemblies=False, - win_no_prefer_redirects=False, -) - -# Exclude unneeded Linux libraries -excluded_binaries = [ - "libicudata.so.66", - "libicuuc.so.66", - "librsvg-2.so.2" -] -a.binaries = [b for b in a.binaries if b[0] not in excluded_binaries] - -pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - [], - upx=True, - debug=False, - strip=False, - console=False, - upx_exclude=[], - target_arch=None, - runtime_tmpdir=None, - codesign_identity=None, - entitlements_file=None, - icon="icons/pickaxe.ico", - bootloader_ignore_signals=False, - disable_windowed_traceback=False, - name="Twitch Drops Miner (by DevilXD)", -) +# -*- mode: python ; coding: utf-8 -*- +from __future__ import annotations + +import sys +import platform +from pathlib import Path +from typing import Any, TYPE_CHECKING + +SELF_PATH = str(Path(".").resolve()) +if SELF_PATH not in sys.path: + sys.path.insert(0, SELF_PATH) + +from constants import WORKING_DIR, SITE_PACKAGES_PATH, DEFAULT_LANG + +if TYPE_CHECKING: + from PyInstaller.building.api import PYZ, EXE + from PyInstaller.building.build_main import Analysis + +# (source_path, dest_path, required) +to_add: list[tuple[Path, str, bool]] = [ + # icon files + (Path("icons/pickaxe.ico"), "./icons", True), + (Path("icons/active.ico"), "./icons", True), + (Path("icons/idle.ico"), "./icons", True), + (Path("icons/error.ico"), "./icons", True), + (Path("icons/maint.ico"), "./icons", True), + # SeleniumWire HTTPS/SSL cert file and key + (Path(SITE_PACKAGES_PATH, "seleniumwire/ca.crt"), "./seleniumwire", False), + (Path(SITE_PACKAGES_PATH, "seleniumwire/ca.key"), "./seleniumwire", False), +] +for lang_filepath in WORKING_DIR.joinpath("lang").glob("*.json"): + if lang_filepath.stem != DEFAULT_LANG: + to_add.append((lang_filepath, "lang", True)) + +# Ensure the required to-be-added data exists +datas: list[tuple[Path, str]] = [] +for source_path, dest_path, required in to_add: + if source_path.exists(): + datas.append((source_path, dest_path)) + elif required: + raise FileNotFoundError(str(source_path)) + +hooksconfig: dict[str, Any] = {} +binaries: list[tuple[Path, str]] = [] +hiddenimports: list[str] = [ + "PIL._tkinter_finder", + "setuptools._distutils.log", + "setuptools._distutils.dir_util", + "setuptools._distutils.file_util", + "setuptools._distutils.archive_util", +] + +if sys.platform == "linux": + # Needed files for better system tray support on Linux via pystray (AppIndicator backend). + arch = platform.machine() + datas.append((Path(f"/usr/lib/{arch}-linux-gnu/girepository-1.0/AyatanaAppIndicator3-0.1.typelib"), "gi_typelibs")) + binaries.append((Path(f"/usr/lib/{arch}-linux-gnu/libayatana-appindicator3.so.1"), ".")) + + hiddenimports.extend([ + "gi.repository.Gtk", + "gi.repository.GObject", + ]) + hooksconfig = { + "gi": { + "icons": [], + "themes": [], + "languages": ["en_US"] + } + } + +block_cipher = None +a = Analysis( + ["main.py"], + pathex=[], + datas=datas, + excludes=[], + hookspath=[], + noarchive=False, + runtime_hooks=[], + binaries=binaries, + cipher=block_cipher, + hooksconfig=hooksconfig, + hiddenimports=hiddenimports, + win_private_assemblies=False, + win_no_prefer_redirects=False, +) + +# Exclude unneeded Linux libraries +excluded_binaries = [ + "libicudata.so.66", + "libicuuc.so.66", + "librsvg-2.so.2" +] +a.binaries = [b for b in a.binaries if b[0] not in excluded_binaries] + +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + upx=True, + debug=False, + strip=False, + console=False, + upx_exclude=[], + target_arch=None, + runtime_tmpdir=None, + codesign_identity=None, + entitlements_file=None, + icon="icons/pickaxe.ico", + bootloader_ignore_signals=False, + disable_windowed_traceback=False, + name="Twitch Drops Miner (by DevilXD)", +) diff --git a/setup_env.bat b/setup_env.bat old mode 100644 new mode 100755 index ee1abced..adeadc55 --- a/setup_env.bat +++ b/setup_env.bat @@ -1,54 +1,46 @@ -@echo off - -REM Get the directory path of the script -set "dirpath=%~dp0" -if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" - -REM Check if git is installed -git --version > nul 2>&1 -if %errorlevel% NEQ 0 ( - echo No git executable found in PATH! - echo: - pause - exit /b 1 -) - -REM Create the virtual environment if it doesn't exist -if not exist "%dirpath%\env" ( - echo: - echo Creating the env folder... - python -m venv "%dirpath%\env" - if %errorlevel% NEQ 0 ( - echo: - echo No python executable found in PATH or failed to create virtual environment! - echo: - pause - exit /b 1 - ) -) - -REM Activate the virtual environment and install requirements -echo: -echo Installing requirements.txt... -"%dirpath%\env\scripts\python" -m pip install -U pip -if %errorlevel% NEQ 0 ( - echo Failed to upgrade pip. - exit /b 1 -) - -"%dirpath%\env\scripts\pip" install wheel -if %errorlevel% NEQ 0 ( - echo Failed to install wheel. - exit /b 1 -) - -"%dirpath%\env\scripts\pip" install -r "%dirpath%\requirements.txt" -if %errorlevel% NEQ 0 ( - echo Failed to install requirements. - exit /b 1 -) - -echo: -echo All done! -echo: -pause \ No newline at end of file +@echo off + +REM Get the directory path of the script +set "dirpath=%~dp0" +if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" + +REM Check if git is installed +git --version > nul 2>&1 +if %errorlevel% NEQ 0 ( + echo No git executable found in PATH! + echo: + pause + exit /b 1 +) + +REM Create the virtual environment if it doesn't exist +if not exist "%dirpath%\env" ( + echo: + echo Creating the env folder... + python -m venv "%dirpath%\env" + if %errorlevel% NEQ 0 ( + echo: + echo No python executable found in PATH or failed to create virtual environment! + echo: + pause + exit /b 1 + ) +) + +REM Activate the virtual environment and install requirements +echo: +echo Installing requirements.txt... +"%dirpath%\env\scripts\python" -m pip install -U pip + +"%dirpath%\env\scripts\pip" install wheel + +"%dirpath%\env\scripts\pip" install -r "%dirpath%\requirements.txt" +if %errorlevel% NEQ 0 ( + echo Failed to install requirements. + exit /b 1 +) + +echo: +echo All done! +echo: +pause diff --git a/setup_env.sh b/setup_env.sh index 5b0f7f3b..984bf161 100755 --- a/setup_env.sh +++ b/setup_env.sh @@ -28,16 +28,8 @@ fi 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 @@ -48,4 +40,4 @@ fi echo echo "All done!" echo -read -p "Press any key to continue..." \ No newline at end of file +read -p "Press any key to continue..." From 3f7ceabac4ea30584334bbe79fd01663d25ba2c1 Mon Sep 17 00:00:00 2001 From: biast12 <53872542+biast12@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:01:15 +0100 Subject: [PATCH 5/5] Fix reviews --- build.bat | 20 +++++++++++++++++--- build.sh | 17 ++++++++++++----- setup_env.bat | 8 +++++--- setup_env.sh | 8 +++++--- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/build.bat b/build.bat index 78c830c9..00fc0467 100755 --- a/build.bat +++ b/build.bat @@ -13,25 +13,39 @@ if not exist "%dirpath%\env" ( exit /b 1 ) -REM Check if pyinstaller and pywin32 is installed in the virtual environment +REM Check if PyInstaller and pywin32 is installed in the virtual environment if not exist "%dirpath%\env\scripts\pyinstaller.exe" ( + echo Installing PyInstaller... "%dirpath%\env\scripts\pip" install pyinstaller if errorlevel 1 ( - echo Failed to install pyinstaller. + echo: + echo Failed to install PyInstaller. + echo: + pause exit /b 1 ) "%dirpath%\env\scripts\python" "%dirpath%\env\scripts\pywin32_postinstall.py" -install -silent if errorlevel 1 ( + echo: echo Failed to run pywin32_postinstall.py. + echo: + pause exit /b 1 ) ) -REM Run pyinstaller with the specified build spec file +REM Run PyInstaller with the specified build spec file +echo Building... "%dirpath%\env\scripts\pyinstaller" "%dirpath%\build.spec" if errorlevel 1 ( + echo: echo PyInstaller build failed. + echo: + pause exit /b 1 ) +echo: echo Build completed successfully. +echo: +pause diff --git a/build.sh b/build.sh index 8648ff46..d3c2dc0c 100755 --- a/build.sh +++ b/build.sh @@ -11,26 +11,33 @@ if [ ! -d "$dirpath/env" ]; then exit 1 fi -# Check if pyinstaller is installed in the virtual environment +# Check if PyInstaller is installed in the virtual environment if [ ! -f "$dirpath/env/bin/pyinstaller" ]; then echo - echo "Installing pyinstaller..." + echo "Installing PyInstaller..." "$dirpath/env/bin/pip" install pyinstaller if [ $? -ne 0 ]; then - echo "Failed to install pyinstaller." + echo + echo "Failed to install PyInstaller." + echo + read -p "Press any key to continue..." exit 1 fi fi -# Run pyinstaller with the specified build spec file +# Run PyInstaller with the specified build spec file echo -echo "Running pyinstaller..." +echo "Running PyInstaller..." "$dirpath/env/bin/pyinstaller" "$dirpath/build.spec" if [ $? -ne 0 ]; then + echo echo "PyInstaller build failed." + echo + read -p "Press any key to continue..." exit 1 fi echo echo "Build completed successfully." +echo read -p "Press any key to continue..." diff --git a/setup_env.bat b/setup_env.bat index adeadc55..86783e70 100755 --- a/setup_env.bat +++ b/setup_env.bat @@ -7,6 +7,7 @@ if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" REM Check if git is installed git --version > nul 2>&1 if %errorlevel% NEQ 0 ( + echo: echo No git executable found in PATH! echo: pause @@ -31,16 +32,17 @@ REM Activate the virtual environment and install requirements echo: echo Installing requirements.txt... "%dirpath%\env\scripts\python" -m pip install -U pip - "%dirpath%\env\scripts\pip" install wheel - "%dirpath%\env\scripts\pip" install -r "%dirpath%\requirements.txt" if %errorlevel% NEQ 0 ( + echo: echo Failed to install requirements. + echo: + pause exit /b 1 ) echo: -echo All done! +echo Environment setup completed successfully. echo: pause diff --git a/setup_env.sh b/setup_env.sh index 984bf161..44f8a68d 100755 --- a/setup_env.sh +++ b/setup_env.sh @@ -4,6 +4,7 @@ dirpath=$(dirname "$(readlink -f "$0")") # Check if git is installed if ! command -v git &> /dev/null; then + echo echo "No git executable found in PATH!" echo read -p "Press any key to continue..." @@ -28,16 +29,17 @@ fi echo echo "Installing requirements.txt..." "$dirpath/env/bin/python" -m pip install -U pip - "$dirpath/env/bin/pip" install wheel - "$dirpath/env/bin/pip" install -r "$dirpath/requirements.txt" if [ $? -ne 0 ]; then + echo echo "Failed to install requirements." + echo + read -p "Press any key to continue..." exit 1 fi echo -echo "All done!" +echo "Environment setup completed successfully." echo read -p "Press any key to continue..."