Skip to content

Ci: build pyinstaller icons#28

Merged
duartebarbosadev merged 8 commits intomainfrom
ci/release-build-pyinstaller-icons
Sep 2, 2025
Merged

Ci: build pyinstaller icons#28
duartebarbosadev merged 8 commits intomainfrom
ci/release-build-pyinstaller-icons

Conversation

@duartebarbosadev
Copy link
Copy Markdown
Owner

This pull request introduces significant improvements to packaging, distribution, and model handling for native desktop builds, along with codebase-wide import refactoring for compatibility with PyInstaller and frozen bundles. It adds a comprehensive GitHub Actions workflow for building and releasing Windows and macOS binaries, improves resource and model bundling strategies, and enhances error handling for rotation model detection. Documentation is updated to reflect these changes and provide guidance for future development.

Packaging, Distribution, and CI Improvements

  • Added a new GitHub Actions workflow (.github/workflows/release-build.yml) to build, package, and release Windows and macOS desktop binaries using PyInstaller, including matrix builds, artifact uploads, icon generation, and SHA256 checksums.
  • Updated the developer guide (DEVELOPER_GUIDE.md) with a new section on packaging and distribution, detailing import strategies, resource/model bundling, logging, PyInstaller flags, CI build targets, and macOS codesigning notes.

Import Path Refactoring for PyInstaller Compatibility

  • Refactored all internal imports in core modules (e.g., src/core/caching/*, src/core/image_features/*, src/core/image_processing/*, src/core/metadata_processor.py) to use package-relative imports without the src. prefix, ensuring compatibility with both source and frozen PyInstaller builds. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Rotation Model Detection and Error Handling

  • Improved ONNX rotation model resolution logic to search multiple locations (PyInstaller extraction dir, project root, CWD), auto-select the newest available model, and raise a ModelNotFoundError if missing, allowing the UI to prompt users for model download. [1] [2] [3]
  • Updated rotation detection tasks and batch processing to propagate ModelNotFoundError so the UI can handle missing models gracefully and abort remaining tasks as needed. [1] [2]

Thread Safety for pyexiv2 Access

  • Added a global threading lock for pyexiv2 access in src/core/metadata_processor.py to prevent crashes or corruption in multi-threaded and frozen contexts.

- Updated import statements across multiple files to replace 'src.' with direct module paths for better clarity and maintainability.
- Introduced a global lock in `metadata_processor.py` to ensure thread safety during pyexiv2 operations.
- Enhanced metadata extraction logic to handle frozen builds and pytest environments more gracefully.
- Improved error handling and logging for metadata extraction processes.
- Added functionality to open logs and models folders directly from the UI.
- Refactored stylesheet loading logic in `main.py` to handle different execution contexts more robustly.
- Updated various UI components to ensure consistent import paths and improve code organization.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the import system to support PyInstaller packaging while adding comprehensive GitHub Actions workflows for building native desktop binaries. The changes ensure compatibility between source development and frozen distribution builds.

  • Migrates all internal imports from src. prefixed paths to package-relative imports
  • Adds GitHub Actions workflow for building Windows/macOS binaries with PyInstaller
  • Improves rotation model detection with better error handling for missing models
  • Enhances thread safety for pyexiv2 operations in multi-threaded contexts

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/conftest.py Adds pyexiv2 import guard and src directory to sys.path for test compatibility
src/ui/*.py Updates imports from src. prefix to package-relative imports
src/core/*.py Converts imports to package-relative format for PyInstaller compatibility
src/main.py Enhanced stylesheet loading and logging for frozen builds
.github/workflows/release-build.yml New CI workflow for building cross-platform desktop binaries
DEVELOPER_GUIDE.md Documents packaging strategies and PyInstaller considerations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


def process_chunk(chunk_paths: List[str]) -> List[Dict[str, Any]]:
chunk_results = []
single_file_mode = len(chunk_paths) == 1
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable single_file_mode is assigned but never used in the function. Consider removing this unused variable.

Suggested change
single_file_mode = len(chunk_paths) == 1

Copilot uses AI. Check for mistakes.
- name: Generate app icons (platform-specific)
shell: bash
run: |
python - <<'PY'
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The inline Python script for icon generation is quite long and complex. Consider extracting this to a separate script file (e.g., scripts/generate_icons.py) for better maintainability and readability.

Copilot uses AI. Check for mistakes.
Comment on lines +241 to +243
logger.error("No orientation model found; rotation detection disabled.")
self._state.failure_logged = True
return None
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent here. Line 242 should be at the same level as line 241 since both are part of the same conditional block.

Copilot uses AI. Check for mistakes.
@duartebarbosadev duartebarbosadev marked this pull request as ready for review September 2, 2025 22:04
@duartebarbosadev duartebarbosadev merged commit 15ece44 into main Sep 2, 2025
3 checks passed
@duartebarbosadev duartebarbosadev deleted the ci/release-build-pyinstaller-icons branch September 2, 2025 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants