Skip to content

Commit 6f8354c

Browse files
committed
Add env.sh installation script with uv support
1 parent f098fa8 commit 6f8354c

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

env.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
3+
# THEMAP Environment Setup Script
4+
# This script sets up a Python virtual environment using uv and installs all dependencies
5+
#
6+
# Usage:
7+
# source env.sh (recommended - keeps environment activated)
8+
# bash env.sh (requires manual activation after)
9+
10+
set -e # Exit on error
11+
12+
echo "=========================================="
13+
echo "THEMAP Environment Setup"
14+
echo "=========================================="
15+
echo ""
16+
17+
# Check if uv is installed
18+
if ! command -v uv &> /dev/null; then
19+
echo "📦 uv not found. Installing uv..."
20+
curl -LsSf https://astral.sh/uv/install.sh | sh
21+
22+
# Add uv to PATH for this session
23+
export PATH="$HOME/.cargo/bin:$PATH"
24+
25+
echo "✅ uv installed successfully"
26+
echo ""
27+
else
28+
echo "✅ uv is already installed"
29+
echo ""
30+
fi
31+
32+
# Check Python version
33+
echo "🐍 Checking Python version..."
34+
if command -v python3.11 &> /dev/null; then
35+
PYTHON_CMD="python3.11"
36+
elif command -v python3.10 &> /dev/null; then
37+
PYTHON_CMD="python3.10"
38+
elif command -v python3.9 &> /dev/null; then
39+
PYTHON_CMD="python3.9"
40+
else
41+
PYTHON_CMD="python3"
42+
fi
43+
44+
PYTHON_VERSION=$($PYTHON_CMD --version 2>&1 | awk '{print $2}')
45+
echo " Using Python: $PYTHON_VERSION"
46+
echo ""
47+
48+
# Create virtual environment with uv
49+
echo "🔨 Creating virtual environment in .venv..."
50+
uv venv .venv --python $PYTHON_CMD
51+
echo "✅ Virtual environment created"
52+
echo ""
53+
54+
# Activate virtual environment
55+
echo "🔄 Activating virtual environment..."
56+
source .venv/bin/activate
57+
echo "✅ Virtual environment activated"
58+
echo ""
59+
60+
# Upgrade pip and install build tools
61+
echo "📦 Installing build tools..."
62+
uv pip install --upgrade pip setuptools wheel
63+
echo "✅ Build tools installed"
64+
echo ""
65+
66+
# Install THEMAP with all dependencies
67+
echo "📚 Installing THEMAP with all dependencies..."
68+
echo " This includes: core, ml, otdd, protein, dev, and test dependencies"
69+
echo ""
70+
71+
# Install the package in editable mode with all optional dependencies
72+
uv pip install -e ".[all,dev,test]"
73+
74+
echo ""
75+
echo "✅ Installation complete!"
76+
echo ""
77+
78+
# Minimal verification
79+
echo "🔍 Verifying installation..."
80+
python -c "import themap; from themap.data import MoleculeDatapoint; print(f'✅ THEMAP v{themap.__version__} imported successfully')"
81+
82+
if [ $? -eq 0 ]; then
83+
echo ""
84+
echo "=========================================="
85+
echo "🎉 Setup Complete!"
86+
echo "=========================================="
87+
echo ""
88+
89+
# Check if script was sourced
90+
if [ -n "$BASH_SOURCE" ] && [ "$0" != "$BASH_SOURCE" ]; then
91+
echo "✅ Environment is ACTIVE in your current shell"
92+
echo ""
93+
echo "Next steps:"
94+
echo " python run_tests.py # Run tests"
95+
echo " python examples/basic/molecule_datasets_demo.py # Try an example"
96+
echo ""
97+
else
98+
echo "To activate the environment, run:"
99+
echo " source .venv/bin/activate"
100+
echo ""
101+
echo "Or run this script with 'source' to auto-activate:"
102+
echo " source env.sh"
103+
echo ""
104+
fi
105+
else
106+
echo "❌ Verification failed. Installation may be incomplete."
107+
exit 1
108+
fi

0 commit comments

Comments
 (0)