Add one-click Easy-Install for automatic dependency management#439
Add one-click Easy-Install for automatic dependency management#439yvann-ba wants to merge 2 commits intosemiautomaticgit:masterfrom
Conversation
Add a complete dependency auto-installer that downloads and configures all required Python packages (remotior-sensus, scipy, scikit-learn, matplotlib, torch CPU, torchvision) in an isolated virtual environment. On plugin load, a fast filesystem check determines if dependencies are present. If missing, a lightweight stub plugin shows a non-blocking install dialog that handles the full setup in a background thread: - Downloads a standalone Python matching the QGIS version - Downloads the uv package installer for faster installs - Creates an isolated venv at ~/.scp_dependencies/ - Batch-installs all packages (2 commands via uv, fallback to pip) - Verifies each package after installation - Handles SSL errors, proxy settings, antivirus blocks, and more The previous remotior_sensus-only download mechanism in semiautomaticclassificationplugin.py is replaced by this unified approach that covers all dependencies. New files: core/scp_config.py - Configuration constants core/python_manager.py - Standalone Python download core/uv_manager.py - uv package installer download core/venv_manager.py - Venv creation, install, verification core/install_dialog.py - Non-blocking Qt6 install dialog Modified files: __init__.py - Stub plugin pattern with dep gating semiautomaticclassificationplugin.py - Simplified RS import metadata.txt - Changelog entry requirements.txt - Complete dependency list Easy-Install feature contributed by TerraLab (https://terralab.fr)
|
@semiautomaticgit hope you're doing well, just ping your username in case you didn't see this pr, have a great day |
|
Dear @yvann-ba , first of all thank you very much for your work, it is much appreciated! However I have a few concerns about your current approach, mainly around how the virtual environment is integrated into QGIS at runtime. The main point is that the current implementation modifies Python import-related state (e.g., sys.path, sys.modules) inside the running QGIS process. In particular:
Additionally, I would like to highlight a separate security concern regarding the use of flags such as From a QGIS architecture perspective, a potentially safer direction could be to isolate dependency execution via a subprocess-based approach using the venv Python interpreter. This would avoid modifying the running QGIS interpreter state, although I realize it would likely require a more substantial refactor of the current execution flow. Thanks again for the contribution, and happy to discuss further. |
Summary
This PR adds a complete one-click dependency auto-installer (Easy-Install) that automatically downloads and configures all required Python packages in an isolated virtual environment when the plugin is first loaded.
Problem
Users currently need to manually install scipy, scikit-learn, matplotlib, torch, and torchvision before using SCP. The existing mechanism only handles remotior-sensus via a tarball download. This is a significant barrier for non-technical users.
Solution
~/.scp_dependencies/What's included
5 new files in
core/:scp_config.pypython_manager.pyuv_manager.pyvenv_manager.pyinstall_dialog.pyModified files:
__init__.pysemiautomaticclassificationplugin.pymetadata.txtrequirements.txtKey design decisions
SCP_CACHE_DIRenvironment variableCompatibility
Test plan
~/.scp_dependencies/, start QGIS → stub shows → click Install → all deps install → restart QGIS → plugin loads normallyINSTALL_LOGIC_VERSION→ restart → verify re-install triggersEasy-Install feature contributed by TerraLab