-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_exe.sh
More file actions
124 lines (110 loc) · 3.07 KB
/
Copy pathbuild_exe.sh
File metadata and controls
124 lines (110 loc) · 3.07 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# build_exe.sh - Build standalone executable for MostlyLucid-NMT (Linux/Mac)
#
# Usage:
# ./build_exe.sh # Build with default settings
# ./build_exe.sh --clean # Clean build (remove dist/build first)
# ./build_exe.sh --no-upx # Skip UPX compression
set -e
CLEAN=false
NO_UPX=false
DEBUG=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--clean|-c)
CLEAN=true
shift
;;
--no-upx)
NO_UPX=true
shift
;;
--debug|-d)
DEBUG=true
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "========================================"
echo "MostlyLucid-NMT Executable Builder"
echo "========================================"
echo ""
# Check Python
echo "[1/5] Checking Python environment..."
if ! command -v python3 &> /dev/null; then
echo "ERROR: Python3 not found in PATH"
exit 1
fi
PYTHON_VERSION=$(python3 --version)
echo " Found: $PYTHON_VERSION"
# Check PyInstaller
echo "[2/5] Checking PyInstaller..."
if ! python3 -c "import PyInstaller" 2>/dev/null; then
echo " Installing PyInstaller..."
pip3 install pyinstaller
fi
PYINSTALLER_VERSION=$(python3 -c "import PyInstaller; print(PyInstaller.__version__)")
echo " Found: PyInstaller $PYINSTALLER_VERSION"
# Check UPX (optional)
UPX_AVAILABLE=false
if [ "$NO_UPX" = false ]; then
echo "[2.5/5] Checking UPX (optional compression)..."
if command -v upx &> /dev/null; then
UPX_AVAILABLE=true
echo " Found: UPX available"
else
echo " UPX not found (optional - exe will be larger)"
fi
fi
# Clean if requested
if [ "$CLEAN" = true ]; then
echo "[3/5] Cleaning previous builds..."
rm -rf dist build
echo " Cleaned dist/ and build/"
else
echo "[3/5] Skipping clean (use --clean to force)"
fi
# Build
echo "[4/5] Building executable..."
echo " This may take several minutes..."
BUILD_ARGS="mostlylucid_nmt.spec"
if [ "$DEBUG" = true ]; then
BUILD_ARGS="$BUILD_ARGS --log-level=DEBUG"
fi
if [ "$NO_UPX" = true ] || [ "$UPX_AVAILABLE" = false ]; then
BUILD_ARGS="$BUILD_ARGS --noupx"
fi
START_TIME=$(date +%s)
pyinstaller $BUILD_ARGS
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
# Verify output
echo "[5/5] Verifying build..."
EXE_PATH="dist/mostlylucid-nmt"
if [ ! -f "$EXE_PATH" ]; then
echo "ERROR: Executable not found at $EXE_PATH"
exit 1
fi
EXE_SIZE=$(du -h "$EXE_PATH" | cut -f1)
echo ""
echo "========================================"
echo "BUILD SUCCESSFUL"
echo "========================================"
echo ""
echo "Output: $EXE_PATH"
echo "Size: $EXE_SIZE"
echo "Time: ${DURATION} seconds"
echo ""
echo "Usage:"
echo " ./dist/mostlylucid-nmt # Start server"
echo " ./dist/mostlylucid-nmt --help # Show help"
echo " ./dist/mostlylucid-nmt --check # Check if running"
echo " ./dist/mostlylucid-nmt --translate 'Hello' -s en -t de"
echo ""
# Make executable
chmod +x "$EXE_PATH"