-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicPipe.command
More file actions
executable file
·77 lines (68 loc) · 2.21 KB
/
Copy pathMicPipe.command
File metadata and controls
executable file
·77 lines (68 loc) · 2.21 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
#!/bin/bash
# Get the directory where this script is located
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
export PATH="$HOME/.local/bin:/usr/local/bin:/opt/homebrew/bin:$PATH"
if command -v uv &> /dev/null; then
# uv handles venv creation and dependency installation automatically
echo "🚀 Starting MicPipe using uv..."
RUN_CMD="uv run python micpipe.py"
else
echo "⚙️ uv not found, using pip..."
# Find a usable python3
if command -v python3 &> /dev/null; then
SYS_PYTHON="python3"
else
echo "❌ Python 3 not found. Please install Python 3.11 or higher."
echo "Press any key to exit..."
read -n 1
exit 1
fi
# Create virtual environment if it doesn't exist
if [ ! -f ".venv/bin/python" ]; then
echo "📦 Creating virtual environment..."
$SYS_PYTHON -m venv .venv
if [ $? -ne 0 ]; then
echo "❌ Failed to create virtual environment."
echo "Press any key to exit..."
read -n 1
exit 1
fi
fi
# Install dependencies if a key package (rumps) is missing
if ! .venv/bin/python -c "import rumps" &> /dev/null; then
echo "📦 Installing dependencies..."
.venv/bin/pip install . --quiet
if [ $? -ne 0 ]; then
echo "❌ Failed to install dependencies."
echo "Press any key to exit..."
read -n 1
exit 1
fi
echo "✅ Dependencies installed."
fi
RUN_CMD=".venv/bin/python micpipe.py"
fi
# Run the application in the background
nohup $RUN_CMD > /tmp/micpipe.log 2>&1 &
echo "🚀 MicPipe is starting in the background..."
echo "📂 Logs are being written to /tmp/micpipe.log"
# Wait a moment and then close the Terminal window(s)
sleep 1
osascript -e '
tell application "Terminal"
-- Close all idle windows opened by this script
repeat while (count of windows) > 0
if busy of front window is false then
close front window
delay 0.3
else
exit repeat
end if
end repeat
delay 0.5
-- Quit Terminal if no windows remain
if (count of windows) is 0 then quit
end tell
' 2>/dev/null &
exit