Skip to content

SG-45276 Surface real Qt import failures and prioritize PySide by Python version - #1136

Merged
julien-lang merged 10 commits into
masterfrom
ticket/SG-45110-log-pyside6-import-error
Oct 1, 2026
Merged

julien-lang merged 10 commits into
masterfrom
ticket/SG-45110-log-pyside6-import-error

Conversation

@julien-lang

@julien-lang julien-lang commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Problem

When PySide2 and PySide6 both fail to import, QtImporter only logged "No Qt matching that interface was found." at debug level, discarding the actual ImportError for 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.
QtImporter also 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_modules now 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 ImportError is 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

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.

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.

🟡 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 control sys.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.

Comment thread python/tank/util/qt_importer.py
Comment thread python/tank/util/qt_importer.py
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.09%. Comparing base (889c1cd) to head (439a212).

Files with missing lines Patch % Lines
python/tank/util/qt_importer.py 75.00% 4 Missing ⚠️

❌ 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     
Flag Coverage Δ
Linux 79.53% <75.00%> (-0.01%) ⬇️
Python-3.10 79.93% <68.75%> (+0.02%) ⬆️
Python-3.11 79.80% <68.75%> (-0.01%) ⬇️
Python-3.13 79.80% <68.75%> (-0.01%) ⬇️
Python-3.9 79.90% <68.75%> (+0.02%) ⬆️
Windows 79.56% <75.00%> (-0.01%) ⬇️
macOS 79.50% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@julien-lang
julien-lang marked this pull request as ready for review September 15, 2026 19:56
@julien-lang
julien-lang removed the request for review from chenm1adsk September 16, 2026 15:49

@carlos-villavicencio-adsk carlos-villavicencio-adsk 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.

LGTM

@julien-lang julien-lang changed the title SG-45110 Surface real Qt import failures and prioritize PySide by Python version SG-45276 Surface real Qt import failures and prioritize PySide by Python version Sep 16, 2026
@julien-lang
julien-lang merged commit 6faa8c7 into master Oct 1, 2026
29 checks passed
@julien-lang
julien-lang deleted the ticket/SG-45110-log-pyside6-import-error branch October 1, 2026 14:54
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.

4 participants