From 42e189635bc63474e7436c210e30114b16c841ef Mon Sep 17 00:00:00 2001 From: Daniel Dybing Date: Tue, 13 Jan 2026 17:48:00 +0100 Subject: [PATCH] Configure Gitea Workflows and Add Build Scripts - Update build-linux.yaml to use standard Ubuntu runner. - Update build-windows.yaml to use tobix/pywine container for cross-compilation on Linux. - Add build_app.py and check_ttx6.py helper scripts. --- .gitea/workflows/build-linux.yaml | 9 +---- .gitea/workflows/build-windows.yaml | 19 ++++----- build_app.py | 60 +++++++++++++++++++++++++++++ check_ttx6.py | 28 ++++++++++++++ 4 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 build_app.py create mode 100644 check_ttx6.py diff --git a/.gitea/workflows/build-linux.yaml b/.gitea/workflows/build-linux.yaml index 09046a1..9649f4c 100644 --- a/.gitea/workflows/build-linux.yaml +++ b/.gitea/workflows/build-linux.yaml @@ -5,12 +5,7 @@ jobs: build: name: Build Linux runs-on: ubuntu-latest - container: - image: catthehacker/ubuntu:act-latest steps: - - name: Configure Git Redirect - run: git config --global url."http://192.168.50.24:3333/".insteadOf "http://server:3000/" - - name: Checkout uses: actions/checkout@v3 @@ -21,7 +16,7 @@ jobs: - name: Install Dependencies run: | - python --version + python -m pip install --upgrade pip pip install -r requirements.txt - name: Build Executable @@ -32,4 +27,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: TeletextEditor-Linux - path: dist/TeletextEditor_Linux + path: dist/TeletextEditor_Linux \ No newline at end of file diff --git a/.gitea/workflows/build-windows.yaml b/.gitea/workflows/build-windows.yaml index 17fbc1f..8ee56d7 100644 --- a/.gitea/workflows/build-windows.yaml +++ b/.gitea/workflows/build-windows.yaml @@ -4,29 +4,24 @@ on: [push, pull_request] jobs: build: name: Build Windows - runs-on: windows-latest + runs-on: ubuntu-latest + container: + image: tobix/pywine:3.10 steps: - - name: Configure Git Redirect - run: git config --global url."http://192.168.50.24:3000/".insteadOf "http://server:3000/" - - name: Checkout uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install Dependencies run: | - pip install -r requirements.txt + wine python -m pip install --upgrade pip + wine pip install -r requirements.txt - name: Build Executable run: | - pyinstaller --onefile --windowed --name TeletextEditor_Windows.exe --paths src src/main.py + wine pyinstaller --onefile --windowed --name TeletextEditor_Windows.exe --paths src src/main.py - name: Upload Artifact uses: actions/upload-artifact@v3 with: name: TeletextEditor-Windows - path: dist/TeletextEditor_Windows.exe + path: dist/TeletextEditor_Windows.exe \ No newline at end of file diff --git a/build_app.py b/build_app.py new file mode 100644 index 0000000..914b95c --- /dev/null +++ b/build_app.py @@ -0,0 +1,60 @@ +import sys +import os +import subprocess +import shutil +import platform + +def clean_build_dirs(): + """Removes build and dist directories if they exist.""" + for d in ["build", "dist"]: + if os.path.exists(d): + print(f"Cleaning {d}...") + shutil.rmtree(d) + + spec_file = "TeletextEditor_Linux.spec" if platform.system() == "Linux" else "TeletextEditor_Windows.spec" + if os.path.exists(spec_file): + os.remove(spec_file) + +def build(): + system = platform.system() + print(f"Detected OS: {system}") + + base_cmd = [ + sys.executable, "-m", "PyInstaller", + "--onefile", + "--windowed", + "--paths", "src", + "src/main.py" + ] + + if system == "Linux": + name = "TeletextEditor_Linux" + elif system == "Windows": + name = "TeletextEditor_Windows.exe" + else: + print(f"Unsupported platform: {system}") + return + + cmd = base_cmd + ["--name", name] + + print("Running build command:") + print(" ".join(cmd)) + + try: + subprocess.check_call(cmd) + print("\n" + "="*40) + print(f"Build successful! Executable is in 'dist/{name}'") + print("="*40) + except subprocess.CalledProcessError as e: + print(f"Build failed with error code {e.returncode}") + sys.exit(1) + + # Cross-compilation note + if system == "Linux": + print("\nNote: To build the Windows executable, please run this script on Windows.") + elif system == "Windows": + print("\nNote: To build the Linux executable, please run this script on Linux.") + +if __name__ == "__main__": + clean_build_dirs() + build() diff --git a/check_ttx6.py b/check_ttx6.py new file mode 100644 index 0000000..fefc66a --- /dev/null +++ b/check_ttx6.py @@ -0,0 +1,28 @@ + +import sys +import os + +# Add src to path +sys.path.append(os.path.join(os.getcwd(), 'src')) + +from teletext.io import load_t42 + +def check_file(filename): + if not os.path.exists(filename): + print(f"File {filename} not found") + return + + service = load_t42(filename) + print(f"Analysis of {filename}:") + print(f"Total packets: {len(service.all_packets)}") + print(f"Total pages: {len(service.pages)}") + + language_names = ["English", "German", "Swedish/Finnish", "Italian", "French", "Portuguese/Spanish", "Turkish", "Romania"] + + for i, page in enumerate(service.pages): + lang_idx = page.language + lang_name = language_names[lang_idx] if 0 <= lang_idx < len(language_names) else f"Unknown ({lang_idx})" + print(f"Page {i+1}: Mag {page.magazine} Num {page.page_number:02d}, Lang: {lang_idx} ({lang_name})") + +if __name__ == "__main__": + check_file("TTX-6_RAW.t42")