-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall-venv-initial.sh
More file actions
executable file
·75 lines (57 loc) · 2.04 KB
/
install-venv-initial.sh
File metadata and controls
executable file
·75 lines (57 loc) · 2.04 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
#!/usr/bin/env bash
set -e
echo "=== VENV Setup ==="
# Detect OS
OS="$(uname -s)"
echo "Detected OS: $OS"
if [[ "$OS" == "Darwin" ]]; then
echo "Setting up for macOS..."
# Ensure Homebrew is installed
if ! command -v brew &>/dev/null; then
echo "Homebrew not found. Installing..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Install Python 3.11 via Homebrew
brew install python@3.11 || true
PYTHON_BIN="$(brew --prefix python@3.11)/bin/python3.11"
VENV_PYTHON="$PYTHON_BIN"
# Install HDF5 for PyTables
brew install hdf5 || true
export HDF5_DIR="$(brew --prefix hdf5)"
elif [[ "$OS" == "Linux" ]]; then
echo "Setting up for Ubuntu/Linux..."
# Remove unsupported PPAs (e.g. deadsnakes on questing)
if ls /etc/apt/sources.list.d/deadsnakes* 1>/dev/null 2>&1; then
echo "Removing unsupported deadsnakes PPA..."
sudo rm -f /etc/apt/sources.list.d/deadsnakes*
fi
sudo apt update
sudo apt install -y software-properties-common curl build-essential
# Ubuntu 24.x has python3.13 available
PYTHON_BIN="/usr/bin/python3.13"
sudo apt install -y python3.13 python3.13-venv python3.13-dev python3-pip
else
echo "Unsupported OS: $OS"
exit 1
fi
# Create .venv
$PYTHON_BIN -m venv .venv
source .venv/bin/activate
# Upgrade pip and build tools
pip install --upgrade pip wheel setuptools
# Install core packages
pip install numpy pandas matplotlib scipy tables seaborn scikit-learn jupyter notebook jupyter-book
# Other packages for notebook execution
pip install emcee
# Configure VS Code for this .venv
mkdir -p .vscode
cat > .vscode/settings.json <<EOL
{
"python.pythonPath": "\${workspaceFolder}/.venv/bin/python",
"python.terminal.activateEnvironment": true,
"jupyter.notebookFileRoot": "\${workspaceFolder}"
}
EOL
echo "✅ Setup complete!"
echo "Activate the environment anytime with: source .venv/bin/activate"
echo "VS Code is configured to use this .venv for terminals and notebooks."