Skip to content

Commit c77a607

Browse files
committed
Testing using UPX on Ubuntu builds. Introduced saving of files to same directory, with reusable model directory.
1 parent 31d87b8 commit c77a607

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
matrix:
13-
os: [windows-latest] # [ubuntu-latest, macos-latest, windows-latest]
13+
os: [ubuntu-latest, macos-latest, windows-latest]
1414

1515
steps:
1616
- name: Checkout code
@@ -37,9 +37,11 @@ jobs:
3737
- name: Build for Linux
3838
if: matrix.os == 'ubuntu-latest'
3939
run: |
40+
sudo apt-get install -y upx
41+
4042
pyinstaller --onefile --name Scriptify --icon web/favicon.ico --add-data "ffmpeg/ffmpeg_ubuntu.zip:ffmpeg" --hidden-import="whisper" --add-data "whisper:whisper" --exclude-module tkinter --exclude-module PyQt5 \
4143
--add-data "web:web" --add-data "js:js" --add-data "index.html:." --add-data "launch.html:." --add-data "style.css:." \
42-
--windowed main.py --version-file version_info.txt
44+
--windowed main.py --version-file version_info.txt --upx-dir /usr/bin
4345
4446
strip dist/Scriptify
4547

main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@
3434
else:
3535
base_path = os.path.abspath(".")
3636

37+
# Determine the directory of the script or the executable
38+
if getattr(sys, 'frozen', False):
39+
app_dir = os.path.dirname(sys.executable)
40+
else:
41+
app_dir = os.path.dirname(os.path.abspath(__file__))
42+
3743
# Set whisper download folder
38-
os.environ["WHISPER_DOWNLOAD_DIR"] = os.path.join(base_path, "models")
39-
os.environ["WHISPER_CACHE_DIR"] = os.path.join(base_path, "models")
44+
os.environ["WHISPER_DOWNLOAD_DIR"] = os.path.join(app_dir, "models")
45+
os.environ["WHISPER_CACHE_DIR"] = os.path.join(app_dir, "models")
4046

4147
def extract_ffmpeg():
4248
"""Extracts the correct FFmpeg binary for the OS and returns its path."""
@@ -292,7 +298,7 @@ def auto_backup(self):
292298
# Format the date and time to fit in a filename
293299
filename_time = now.strftime("%Y-%m-%d_%H-%M-%S")
294300
backup_filename = f"{sanitized_title}_{filename_time}_backup.scriptify"
295-
backup_path = os.path.join(base_path, backup_filename)
301+
backup_path = os.path.join(app_dir, backup_filename)
296302

297303
# Prepare the data to be saved
298304
data = {

0 commit comments

Comments
 (0)