Skip to content

Commit 15de09e

Browse files
Fix build failures for Windows and macOS
Windows fix: - Add UTF-8 console encoding configuration - Use ASCII fallbacks for Unicode symbols (✓, ✗, ⚠) - Fixes UnicodeEncodeError on Windows cp1252 console macOS fix: - Make icon files optional in hexglitcher.spec - Check if icon.ico and icon.icns exist before using - Fixes FileNotFoundError when icons are missing Both platforms can now build without icon files present. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 22381d2 commit 15de09e

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

build.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
import platform
1212
from pathlib import Path
1313

14+
# Fix Windows console encoding for Unicode characters
15+
if sys.platform == 'win32':
16+
try:
17+
# Try to set UTF-8 encoding for Windows console
18+
sys.stdout.reconfigure(encoding='utf-8')
19+
except AttributeError:
20+
# Python < 3.7 fallback
21+
import codecs
22+
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer, 'strict')
23+
1424
# Colors for terminal output
1525
class Colors:
1626
HEADER = '\033[95m'
@@ -28,15 +38,21 @@ def print_step(message):
2838

2939
def print_success(message):
3040
"""Print a success message."""
31-
print(f"{Colors.OKGREEN}{message}{Colors.ENDC}")
41+
# Use ASCII checkmark on Windows if Unicode fails
42+
checkmark = "√" if sys.platform != 'win32' else "[OK]"
43+
print(f"{Colors.OKGREEN}{checkmark} {message}{Colors.ENDC}")
3244

3345
def print_error(message):
3446
"""Print an error message."""
35-
print(f"{Colors.FAIL}{message}{Colors.ENDC}")
47+
# Use ASCII X on Windows if Unicode fails
48+
xmark = "✗" if sys.platform != 'win32' else "[ERROR]"
49+
print(f"{Colors.FAIL}{xmark} {message}{Colors.ENDC}")
3650

3751
def print_warning(message):
3852
"""Print a warning message."""
39-
print(f"{Colors.WARNING}{message}{Colors.ENDC}")
53+
# Use ASCII warning on Windows if Unicode fails
54+
warning = "⚠" if sys.platform != 'win32' else "[WARN]"
55+
print(f"{Colors.WARNING}{warning} {message}{Colors.ENDC}")
4056

4157
def check_dependencies():
4258
"""Check if required build dependencies are installed."""

hexglitcher.spec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ Builds standalone executable for Windows, Linux, and macOS
66
"""
77

88
import sys
9+
import os
910
from PyInstaller.utils.hooks import collect_data_files
1011

1112
block_cipher = None
1213

1314
# Collect data files for PIL/Pillow
1415
datas = collect_data_files('PIL')
1516

17+
# Check if icon files exist
18+
icon_ico = 'icon.ico' if os.path.exists('icon.ico') else None
19+
icon_icns = 'icon.icns' if os.path.exists('icon.icns') else None
20+
1621
a = Analysis(
1722
['main.py'],
1823
pathex=[],
@@ -55,15 +60,15 @@ exe = EXE(
5560
target_arch=None,
5661
codesign_identity=None,
5762
entitlements_file=None,
58-
icon='icon.ico' if sys.platform == 'win32' else None,
63+
icon=icon_ico if sys.platform == 'win32' else None,
5964
)
6065

6166
# On macOS, create an app bundle
6267
if sys.platform == 'darwin':
6368
app = BUNDLE(
6469
exe,
6570
name='HexGlitcher.app',
66-
icon='icon.icns',
71+
icon=icon_icns,
6772
bundle_identifier='com.glitches.hexglitcher',
6873
info_plist={
6974
'NSPrincipalClass': 'NSApplication',

0 commit comments

Comments
 (0)