Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
olvidalo committed Nov 25, 2024
1 parent 03e2c73 commit a6d4793
Show file tree
Hide file tree
Showing 9 changed files with 1,891 additions and 1,782 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build for Windows

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}

steps:
- uses: actions/checkout@v4

- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-python
mingw-w64-x86_64-python-pip
mingw-w64-x86_64-libgphoto2
mingw-w64-x86_64-qt6-base
mingw-w64-x86_64-pkg-config
mingw-w64-x86_64-python-pip
mingw-w64-x86_64-python-pyqt6
mingw-w64-x86_64-python-pillow
mingw-w64-x86_64-pyinstaller
wget
p7zip
mingw-w64-x86_64-jq
- name: Set up Python environment
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Build
run: |
chmod +x build_win.sh
./build_win.sh
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
dist/main
35 changes: 35 additions & 0 deletions build_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -euo pipefail

# Get latest release info from GitHub API
LIBUSB_RELEASE_INFO=$(wget -qO- https://api.github.com/repos/libusb/libusb/releases/latest)

# Extract Windows release asset URL (only .7z file)
LIBUSB_WIN_URL=$(echo "$LIBUSB_RELEASE_INFO" | \
jq -r '.assets[] | select(.name | endswith(".7z")) | .browser_download_url')
LIBUSB_FILENAME=$(basename "$LIBUSB_WIN_URL")

# Create vendor directory if it doesn't exist
mkdir -p vendor/libusb

# Download and extract
cd vendor
if [ ! -f "$LIBUSB_FILENAME" ]; then
wget -N "$LIBUSB_WIN_URL"
else
echo $LIBUSB_FILENAME already exists, skipping download.
fi
7z x "$LIBUSB_FILENAME" -aos -olibusb

# Clean up downloaded archive
#rm libusb.7z

cd ..

pyinstaller --onedir \
--add-binary /mingw64/lib/libgphoto2_port/0.12.2/:. \
--add-binary /mingw64/lib/libgphoto2/2.5.31/:. \
--add-binary ./vendor/libusb/MinGW64/dll/libusb-1.0.dll:. \
--add-data ui:ui main.py \
--runtime-hook ./build_win_hook.py \
--noconfirm
7 changes: 7 additions & 0 deletions build_win_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
import sys
import logging

logging.info(f"Set IOLIBS and CAMLIBS to: #{sys._MEIPASS}")
os.environ["IOLIBS"] = sys._MEIPASS
os.environ["CAMLIBS"] = sys._MEIPASS
Loading

0 comments on commit a6d4793

Please sign in to comment.