Skip to content

Commit d8e2d64

Browse files
committed
fix: Linux/macOS build script with proper icons and optimizations
1 parent c22a182 commit d8e2d64

File tree

2 files changed

+111
-8
lines changed

2 files changed

+111
-8
lines changed

Launcher.sh

Lines changed: 98 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,38 @@ build_stable() {
104104
pip install pyinstaller -q
105105

106106
FILENAME="SurfManager-${OS_NAME}-${ARCH_NAME}-${VERSION}"
107+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
108+
109+
# Platform-specific options
110+
PLATFORM_OPTS=""
111+
ICON_DATA=""
112+
113+
# Include icons folder for runtime
114+
if [ -d "app/icons" ]; then
115+
ICON_DATA="--add-data app/icons:app/icons"
116+
fi
117+
118+
if [ "$OS" = "Darwin" ]; then
119+
# macOS: use .icns if available, set bundle identifier
120+
if [ -f "app/icons/app.icns" ]; then
121+
PLATFORM_OPTS="--icon=app/icons/app.icns"
122+
elif [ -f "app/icons/app.ico" ]; then
123+
PLATFORM_OPTS="--icon=app/icons/app.ico"
124+
fi
125+
PLATFORM_OPTS="$PLATFORM_OPTS --osx-bundle-identifier=com.risuncode.surfmanager"
126+
else
127+
# Linux: use .png or .ico
128+
if [ -f "app/icons/app.png" ]; then
129+
PLATFORM_OPTS="--icon=app/icons/app.png"
130+
elif [ -f "app/icons/app.ico" ]; then
131+
PLATFORM_OPTS="--icon=app/icons/app.ico"
132+
fi
133+
fi
107134

108135
echo "Generating executable (this may take 2-3 minutes)..."
109-
pyinstaller --onefile --windowed --clean --name="$FILENAME" --distpath="dist/stable" --workpath="build/stable" --specpath="build/stable" \
136+
pyinstaller --onefile --windowed --clean --name="$FILENAME" \
137+
--distpath="dist/stable" --workpath="build/stable" --specpath="build/stable" \
138+
$PLATFORM_OPTS $ICON_DATA \
110139
--hidden-import PyQt6.QtCore \
111140
--hidden-import PyQt6.QtWidgets \
112141
--hidden-import PyQt6.QtGui \
@@ -117,16 +146,34 @@ build_stable() {
117146
--exclude-module matplotlib \
118147
--exclude-module numpy \
119148
--exclude-module pandas \
149+
--exclude-module PyQt6.QtWebEngine \
150+
--exclude-module PyQt6.QtWebEngineWidgets \
151+
--exclude-module PyQt6.QtQml \
152+
--exclude-module PyQt6.QtQuick \
153+
--exclude-module PyQt6.QtMultimedia \
154+
--exclude-module PyQt6.QtBluetooth \
155+
--exclude-module PyQt6.QtPositioning \
156+
--exclude-module PyQt6.QtPrintSupport \
157+
--exclude-module PyQt6.QtTest \
158+
--exclude-module PyQt6.QtSql \
159+
--exclude-module PyQt6.QtOpenGL \
160+
--exclude-module PIL \
161+
--exclude-module IPython \
162+
--exclude-module pytest \
163+
--exclude-module unittest \
164+
--exclude-module test \
165+
--strip \
166+
--noupx \
120167
app/main.py
121168

122169
if [ $? -eq 0 ]; then
123170
echo ""
124-
echo -e "${GREEN}Build successful!${NC}"
171+
echo -e "${GREEN}Build successful!${NC}"
125172
echo "Executable: dist/stable/$FILENAME"
126173
echo ""
127174
else
128175
echo ""
129-
echo -e "${RED}Build failed!${NC}"
176+
echo -e "${RED}Build failed!${NC}"
130177
echo ""
131178
fi
132179
read -p "Press Enter to continue..."
@@ -143,8 +190,36 @@ build_debug() {
143190

144191
FILENAME="SurfManager-${OS_NAME}-${ARCH_NAME}-${VERSION}-debug"
145192

193+
# Platform-specific options
194+
PLATFORM_OPTS=""
195+
ICON_DATA=""
196+
197+
# Include icons folder for runtime
198+
if [ -d "app/icons" ]; then
199+
ICON_DATA="--add-data app/icons:app/icons"
200+
fi
201+
202+
if [ "$OS" = "Darwin" ]; then
203+
# macOS: use .icns if available, set bundle identifier
204+
if [ -f "app/icons/app.icns" ]; then
205+
PLATFORM_OPTS="--icon=app/icons/app.icns"
206+
elif [ -f "app/icons/app.ico" ]; then
207+
PLATFORM_OPTS="--icon=app/icons/app.ico"
208+
fi
209+
PLATFORM_OPTS="$PLATFORM_OPTS --osx-bundle-identifier=com.risuncode.surfmanager"
210+
else
211+
# Linux: use .png or .ico
212+
if [ -f "app/icons/app.png" ]; then
213+
PLATFORM_OPTS="--icon=app/icons/app.png"
214+
elif [ -f "app/icons/app.ico" ]; then
215+
PLATFORM_OPTS="--icon=app/icons/app.ico"
216+
fi
217+
fi
218+
146219
echo "Generating executable with debug info..."
147-
pyinstaller --onefile --console --clean --name="$FILENAME" --distpath="dist/debug" --workpath="build/debug" --specpath="build/debug" \
220+
pyinstaller --onefile --console --clean --name="$FILENAME" \
221+
--distpath="dist/debug" --workpath="build/debug" --specpath="build/debug" \
222+
$PLATFORM_OPTS $ICON_DATA \
148223
--hidden-import PyQt6.QtCore \
149224
--hidden-import PyQt6.QtWidgets \
150225
--hidden-import PyQt6.QtGui \
@@ -155,17 +230,34 @@ build_debug() {
155230
--exclude-module matplotlib \
156231
--exclude-module numpy \
157232
--exclude-module pandas \
233+
--exclude-module PyQt6.QtWebEngine \
234+
--exclude-module PyQt6.QtWebEngineWidgets \
235+
--exclude-module PyQt6.QtQml \
236+
--exclude-module PyQt6.QtQuick \
237+
--exclude-module PyQt6.QtMultimedia \
238+
--exclude-module PyQt6.QtBluetooth \
239+
--exclude-module PyQt6.QtPositioning \
240+
--exclude-module PyQt6.QtPrintSupport \
241+
--exclude-module PyQt6.QtTest \
242+
--exclude-module PyQt6.QtSql \
243+
--exclude-module PyQt6.QtOpenGL \
244+
--exclude-module PIL \
245+
--exclude-module IPython \
246+
--exclude-module pytest \
247+
--exclude-module unittest \
248+
--exclude-module test \
158249
--debug all \
250+
--noupx \
159251
app/main.py
160252

161253
if [ $? -eq 0 ]; then
162254
echo ""
163-
echo -e "${GREEN}Build successful!${NC}"
255+
echo -e "${GREEN}Build successful!${NC}"
164256
echo "Executable: dist/debug/$FILENAME"
165257
echo ""
166258
else
167259
echo ""
168-
echo -e "${RED}Build failed!${NC}"
260+
echo -e "${RED}Build failed!${NC}"
169261
echo ""
170262
fi
171263
read -p "Press Enter to continue..."

app/main.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,19 @@ def main():
3434
app.setApplicationName("SurfManager")
3535
app.setApplicationVersion(__version__)
3636

37-
# Set application icon
38-
icon_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "icons", "app.ico")
37+
# Set application icon (cross-platform)
38+
app_dir = os.path.dirname(__file__)
39+
if sys.platform == 'darwin':
40+
icon_file = "app.icns"
41+
elif sys.platform == 'win32':
42+
icon_file = "app.ico"
43+
else:
44+
icon_file = "app.png"
45+
46+
icon_path = os.path.join(app_dir, "icons", icon_file)
47+
# Fallback to .ico if platform-specific icon not found
48+
if not os.path.exists(icon_path):
49+
icon_path = os.path.join(app_dir, "icons", "app.ico")
3950
if os.path.exists(icon_path):
4051
app.setWindowIcon(QIcon(icon_path))
4152

0 commit comments

Comments
 (0)