|
| 1 | +# Development Setup Guide |
| 2 | + |
| 3 | +This guide helps you set up a local development environment for the vortex-sdk-python package. |
| 4 | + |
| 5 | +## Python Installation with Homebrew (macOS) |
| 6 | + |
| 7 | +If you installed Python with Homebrew, you may encounter permission issues with system-wide installations. The solution is to use a virtual environment. |
| 8 | + |
| 9 | +## Setting Up Virtual Environment |
| 10 | + |
| 11 | +### 1. Create a Virtual Environment |
| 12 | + |
| 13 | +```bash |
| 14 | +# Navigate to project directory |
| 15 | +cd vortex-python-sdk |
| 16 | + |
| 17 | +# Create virtual environment using Homebrew Python |
| 18 | +python3 -m venv venv |
| 19 | + |
| 20 | +# Alternative: specify explicit Python version |
| 21 | +/opt/homebrew/bin/python3 -m venv venv |
| 22 | +``` |
| 23 | + |
| 24 | +### 2. Activate Virtual Environment |
| 25 | + |
| 26 | +```bash |
| 27 | +# On macOS/Linux |
| 28 | +source venv/bin/activate |
| 29 | + |
| 30 | +# On Windows |
| 31 | +venv\Scripts\activate |
| 32 | +``` |
| 33 | + |
| 34 | +After activation, your terminal prompt should show `(venv)` prefix. |
| 35 | + |
| 36 | +### 3. Upgrade pip in Virtual Environment |
| 37 | + |
| 38 | +```bash |
| 39 | +pip install --upgrade pip setuptools wheel |
| 40 | +``` |
| 41 | + |
| 42 | +### 4. Install the Package in Development Mode |
| 43 | + |
| 44 | +```bash |
| 45 | +# Install package with all development dependencies |
| 46 | +pip install -e ".[dev]" |
| 47 | +``` |
| 48 | + |
| 49 | +### 5. Install Node.js Dependencies |
| 50 | + |
| 51 | +```bash |
| 52 | +# Install npm dependencies (required for the SDK) |
| 53 | +npm install |
| 54 | +``` |
| 55 | + |
| 56 | +### 6. Verify Installation |
| 57 | + |
| 58 | +```bash |
| 59 | +# Test import |
| 60 | +python -c "from vortex_sdk import VortexSDK; print('✓ Import successful')" |
| 61 | + |
| 62 | +# Run tests |
| 63 | +pytest |
| 64 | + |
| 65 | +# Check Node.js SDK is accessible |
| 66 | +node -e "require.resolve('@vortexfi/sdk')" |
| 67 | +``` |
| 68 | + |
| 69 | +## Complete Setup Commands (Copy-Paste) |
| 70 | + |
| 71 | +```bash |
| 72 | +# 1. Create and activate venv |
| 73 | +python3 -m venv venv |
| 74 | +source venv/bin/activate |
| 75 | + |
| 76 | +# 2. Upgrade pip |
| 77 | +pip install --upgrade pip setuptools wheel |
| 78 | + |
| 79 | +# 3. Install Node.js dependencies |
| 80 | +npm install |
| 81 | + |
| 82 | +# 4. Install Python package in development mode |
| 83 | +pip install -e ".[dev]" |
| 84 | + |
| 85 | +# 5. Install pre-commit hooks (optional) |
| 86 | +pre-commit install |
| 87 | + |
| 88 | +# 6. Verify everything works |
| 89 | +python -c "from vortex_sdk import VortexSDK; print('✓ Ready!')" |
| 90 | +pytest |
| 91 | +``` |
| 92 | + |
| 93 | +## Deactivating Virtual Environment |
| 94 | + |
| 95 | +When you're done working: |
| 96 | + |
| 97 | +```bash |
| 98 | +deactivate |
| 99 | +``` |
| 100 | + |
| 101 | +## Troubleshooting |
| 102 | + |
| 103 | +### "Permission denied" or "externally-managed-environment" |
| 104 | + |
| 105 | +**Problem:** Cannot install packages due to system protection. |
| 106 | + |
| 107 | +**Solution:** Always use a virtual environment (venv). Never use `sudo pip`. |
| 108 | + |
| 109 | +```bash |
| 110 | +# Create venv if you haven't |
| 111 | +python3 -m venv venv |
| 112 | +source venv/bin/activate |
| 113 | +pip install -e ".[dev]" |
| 114 | +``` |
| 115 | + |
| 116 | +### "Command not found: python3" |
| 117 | + |
| 118 | +**Problem:** Python not in PATH or not installed. |
| 119 | + |
| 120 | +**Solution:** |
| 121 | + |
| 122 | +```bash |
| 123 | +# Install Python via Homebrew |
| 124 | + |
| 125 | + |
| 126 | +# Use explicit path |
| 127 | +/opt/homebrew/bin/python3 -m venv venv |
| 128 | +``` |
| 129 | + |
| 130 | +### "Node.js not found" |
| 131 | + |
| 132 | +**Problem:** Node.js not installed. |
| 133 | + |
| 134 | +**Solution:** |
| 135 | + |
| 136 | +```bash |
| 137 | +# Install Node.js via Homebrew |
| 138 | +brew install node |
| 139 | + |
| 140 | +# Verify installation |
| 141 | +node --version |
| 142 | +npm --version |
| 143 | +``` |
| 144 | + |
| 145 | +### "@vortexfi/sdk not found" |
| 146 | + |
| 147 | +**Problem:** npm dependencies not installed. |
| 148 | + |
| 149 | +**Solution:** |
| 150 | + |
| 151 | +```bash |
| 152 | +# Install npm dependencies |
| 153 | +npm install |
| 154 | + |
| 155 | +# Or install globally |
| 156 | +npm install -g @vortexfi/sdk |
| 157 | +``` |
| 158 | + |
| 159 | +### Virtual environment not activating |
| 160 | + |
| 161 | +**Problem:** `source venv/bin/activate` doesn't work. |
| 162 | + |
| 163 | +**Solution:** |
| 164 | + |
| 165 | +```bash |
| 166 | +# Try with dot notation |
| 167 | +. venv/bin/activate |
| 168 | + |
| 169 | +# Or use full path |
| 170 | +source /Users/yourname/vortex-python-sdk/venv/bin/activate |
| 171 | +``` |
| 172 | + |
| 173 | +### "No module named 'vortex_sdk'" |
| 174 | + |
| 175 | +**Problem:** Package not installed in development mode. |
| 176 | + |
| 177 | +**Solution:** |
| 178 | + |
| 179 | +```bash |
| 180 | +# Make sure venv is activated |
| 181 | +source venv/bin/activate |
| 182 | + |
| 183 | +# Install in development mode |
| 184 | +pip install -e . |
| 185 | +``` |
| 186 | + |
| 187 | +## Working with Multiple Python Versions |
| 188 | + |
| 189 | +If you need to test with different Python versions: |
| 190 | + |
| 191 | +```bash |
| 192 | +# Create venv with specific Python version |
| 193 | +python3.9 -m venv venv39 |
| 194 | +python3.10 -m venv venv310 |
| 195 | +python3.11 -m venv venv311 |
| 196 | + |
| 197 | +# Activate the one you want |
| 198 | +source venv39/bin/activate |
| 199 | +pip install -e ".[dev]" |
| 200 | +pytest |
| 201 | +``` |
| 202 | + |
| 203 | +## IDE Setup |
| 204 | + |
| 205 | +### VSCode |
| 206 | + |
| 207 | +1. Install Python extension |
| 208 | +2. Select interpreter: `Cmd+Shift+P` → "Python: Select Interpreter" |
| 209 | +3. Choose `./venv/bin/python` |
| 210 | + |
| 211 | +Add to `.vscode/settings.json`: |
| 212 | +```json |
| 213 | +{ |
| 214 | + "python.defaultInterpreterPath": "${workspaceFolder}/venv/bin/python", |
| 215 | + "python.terminal.activateEnvironment": true, |
| 216 | + "python.formatting.provider": "black", |
| 217 | + "python.linting.enabled": true, |
| 218 | + "python.linting.ruffEnabled": true |
| 219 | +} |
| 220 | +``` |
| 221 | + |
| 222 | +### PyCharm |
| 223 | + |
| 224 | +1. File → Settings → Project → Python Interpreter |
| 225 | +2. Click gear icon → Add |
| 226 | +3. Select "Existing environment" |
| 227 | +4. Choose `venv/bin/python` |
| 228 | + |
| 229 | +## Daily Development Workflow |
| 230 | + |
| 231 | +```bash |
| 232 | +# 1. Activate venv |
| 233 | +source venv/bin/activate |
| 234 | + |
| 235 | +# 2. Make your changes |
| 236 | +# ... edit code ... |
| 237 | + |
| 238 | +# 3. Run tests |
| 239 | +pytest |
| 240 | + |
| 241 | +# 4. Format code |
| 242 | +black src/ tests/ examples/ |
| 243 | + |
| 244 | +# 5. Check linting |
| 245 | +ruff check src/ tests/ examples/ |
| 246 | + |
| 247 | +# 6. Type check |
| 248 | +mypy src/ |
| 249 | + |
| 250 | +# 7. When done |
| 251 | +deactivate |
| 252 | +``` |
| 253 | + |
| 254 | +## Running Examples |
| 255 | + |
| 256 | +```bash |
| 257 | +# Activate venv |
| 258 | +source venv/bin/activate |
| 259 | + |
| 260 | +# Run example |
| 261 | +python examples/brl_onramp_example.py |
| 262 | +``` |
| 263 | + |
| 264 | +## Updating Dependencies |
| 265 | + |
| 266 | +```bash |
| 267 | +# Activate venv |
| 268 | +source venv/bin/activate |
| 269 | + |
| 270 | +# Update Python dependencies |
| 271 | +pip install --upgrade -e ".[dev]" |
| 272 | + |
| 273 | +# Update Node.js dependencies |
| 274 | +npm update |
| 275 | +``` |
| 276 | + |
| 277 | +## Clean Start |
| 278 | + |
| 279 | +If you encounter issues, start fresh: |
| 280 | + |
| 281 | +```bash |
| 282 | +# Remove virtual environment |
| 283 | +rm -rf venv |
| 284 | + |
| 285 | +# Remove Python build artifacts |
| 286 | +rm -rf build/ dist/ *.egg-info src/*.egg-info |
| 287 | + |
| 288 | +# Remove Node.js dependencies |
| 289 | +rm -rf node_modules package-lock.json |
| 290 | + |
| 291 | +# Start over |
| 292 | +python3 -m venv venv |
| 293 | +source venv/bin/activate |
| 294 | +pip install --upgrade pip setuptools wheel |
| 295 | +npm install |
| 296 | +pip install -e ".[dev]" |
| 297 | +``` |
| 298 | + |
| 299 | +## Best Practices |
| 300 | + |
| 301 | +1. **Always use venv** - Never install packages globally or with sudo |
| 302 | +2. **Activate before working** - Always activate venv before development |
| 303 | +3. **Keep it updated** - Regularly update pip and dependencies |
| 304 | +4. **Test in clean environment** - Occasionally test in a fresh venv |
| 305 | +5. **Don't commit venv** - The `venv/` directory is in `.gitignore` |
| 306 | + |
| 307 | +## Additional Resources |
| 308 | + |
| 309 | +- [Python Virtual Environments](https://docs.python.org/3/tutorial/venv.html) |
| 310 | +- [Homebrew Python Guide](https://docs.brew.sh/Homebrew-and-Python) |
| 311 | +- [pip User Guide](https://pip.pypa.io/en/stable/user_guide/) |
0 commit comments