Skip to content

fix: resolve QGIS Python interpreter on macOS app bundles#77

Merged
giswqs merged 3 commits into
mainfrom
fix/macos-qgis-python-executable
May 5, 2026
Merged

fix: resolve QGIS Python interpreter on macOS app bundles#77
giswqs merged 3 commits into
mainfrom
fix/macos-qgis-python-executable

Conversation

@giswqs

@giswqs giswqs commented May 5, 2026

Copy link
Copy Markdown
Member

Summary

  • On macOS QGIS, sys.executable can point to the QGIS app binary, so _find_python_executable previously fell back to that path and dependency installs launched a second QGIS process instead of running Python.
  • Search the QGIS.app bundle (Contents/MacOS, Contents/Frameworks/Python.framework/Versions/.../bin) and validate that candidates look like a Python interpreter before returning them.
  • Raise a clear RuntimeError when no Python interpreter can be located, instead of silently returning the QGIS binary as a fallback.

Test plan

  • pre-commit run --all-files
  • New tests in qgis_geoagent/tests/test_settings_diagnostics.py cover the macOS bundle resolution and the no-Python error path
  • Manual smoke test on a macOS QGIS install

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.
Copilot AI review requested due to automatic review settings May 5, 2026 19:52
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request May 5, 2026 19:54 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread qgis_geoagent/open_geoagent/deps_manager.py Outdated
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.
@github-actions github-actions Bot temporarily deployed to pull request May 5, 2026 19:57 Inactive
- 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.
@github-actions github-actions Bot temporarily deployed to pull request May 5, 2026 19:59 Inactive
@giswqs giswqs merged commit 8e6ae53 into main May 5, 2026
9 checks passed
@giswqs giswqs deleted the fix/macos-qgis-python-executable branch May 5, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants