fix: resolve QGIS Python interpreter on macOS app bundles#77
Merged
Conversation
On macOS QGIS, sys.executable can point to the QGIS app binary, which caused dependency installation to launch a second QGIS instead of running Python. _find_python_executable now searches the app bundle and framework layout, validates that candidates look like Python, and raises a clear error instead of silently returning the QGIS binary as a fallback.
|
🚀 Deployed on https://69fa4c30d0549f0fbe63ad83--opengeos.netlify.app |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves dependency installation on macOS QGIS app bundles by ensuring subprocess calls use an actual Python interpreter (not the QGIS.app GUI binary), and by failing fast with a clear error when no suitable interpreter can be found.
Changes:
- Adds Python interpreter name/validation helpers and macOS bundle-specific search paths to
_find_python_executable(). - Updates venv-creation safety checks to rely on the new “looks like Python” predicate.
- Adds tests covering macOS bundle resolution (including
sys._base_executable) and the “no Python found” error path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| qgis_geoagent/open_geoagent/deps_manager.py | Implements stricter Python interpreter discovery (including macOS bundle scanning) and raises when no interpreter can be found. |
| qgis_geoagent/tests/test_settings_diagnostics.py | Adds unit tests for macOS interpreter resolution and the explicit failure mode when only the QGIS binary is available. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated the version number in pyproject.toml, __init__.py, and metadata.txt to reflect the new release. Adjusted dependency installation instructions in README.md and various source files to require GeoAgent 1.5.0. Added changelog entry for minor updates related to macOS dependency installation.
- Filter out falsey prefixes before joining and prefer the public `sys.base_prefix` / `sys.base_exec_prefix` attributes over the internal `sys._base_prefix` when scanning for a non-Windows Python interpreter, so a missing `_base_prefix` no longer turns into a literal "None/bin/python" search relative to CWD. - Patch the new public prefix attributes in the macOS "no Python" test so the failure path stays isolated from the host environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sys.executablecan point to the QGIS app binary, so_find_python_executablepreviously fell back to that path and dependency installs launched a second QGIS process instead of running Python.Contents/MacOS,Contents/Frameworks/Python.framework/Versions/.../bin) and validate that candidates look like a Python interpreter before returning them.RuntimeErrorwhen no Python interpreter can be located, instead of silently returning the QGIS binary as a fallback.Test plan
pre-commit run --all-filesqgis_geoagent/tests/test_settings_diagnostics.pycover the macOS bundle resolution and the no-Python error path