-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_with_pyinstaller.sh
More file actions
executable file
·74 lines (60 loc) · 1.98 KB
/
build_with_pyinstaller.sh
File metadata and controls
executable file
·74 lines (60 loc) · 1.98 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
68
69
70
71
72
73
74
#!/bin/bash
# Build Python scripts with PyInstaller
# Usage: ./build_with_pyinstaller.sh [target_platform] [output_dir] [scripts] [script_names] [icon_file] [include_data_dirs] [data_separator] [additional_args]
set -e
# Parse arguments
TARGET_PLATFORM="${1}"
OUTPUT_DIR="${2}"
SCRIPTS="${3}"
SCRIPT_NAMES="${4}"
ICON_FILE="${5}"
INCLUDE_DATA_DIRS="${6}"
DATA_SEPARATOR="${7}"
ADDITIONAL_ARGS="${8}"
echo "Building with PyInstaller..."
echo "Target platform: $TARGET_PLATFORM"
echo "Output directory: $OUTPUT_DIR"
echo "Scripts: $SCRIPTS"
echo "Script names: $SCRIPT_NAMES"
# Build each Python file
IFS=' ' read -ra PYTHON_FILES <<< "$SCRIPTS"
IFS=' ' read -ra SCRIPT_NAMES_ARRAY <<< "$SCRIPT_NAMES"
for i in "${!PYTHON_FILES[@]}"; do
file="${PYTHON_FILES[$i]}"
echo "Building $file for $TARGET_PLATFORM..."
# Start building the command
cmd="uv run pyinstaller --onefile --distpath=$OUTPUT_DIR"
# Add custom name if provided
if [ -n "$SCRIPT_NAMES" ] && [ $i -lt ${#SCRIPT_NAMES_ARRAY[@]} ]; then
custom_name="${SCRIPT_NAMES_ARRAY[$i]}"
cmd="$cmd --name=$custom_name"
echo "Using custom name: $custom_name"
fi
# Windows-specific options
if [ "$TARGET_PLATFORM" = "windows-amd64" ]; then
if [ -n "$ICON_FILE" ]; then
cmd="$cmd --icon=$ICON_FILE"
fi
fi
# Add include-data-dirs using Python script
if [ -n "$INCLUDE_DATA_DIRS" ]; then
echo "Processing include-data-dirs for $file..."
include_flags=$(uv run python $GITHUB_ACTION_PATH/process_include_dirs.py "$INCLUDE_DATA_DIRS" "$DATA_SEPARATOR" "$file")
echo "Include flags result: '$include_flags'"
if [ -n "$include_flags" ]; then
cmd="$cmd $include_flags"
echo "Added include flags to command"
else
echo "No include flags generated"
fi
fi
# Add additional arguments
if [ -n "$ADDITIONAL_ARGS" ]; then
cmd="$cmd $ADDITIONAL_ARGS"
fi
# Add the file to build
cmd="$cmd $file"
echo "Executing: $cmd"
eval "$cmd"
done
echo "Build completed successfully"