Development Setup¶
This guide covers setting up your development environment for Species Explorer.
Prerequisites¶
- Git for version control
- QGIS 3.0+ or Nix for QGIS provision
- Python 3.9+
- Nix (recommended) for reproducible environment
Setup with Nix (Recommended)¶
1. Install Nix¶
If you don't have Nix installed:
Enable flakes in your Nix configuration:
2. Clone the Repository¶
3. Enter Development Shell¶
This provides:
- Python environment with all dependencies
- QGIS
- Code quality tools (black, flake8, isort, pylint)
- Testing tools (pytest, coverage)
- Documentation tools (mkdocs)
- Pre-commit hooks
4. Allow direnv (Optional)¶
If you use direnv:
The environment will activate automatically when entering the directory.
Setup without Nix¶
1. Clone the Repository¶
2. Create Virtual Environment¶
3. Install Dependencies¶
4. Install QGIS¶
Install QGIS 3.x from your system package manager or qgis.org.
Plugin Symlink¶
To test the plugin in QGIS, create a symlink:
Or use the Nix command:
IDE Setup¶
Neovim¶
The repository includes .exrc and .nvim.lua for Neovim integration:
- WhichKey shortcuts under
<leader>p - LSP configuration with Pyright
- DAP debugging support
VS Code¶
Recommended extensions:
- Python
- Pylance
- QGIS Plugin Development
Create .vscode/settings.json:
{
"python.analysis.extraPaths": [
"/usr/share/qgis/python",
"/usr/share/qgis/python/plugins"
],
"python.formatting.provider": "black",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true
}
PyCharm¶
- Set Python interpreter to your QGIS Python
- Add QGIS Python paths to project structure
- Enable Black formatter
Pre-commit Hooks¶
Install pre-commit hooks:
Run checks manually:
Or using Nix:
Compile Resources¶
If you modify resources.qrc:
Running Tests¶
Building Documentation¶
Troubleshooting¶
QGIS Python Not Found¶
Add QGIS to your Python path:
Pre-commit Fails¶
- Ensure all tools are installed
- Run
pre-commit cleanand try again - Check specific hook errors
Tests Fail¶
- Ensure QGIS is properly configured
- Check that all dependencies are installed
- Run with
-vfor verbose output