Skip to content

Commit

Permalink
onefile build with pyinstaller 6
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains committed Feb 24, 2024
1 parent 894d012 commit e6ed5b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
pip3 install pip-tools
python3 -m piptools compile -o requirements.txt pyproject.toml
pip3 install -r requirements.txt
pyinstaller --icon=updater.ico updater.py
pyinstaller --onefile --icon=updater.ico updater.py
- name: "Check if updater works correctly"
run: |
mkdir Release
mkdir -p Release/Updater
mv dist/updater/* Release/Updater/
mv dist/* Release/Updater/
mkdir -p Release/ImperatorToCK3
mv Release/Updater Release/Updater-running
cd Release/Updater-running
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
pip3 install -r requirements.txt
- name: "Create executable with pyinstaller"
run: |
pyinstaller --icon=updater.ico updater.py
pyinstaller --onefile --icon=updater.ico updater.py
- name: "Archive release"
uses: thedoctor0/zip-release@master
with:
Expand Down
16 changes: 7 additions & 9 deletions updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
import pathlib


# change working directory to script's location
# Change working directory to updater.exe's directory.
# The if below determines whether the app is a script file or frozen exe.
if getattr(sys, 'frozen', False):
# If the application is run as a bundle, the PyInstaller bootloader
# extends the sys module by a flag frozen=True and sets the app
# path into variable _MEIPASS
running_updater_path = sys._MEIPASS
else:
running_updater_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(running_updater_path)
running_updater_dir = os.path.dirname(sys.executable)
elif __file__:
running_updater_dir = os.path.dirname(__file__)
os.chdir(running_updater_dir)


# Logging configuration: log to file and console.
Expand Down Expand Up @@ -65,7 +63,7 @@ def clear_converter_folder():
for path in paths:
if os.path.isdir(path):
# remove directory
if os.path.samefile(path, running_updater_path):
if os.path.samefile(path, running_updater_dir):
# Don't remove running updater folder.
continue
shutil.rmtree(path, ignore_errors=True)
Expand Down

0 comments on commit e6ed5b0

Please sign in to comment.