-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsetup_env.sh
More file actions
126 lines (108 loc) · 3.17 KB
/
setup_env.sh
File metadata and controls
126 lines (108 loc) · 3.17 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
125
126
#!/bin/bash
# SpatialAgent Environment Setup Script
# Creates a conda environment with Python 3.11 and all required packages
#
# Usage:
# ./setup_env.sh [env_name]
#
# Default environment name: spatial_agent
set -e # Exit on error
ENV_NAME="${1:-spatial_agent}"
CONDA_BASE=$(conda info --base)
echo "==========================================="
echo "SpatialAgent Environment Setup"
echo "==========================================="
echo "Environment name: $ENV_NAME"
echo "Conda base: $CONDA_BASE"
echo ""
# Check if conda is available
if ! command -v conda &> /dev/null; then
echo "ERROR: conda is not installed or not in PATH"
exit 1
fi
# Check if environment already exists
if conda env list | grep -q "^$ENV_NAME "; then
echo "WARNING: Environment '$ENV_NAME' already exists."
read -p "Do you want to remove it and create a new one? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Removing existing environment..."
conda env remove -n "$ENV_NAME" -y
else
echo "Aborting."
exit 1
fi
fi
echo ""
echo "Step 1: Creating conda environment with Python 3.11..."
conda create -n "$ENV_NAME" python=3.11 -y
# Activate environment
source "$CONDA_BASE/etc/profile.d/conda.sh"
conda activate "$ENV_NAME"
echo ""
echo "Step 2: Installing packages from requirements.txt..."
# Upgrade pip
pip install --upgrade pip
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Install all packages from requirements.txt
pip install -r "$SCRIPT_DIR/resource/requirements.txt"
echo ""
echo "Step 3: Installing UTAG (Python 3.12 compatible fork)..."
pip install -e "$SCRIPT_DIR/resource/utag"
echo ""
echo "Step 4: Verifying installation..."
python -c "
import sys
print(f'Python: {sys.version}')
print()
modules = [
('scanpy', 'scanpy'),
('anndata', 'anndata'),
('squidpy', 'squidpy'),
('scvi', 'scvi-tools'),
('cell2location', 'cell2location'),
('SpaGCN', 'SpaGCN'),
('GraphST', 'GraphST'),
('ot', 'POT'),
('tangram', 'tangram-sc'),
('liana', 'liana'),
('langchain', 'langchain'),
('anthropic', 'anthropic'),
('torch', 'pytorch'),
('leidenalg', 'leidenalg'),
('bbknn', 'bbknn'),
('scvelo', 'scvelo'),
('cellrank', 'cellrank'),
('mofapy2', 'mofapy2'),
('Bio', 'biopython'),
('utag', 'utag'),
('cellphonedb', 'cellphonedb'),
]
print('Package verification:')
failed = []
for mod, name in modules:
try:
m = __import__(mod)
v = getattr(m, '__version__', 'OK')
print(f' {name}: {v}')
except Exception as e:
print(f' {name}: FAILED')
failed.append(name)
if failed:
print(f'\\nWARNING: {len(failed)} package(s) failed to import: {failed}')
sys.exit(1)
else:
print('\\nAll packages verified successfully!')
"
echo ""
echo "==========================================="
echo "Setup Complete!"
echo "==========================================="
echo ""
echo "To activate the environment:"
echo " conda activate $ENV_NAME"
echo ""
echo "To register as Jupyter kernel:"
echo " python -m ipykernel install --user --name $ENV_NAME --display-name \"Python ($ENV_NAME)\""
echo ""