migrate pyqt5 to pyside6

This commit is contained in:
ykcheungab
2026-09-21 09:34:56 +08:00
parent e276b5de0f
commit ccedb9ddd9
66 changed files with 2184 additions and 395 deletions
+13 -2
View File
@@ -237,12 +237,19 @@ $install += @($PyInstallerPin, $CvPin)
& $VenvPy @install
if ($LASTEXITCODE -ne 0) { throw "pip install failed" }
# Upstream `orisys` may declare opencv-python; the app needs the headless wheel (PyQt owns
# Upstream `orisys` may declare opencv-python; the app needs the headless wheel (PySide6 owns
# the GUI), and 5.x can arrive without a `cv2` module.
& $VenvPy -m pip uninstall -y opencv-python opencv-python-headless 2>$null | Out-Null
& $VenvPy -m pip install --disable-pip-version-check -c $Constraints $CvPin
if ($LASTEXITCODE -ne 0) { throw "opencv-python-headless install failed" }
# PyQt5 must not be in the build environment, even though the SDK's `gui` extra asks for it
# when someone installs that: `pyqtgraph` binds to whichever toolkit it imports first, and a
# frozen app built where PyQt5 is present can end up with plots built from the wrong binding.
# The apps are PySide6-only (see apps/studio/tests/test_binding_purity.py).
Write-Host "Removing any other Qt binding from the build venv ..."
& $VenvPy -m pip uninstall -y PyQt5 PyQt5-Qt5 PyQt5-sip PyQt6 PySide2 2>$null | Out-Null
# Open3D must not be in the build env: it is an offline tool, and the spec excludes it.
$hasOpen3d = & $VenvPy -c "import importlib.util; print(importlib.util.find_spec('open3d') is not None)"
if ($hasOpen3d -eq "True") {
@@ -256,8 +263,12 @@ if (-not $NoVerify) {
Write-Host "Verifying the provisioned environment ..."
# These are the imports the frozen app makes before it can draw anything. Checking them
# here is what turns "the build succeeded" into "the build can start".
& $VenvPy -c "import orisys_app_shared, orisys_studio, orisys, OpenGL, cv2, PyQt5.QtWidgets, PyInstaller; print('imports OK')"
& $VenvPy -c "import orisys_app_shared, orisys_studio, orisys, OpenGL, cv2, PySide6.QtWidgets, PySide6.QtOpenGLWidgets, PyInstaller; print('imports OK')"
if ($LASTEXITCODE -ne 0) { throw "the venv cannot import what the app imports (see above)" }
# A second binding in the venv is the failure mode the uninstall above exists for: it
# imports fine here and breaks `pyqtgraph` at run time.
& $VenvPy -c "import importlib.util as u; bad=[m for m in ('PyQt5','PyQt6','PySide2') if u.find_spec(m)]; assert not bad, 'another Qt binding is installed: '+str(bad); print('binding OK: PySide6 only')"
if ($LASTEXITCODE -ne 0) { throw "the build venv has more than one Qt binding" }
# Theme colours are package data: PyInstaller only bundles them if the package is
# importable at build time, so a stale editable install loses them silently.
& $VenvPy -c "from PyInstaller.utils.hooks import collect_data_files as c; d=c('orisys_app_shared', includes=['theme/*.json']); assert d, 'theme data not collectable'; print('theme data OK:', len(d), 'files')"