villsim/.cursor/rules/00-python-env.mdc

30 lines
1016 B
Plaintext

---
description: "Ensure Python is always run via the project's .venv virtual environment"
globs: ["**/*.py", "**/*"]
alwaysApply: true
---
# Python Environment Rule
## Context
- Applies to all Python files and commands in the VillSim project.
## Requirements
1. **Always use the virtual environment** located at `.venv/` for running Python scripts.
2. Activate with: `source .venv/bin/activate` (Unix/macOS) before running any Python commands.
3. When running Python files, use: `python` (after activation) or `.venv/bin/python` directly.
4. Install dependencies with: `.venv/bin/pip install -r requirements.txt`.
5. Never use system Python - all scripts, tests, and tasks must use the `.venv` interpreter.
## Examples
<example>
**Valid:**
- `source .venv/bin/activate && python backend/main.py`
- `.venv/bin/python tools/run_headless_analysis.py`
- `.venv/bin/pip install -r requirements.txt`
**Invalid:**
- `python backend/main.py` (using system Python)
- `pip install package` (using system pip)
</example>