From f53a9249f04a9367778a78a8d9385e44d305161d Mon Sep 17 00:00:00 2001 From: Theasacraft <91694323+Thesacraft@users.noreply.github.com> Date: Sun, 28 Apr 2024 01:51:09 +0200 Subject: [PATCH 1/7] Build script for windows Adds a build script for windows --- Build_win.bat | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Build_win.bat diff --git a/Build_win.bat b/Build_win.bat new file mode 100644 index 00000000..4b91a2f6 --- /dev/null +++ b/Build_win.bat @@ -0,0 +1,15 @@ +@echo off +echo Building windows executable... + + +set TAGSTUDIO_NAME=TagStudio +set TAGSTUDIO_DIR=tagstudio +set TAGSTUDIO_DIR_RESOURCES=%TAGSTUDIO_DIR%/resources +set TAGSTUDIO_ICON=%TAGSTUDIO_DIR%/resources/icon.ico +set TAGSTUDIO_SRC=%TAGSTUDIO_DIR%/src +set TAGSTUDIO_MAIN=%TAGSTUDIO_DIR%/tag_studio.py + +set COMMAND=PyInstaller --name "%TAGSTUDIO_NAME%" --icon "%TAGSTUDIO_ICON%" --add-data "%TAGSTUDIO_DIR_RESOURCES%:./resources" --add-data "%TAGSTUDIO_SRC%:./src" --distpath "%DIST_PATH%" -p "%TAGSTUDIO_DIR%" --console --onefile "%TAGSTUDIO_MAIN%" -y +call .venv\Scripts\activate.bat +%COMMAND% +deactivate \ No newline at end of file From 329c23e23c53e03bd3316f40c555130269f89de2 Mon Sep 17 00:00:00 2001 From: Theasacraft <91694323+Thesacraft@users.noreply.github.com> Date: Sun, 28 Apr 2024 01:54:17 +0200 Subject: [PATCH 2/7] Update requirements.txt to include pyinstaller Pyinstaller is used to build the windows executable --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 0456b920..7a144c43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ PySide6_Addons>=6.5.1.1,<=6.6.3.1 PySide6_Essentials>=6.5.1.1,<=6.6.3.1 typing_extensions>=3.10.0.0,<=4.11.0 ujson>=5.8.0,<=5.9.0 +Pyinstaller From 4f00a8ac88b97ce0e4a9e79e04041b7b3ce7b89e Mon Sep 17 00:00:00 2001 From: Theasacraft <91694323+Thesacraft@users.noreply.github.com> Date: Sun, 28 Apr 2024 01:56:13 +0200 Subject: [PATCH 3/7] Update .gitignore to ignore build specific files and folders --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 0a5d8271..2aab2c25 100644 --- a/.gitignore +++ b/.gitignore @@ -251,4 +251,9 @@ compile_commands.json .TagStudio TagStudio.ini +build +dist +TagStudio.spec + + # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,qt From 9959eb1049ee63674ff6422a7bb0c21d61721237 Mon Sep 17 00:00:00 2001 From: Theasacraft <91694323+Thesacraft@users.noreply.github.com> Date: Sun, 28 Apr 2024 02:00:17 +0200 Subject: [PATCH 4/7] Update .gitignore to revert doubled entrys --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2aab2c25..8c0029f0 100644 --- a/.gitignore +++ b/.gitignore @@ -251,9 +251,7 @@ compile_commands.json .TagStudio TagStudio.ini -build -dist -TagStudio.spec + # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python,qt From 049582487861787a7427ba80d3626ca1db8eddfc Mon Sep 17 00:00:00 2001 From: Theasacraft <91694323+Thesacraft@users.noreply.github.com> Date: Sun, 28 Apr 2024 04:54:02 +0200 Subject: [PATCH 5/7] Update requirements.txt to use last tested pyinstaller version Thanks to @williamtcastro for pointing it out --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7a144c43..7c1b4c35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ PySide6_Addons>=6.5.1.1,<=6.6.3.1 PySide6_Essentials>=6.5.1.1,<=6.6.3.1 typing_extensions>=3.10.0.0,<=4.11.0 ujson>=5.8.0,<=5.9.0 -Pyinstaller +Pyinstaller==6.6.0 From 260583cfeb07a08a605baa5d8fa1c5dcd4559dd3 Mon Sep 17 00:00:00 2001 From: Theasacraft <91694323+Thesacraft@users.noreply.github.com> Date: Sun, 28 Apr 2024 21:52:16 +0200 Subject: [PATCH 6/7] Update Build_win.bat for faster start of executable I changed it to output an executable and a _internals dir because this makes it, atleast from my experience, much faster (12s -> 1-2s). This is probably because the decompression that has to happen before startup if its in one file --- Build_win.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Build_win.bat b/Build_win.bat index 4b91a2f6..2d2ec782 100644 --- a/Build_win.bat +++ b/Build_win.bat @@ -9,7 +9,7 @@ set TAGSTUDIO_ICON=%TAGSTUDIO_DIR%/resources/icon.ico set TAGSTUDIO_SRC=%TAGSTUDIO_DIR%/src set TAGSTUDIO_MAIN=%TAGSTUDIO_DIR%/tag_studio.py -set COMMAND=PyInstaller --name "%TAGSTUDIO_NAME%" --icon "%TAGSTUDIO_ICON%" --add-data "%TAGSTUDIO_DIR_RESOURCES%:./resources" --add-data "%TAGSTUDIO_SRC%:./src" --distpath "%DIST_PATH%" -p "%TAGSTUDIO_DIR%" --console --onefile "%TAGSTUDIO_MAIN%" -y +set COMMAND=PyInstaller --name "%TAGSTUDIO_NAME%" --icon "%TAGSTUDIO_ICON%" --add-data "%TAGSTUDIO_DIR_RESOURCES%:./resources" --add-data "%TAGSTUDIO_SRC%:./src" --distpath "%DIST_PATH%" -p "%TAGSTUDIO_DIR%" --console --onedir "%TAGSTUDIO_MAIN%" -y call .venv\Scripts\activate.bat %COMMAND% -deactivate \ No newline at end of file +deactivate From 44106e2c59fa697d36435173560d48859a76f8e6 Mon Sep 17 00:00:00 2001 From: Theasacraft <91694323+Thesacraft@users.noreply.github.com> Date: Mon, 29 Apr 2024 00:13:48 +0200 Subject: [PATCH 7/7] Updates Build_win.bat to not delete source and be able to build portable version --- Build_win.bat | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Build_win.bat b/Build_win.bat index 2d2ec782..3e99fdcf 100644 --- a/Build_win.bat +++ b/Build_win.bat @@ -1,15 +1,31 @@ @echo off -echo Building windows executable... - - set TAGSTUDIO_NAME=TagStudio set TAGSTUDIO_DIR=tagstudio set TAGSTUDIO_DIR_RESOURCES=%TAGSTUDIO_DIR%/resources set TAGSTUDIO_ICON=%TAGSTUDIO_DIR%/resources/icon.ico set TAGSTUDIO_SRC=%TAGSTUDIO_DIR%/src set TAGSTUDIO_MAIN=%TAGSTUDIO_DIR%/tag_studio.py +set BUILD_MODE=--onedir -set COMMAND=PyInstaller --name "%TAGSTUDIO_NAME%" --icon "%TAGSTUDIO_ICON%" --add-data "%TAGSTUDIO_DIR_RESOURCES%:./resources" --add-data "%TAGSTUDIO_SRC%:./src" --distpath "%DIST_PATH%" -p "%TAGSTUDIO_DIR%" --console --onedir "%TAGSTUDIO_MAIN%" -y + +if "%1" == "--help" ( + echo run "%~nx0" for normal Build + echo run "%~nx0 --portable" for Build packaged into one file + goto end +) +if "%1" == "--portable" ( + echo Building portable executable... + set BUILD_MODE=--onefile + goto run +) +if not "%1" == "" ( + echo Invalid argument run "%~nx0 --help" for help + goto end +) +:run +echo Building executable... +set COMMAND=PyInstaller --name "%TAGSTUDIO_NAME%" --icon "%TAGSTUDIO_ICON%" --add-data "%TAGSTUDIO_DIR_RESOURCES%:./resources" --add-data "%TAGSTUDIO_SRC%:./src" -p "%TAGSTUDIO_DIR%" --console %BUILD_MODE% "%TAGSTUDIO_MAIN%" -y call .venv\Scripts\activate.bat %COMMAND% deactivate +:end