Repository navigation
SG-45276 Surface real Qt import failures and prioritize PySide by Python version - #1136
Conversation
Diagnostic only: surfaces the actual underlying exception (e.g. missing shared libraries) instead of silently swallowing it, so failures are visible in the doc build log.
…irst Toolkit ships PySide2 for Python <= 3.10 and PySide6 for Python > 3.10 (tk-internal/app_store/requirements.txt). Previously PySide2 was always attempted first, so every Toolkit bootstrap on Python > 3.10 logged a doomed ImportError for a binding that was never expected to be installed.
…w logs Python 3.11 should prioritize PySide6 (no PySide2 wheels from 3.11 on), not PySide2. Also clarify the comment/docstring and switch the new debug log calls to f-strings.
Previously, when no Qt binding could be imported, only a debug-level message was logged (invisible without debug logging enabled), and the specific per-binding failure reasons (e.g. missing libEGL vs binding not installed) were only available at debug level too. Now a warning is always logged summarizing why each attempted binding failed, and the final generic 'nothing found' fallback is now a warning as well.
There was a problem hiding this comment.
🟡 Changes recommended
Update selection tests and preserve diagnostics for QT5/QT6 import failures.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates QtImporter to prioritize Qt bindings by Python version and improve import-failure diagnostics.
Changes:
- Prioritizes PySide2 or PySide6 based on Python version.
- Logs and summarizes failed Qt import attempts.
File summaries
| File | Summary |
|---|---|
python/tank/util/qt_importer.py |
Implements version-based binding ordering and failure logging. |
Review details
Suppressed comments (1)
python/tank/util/qt_importer.py:382
- The version-dependent order and fallback path are not covered by the existing QT4 tests: those tests depend on the installed bindings and assert PySide2 whenever it is present, so they do not verify PySide6-first on Python 3.11+ or retrying PySide2 after an
ImportError. Add mocked tests that controlsys.version_info, force each attempt to succeed/fail, and assert the order and diagnostics so this central selection logic cannot regress unnoticed.
if sys.version_info < (3, 11):
# VFX Reference Platform CY2023 and earlier: PySide2/Qt5
attempts = (
("PySide2", self._import_pyside2_as_pyside),
("PySide6", self._import_pyside6_as_pyside),
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (75.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1136 +/- ##
==========================================
- Coverage 80.09% 80.09% -0.01%
==========================================
Files 203 203
Lines 19537 19540 +3
==========================================
+ Hits 15649 15651 +2
- Misses 3888 3889 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ts, capture QT5/QT6 import failures
Problem
When PySide2 and PySide6 both fail to import,
QtImporteronly logged"No Qt matching that interface was found."at debug level, discarding the actualImportErrorfor each binding. This made it very hard to diagnose real environment issues (e.g. missing native shared libraries needed by PySide6 on Rundeck) since the underlying error was never surfaced.QtImporteralso always tried PySide2 before PySide6, regardless of the running Python version, even though the VFX Reference Platform pairs newer Python versions with PySide6/Qt6.Fix
_import_modulesnow tries the PySide binding most likely to succeed first, based on the running Python version and the VFX Reference Platform's Python/Qt pairing heuristic (PySide2 first below Python 3.11, PySide6 first at 3.11+), falling back to the other binding if the first attempt fails.Each import attempt's
ImportErroris now logged (including a full traceback at debug level), and if every attempt fails, a single warning is logged summarizing all the failures instead of a generic message with no detail.Testing
Used to diagnose and confirm the Rundeck native shared-library failures (missing
libdbus-1.so.3,libEGL.so.1, etc.) blocking PySide6 imports during tk-internal's Sphinx doc build job.Jira: SG-45276
Related: SG-45110