-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackager.sh
More file actions
executable file
·67 lines (55 loc) · 1.6 KB
/
packager.sh
File metadata and controls
executable file
·67 lines (55 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
APP_NAME="pac-man"
DIST_DIR="dist"
BUILD_DIR="build"
echo "--- Starting packaging process for $APP_NAME ---"
# 1. Clean previous builds
echo "Cleaning old directories..."
rm -rf "$DIST_DIR" "$BUILD_DIR" "${APP_NAME}.spec"
# 2. Run PyInstaller via uv
echo "Running PyInstaller with uv..."
uv run pyinstaller --noconfirm --onefile --windowed \
--paths "src" \
--paths "libs" \
--add-data "assets:assets" \
--add-data "default_files:default_files" \
--hidden-import "pygame" \
--collect-all "pydantic" \
"${APP_NAME}.py"
# Check if PyInstaller succeeded
if [ $? -ne 0 ]; then
echo "Error: PyInstaller failed."
exit 1
fi
# 3. Copy external files to the dist/ folder
echo "Copying configuration files and external assets..."
# Copy JSON files
if [ -f "config.json" ]; then
cp "config.json" "$DIST_DIR/"
else
echo "Warning: config.json not found in root."
fi
if [ -f "highscores.json" ]; then
cp "highscores.json" "$DIST_DIR/"
else
echo "Warning: highscores.json not found in root (will be created on play)."
fi
# Copy assets folder
if [ -d "assets" ]; then
cp -r "assets" "$DIST_DIR/"
else
echo "Error: assets/ directory not found."
exit 1
fi
# Copy default_files folder
if [ -d "default_files" ]; then
echo "Copying default_files to dist..."
cp -r "default_files" "$DIST_DIR/"
else
echo "Warning: default_files/ directory not found in root."
fi
# 4. Set execution permissions
echo "Setting execution permissions for the binary..."
chmod +x "$DIST_DIR/$APP_NAME"
echo "--- Process completed successfully ---"
echo "Game is packaged in: $DIST_DIR"