-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch-native.command
More file actions
90 lines (76 loc) · 3.02 KB
/
launch-native.command
File metadata and controls
90 lines (76 loc) · 3.02 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
#!/usr/bin/env bash
# QuantUI NATIVE MODE — macOS launcher
# Double-click in Finder, or run from a terminal. Equivalent to
# launch-native.bat on Windows but runs natively on macOS (no WSL
# layer, since PySCF installs cleanly on macOS).
#
# Use this when you have edited quantui/*.py and want to test
# immediately — quantui/*.py changes are always live in editable mode.
set -eu
# Resolve script directory so double-click from any location works.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "QuantUI NATIVE MODE — Local conda env on macOS, no container"
echo "Use this when you have edited quantui/*.py and want to test immediately."
echo
# Locate conda.sh. Miniconda at ~/miniconda3 is the documented install;
# we try a few common fallback locations before giving up.
CONDA_SH=""
for candidate in \
"$HOME/miniconda3/etc/profile.d/conda.sh" \
"$HOME/opt/miniconda3/etc/profile.d/conda.sh" \
"/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" \
"/usr/local/Caskroom/miniconda/base/etc/profile.d/conda.sh" \
"$HOME/anaconda3/etc/profile.d/conda.sh" \
"$HOME/opt/anaconda3/etc/profile.d/conda.sh"; do
if [ -f "$candidate" ]; then
CONDA_SH="$candidate"
break
fi
done
if [ -z "$CONDA_SH" ]; then
echo "ERROR: Could not locate conda.sh."
echo " Install Miniconda to ~/miniconda3 and re-run."
echo " https://docs.conda.io/projects/miniconda/en/latest/"
echo
read -n 1 -s -r -p "Press any key to close this window..."
exit 1
fi
# shellcheck disable=SC1090
source "$CONDA_SH"
conda activate quantui
# pip install -e . is skipped when pyproject.toml has not changed since
# the last install (.dev_install_stamp). quantui/*.py changes are always
# live in editable mode — reinstall is only needed after pyproject.toml
# changes or on first use.
if [ ! -f .dev_install_stamp ] || [ pyproject.toml -nt .dev_install_stamp ]; then
echo "Installing quantui in editable mode (first run or pyproject.toml changed)..."
pip install -e . -q
touch .dev_install_stamp
fi
# Mirrors the Windows launcher: clear bytecode and disable .pyc writes.
# Not strictly required on macOS (no WSL2 DrvFs mtime issues), but kept
# for parity so the dev experience is identical across platforms.
rm -rf quantui/__pycache__
export PYTHONDONTWRITEBYTECODE=1
# Port 8867 mirrors the Windows native launcher.
PORT=8867
URL="http://localhost:${PORT}"
echo "Starting Voilà on ${URL}..."
echo
# Launch Voilà in the background so we can open the browser, then wait
# on the process so closing this Terminal window stops the server.
voila notebooks/molecule_computations.ipynb \
--no-browser \
--port="${PORT}" \
--ServerApp.disable_check_xsrf=True &
VOILA_PID=$!
# Give Voilà a moment to bind to the port before opening the browser.
sleep 4
open "${URL}"
echo
echo "Native dev server running at ${URL}"
echo "All local quantui/*.py changes are live — no rebuild needed."
echo "Close this Terminal window or press Ctrl-C to stop."
echo
wait "${VOILA_PID}"