2.4 KiB
2.4 KiB
Development Setup
Prerequisites
- Python 3.12 or higher
- Redis server (for caching)
- Git
Development Installation
-
Clone and enter the repository:
git clone https://github.com/micha-zone/random-access.git cd random-access -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install development dependencies:
pip install -e .[dev] -
Set up environment configuration:
cp .env.template .env # Edit .env with your specific configuration -
Start Redis (if not running):
# On Ubuntu/Debian: sudo systemctl start redis-server # On macOS with Homebrew: brew services start redis # Using Docker: docker run -d -p 6379:6379 redis:alpine
Development Workflow
Code Quality Checks
# Format code
black src/ tests/
isort src/ tests/
# Lint code
ruff check src/ tests/
# Type checking
mypy src/
# Run all quality checks
black src/ tests/ && isort src/ tests/ && ruff check src/ tests/ && mypy src/
Testing
# Run tests
pytest
# Run tests with coverage
pytest --cov=random_access --cov-report=html
# Run specific test file
pytest tests/test_security.py
Running the Application
# Development server with auto-reload
random-access-server
# Or with uvicorn directly
uvicorn random_access.main:app --reload --host 0.0.0.0 --port 8000
Building the Package
# Build source and wheel distributions
python -m build
# Install from local build
pip install dist/random_access-*.whl
IDE Configuration
VS Code
Recommended extensions:
- Python
- Pylance
- Black Formatter
- isort
- Ruff
PyCharm
The project includes proper pyproject.toml configuration that PyCharm will automatically recognize.
Troubleshooting
Common Issues
- Redis connection errors: Ensure Redis is running on localhost:6379
- Import errors: Make sure you've installed the package in development mode (
pip install -e .) - Permission errors: Check file permissions and virtual environment activation
Environment Variables
Key environment variables (see .env.template):
ENVIRONMENT: Set to "development" for dev modeREDIS_URL: Redis connection stringAIRTABLE_API_KEY: Your Airtable API keyAIRTABLE_BASE_ID: Your Airtable base ID