-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·106 lines (91 loc) · 3.14 KB
/
build.sh
File metadata and controls
executable file
·106 lines (91 loc) · 3.14 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
#!/bin/bash
# OpenContext Build Script
# Packages the project into a single executable using PyInstaller.
set -e
echo "=== OpenContext Build Script ==="
# 1. Dependency Check
echo "--> Checking for python3..."
if ! command -v python3 &> /dev/null; then
echo "❌ Error: python3 is not found. Please install Python 3."
exit 1
fi
USE_UV=false
# 2. Check for uv and install dependencies
if command -v uv &> /dev/null; then
echo "--> Using uv to install dependencies..."
uv sync
USE_UV=true
else
echo "--> uv not found, using pip to install from pyproject.toml..."
python3 -m pip install -e .
fi
# 3. Install PyInstaller if not present
if [ "$USE_UV" = true ]; then
# Use uv run to ensure detection within the uv-managed virtual environment
if ! uv run python -c "import PyInstaller" 2>/dev/null; then
echo "--> PyInstaller not found (uv env). Installing..."
uv pip install pyinstaller
fi
else
if ! python3 -c "import PyInstaller" 2>/dev/null; then
echo "--> PyInstaller not found. Installing..."
python3 -m pip install pyinstaller
fi
fi
# 4. Clean up previous builds
echo "--> Cleaning up previous build directories..."
rm -rf dist/ build/
# 5. Run PyInstaller build
echo "--> Starting application build with PyInstaller..."
if [ "$USE_UV" = true ]; then
uv run pyinstaller --clean --noconfirm --log-level INFO opencontext.spec
else
pyinstaller --clean --noconfirm --log-level INFO opencontext.spec
fi
# 6. Verify build and package
echo "--> Verifying build output..."
EXECUTABLE_NAME="main" # As defined in the original script
ONEDIR_EXECUTABLE="dist/$EXECUTABLE_NAME/$EXECUTABLE_NAME"
ONEDIR_EXECUTABLE_WIN="dist/$EXECUTABLE_NAME/$EXECUTABLE_NAME.exe"
if [ -f "$ONEDIR_EXECUTABLE" ]; then
BUILT_EXECUTABLE="$ONEDIR_EXECUTABLE"
elif [ -f "$ONEDIR_EXECUTABLE_WIN" ]; then
BUILT_EXECUTABLE="$ONEDIR_EXECUTABLE_WIN"
else
BUILT_EXECUTABLE=""
fi
if [ -n "$BUILT_EXECUTABLE" ]; then
echo "✅ Build successful!"
# Ad-hoc sign for macOS to avoid Gatekeeper issues
if [[ "$OSTYPE" == "darwin"* ]] && [ -f "$BUILT_EXECUTABLE" ]; then
echo "--> Performing ad-hoc sign for macOS executable..."
codesign -s - --force --all-architectures --timestamp=none --deep "$BUILT_EXECUTABLE" 2>/dev/null || {
echo "⚠️ Warning: Ad-hoc signing failed. The app might still run, but you may see security warnings."
}
fi
echo "--> Executable is available in the 'dist/' directory."
ls -la dist/
# Copy config directory
if [ -d "config" ]; then
echo "--> Copying 'config' directory to 'dist/'..."
cp -r config dist/
echo "✅ Config directory copied."
else
echo "⚠️ Warning: 'config' directory not found."
fi
echo
echo "✅ Build complete!"
echo
echo "To run:"
if [ -f "$ONEDIR_EXECUTABLE" ]; then
echo " cd dist/main && ./main start"
else
echo " cd dist/main && main.exe start"
fi
echo
echo "Options: --port 9000 | --host 0.0.0.0 | --config config/config.yaml"
echo
else
echo "❌ Build failed. Check the PyInstaller logs above for errors."
exit 1
fi