Development Setup
Complete guide to setting up your development environment for FilterMate plugin development.
Prerequisitesβ
Required Softwareβ
- QGIS 3.x (Latest LTS recommended)
- Python 3.7+ (comes with QGIS)
- Git for version control
- Code Editor (VS Code, PyCharm, or similar)
Optional Dependenciesβ
- psycopg2 for PostgreSQL backend development
- pytest for running tests
- black for code formatting
Initial Setupβ
1. Clone Repositoryβ
# Clone the repository
git clone https://github.com/sducournau/filter_mate.git
cd filter_mate
2. Link to QGIS Plugins Directoryβ
Linux:
ln -s $(pwd) ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/filter_mate
Windows:
mklink /D "%APPDATA%\QGIS\QGIS3\profiles\default\python\plugins\filter_mate" "%CD%"
macOS:
ln -s $(pwd) ~/Library/Application\ Support/QGIS/QGIS3/profiles/default/python/plugins/filter_mate
3. Install Dependenciesβ
PostgreSQL Support (Recommended)β
# Using pip
pip install psycopg2-binary
# Or using QGIS Python console
import pip
pip.main(['install', 'psycopg2-binary'])
Testing Dependenciesβ
pip install -r tests/requirements-test.txt
Development Workflowβ
Compiling UI Filesβ
After modifying .ui files in Qt Designer:
Linux/macOS:
./compile_ui.sh
Windows:
compile_ui.bat
Manual compilation:
pyuic5 filter_mate_dockwidget_base.ui -o filter_mate_dockwidget_base.py
pyrcc5 resources.qrc -o resources.py
Running Testsβ
# Run all tests
pytest tests/ -v
# Run specific test file
pytest tests/test_backends.py -v
# Run with coverage
pytest tests/ --cov=modules --cov-report=html
# Run performance benchmarks
python tests/benchmark_simple.py
Debuggingβ
Using QGIS Python Consoleβ
- Open QGIS
- Go to Plugins β Python Console
- Use
print()statements in your code - Reload plugin:
qgis.utils.reloadPlugin('filter_mate')
Using VS Codeβ
- Install "Python" extension
- Configure
.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "QGIS Python",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost"
}
]
}
- Add to your code:
import debugpy
debugpy.listen(5678)
debugpy.wait_for_client()
Project Structureβ
filter_mate/
βββ filter_mate.py # Plugin entry point
βββ filter_mate_app.py # Main application
βββ filter_mate_dockwidget.py # UI management
βββ config/
β βββ config.json # Configuration
β βββ config.py # Config loader
βββ modules/
β βββ appTasks.py # Async tasks
β βββ appUtils.py # Utilities
β βββ backends/ # Backend implementations
β βββ ... # Other modules
βββ tests/ # Unit tests
βββ docs/ # Documentation
βββ website/ # Docusaurus site
Common Tasksβ
Creating a Releaseβ
# Create release ZIP
python create_release_zip.py
# Output: filter_mate_vX.Y.Z.zip
Building Documentationβ
cd website
npm install
npm run build
Code Formattingβ
# Format code with black
black modules/ tests/
# Check formatting
black --check modules/ tests/
Troubleshootingβ
Plugin Not Loadingβ
- Check QGIS Python console for errors
- Verify symbolic link is correct
- Ensure
metadata.txtis present - Check plugin path in QGIS settings
Import Errorsβ
- Ensure all dependencies are installed in QGIS Python environment
- Use QGIS's Python interpreter, not system Python
UI Not Updatingβ
- Recompile UI files with
compile_ui.sh - Restart QGIS
- Clear QGIS cache:
~/.local/share/QGIS/QGIS3/cache/
Best Practicesβ
- Always test locally before committing
- Run unit tests after changes
- Follow code style guidelines
- Update documentation for new features
- Use feature branches for development