Has anyone come up with a way to keep your tools compatible between PySide2 and PySide6 in different versions of Maya? I’ve only recently had to upgrade my studio’s tools to be compatible with Maya 2025+ which switched from PySide2 to PySide6. I can’t do a straight update to PySide6 because our tools still need to support lower versions of Maya.
The simple but ugly way I can think of is to wrap PySide imports in try/except statements but this seems so inelegant. I’m only finding tools and guides on how to upgrade to PySide6, but not on how to maintain the codebase to be able to use either library depending on which version of Maya loads the tools.
Find a library that handles the compatibility for you.
At work, we use Qt.py. It’s pip installable, and it’s one file so you can include it in scripts if you can’t pip install.
The latest version handles compatibility between Qt 4, 5, and 6.
I know there are other libraries out there that do similar things, and you should definitely consider them, but I only have personal experience with this one.
And just ‘cause I ran across it today: This is the other popular qt version library I know of (there may be others)
It’s not a single-file solution, so it’d be more difficult to vendor into your tools (if that’s what you wanted to do). It also doesn’t support Qt4, but that’s probably not an issue for you.
I think this one became popular because of early Qt6 adoption compared to Qt.py, but that’s just speculation.
Personally my issue with Qt.py, even though i still use it for its simplicity, is that it still supports qt4.
Nowadays I hit walls more and more that things only qt5 and qt6 support are what i want to use.
Still trying to justify open source work at my company so I could have more say one day xD
I solved this by writing a small compatibility layer—a GUI wrapper that abstracts the PySide differences. The wrapper exposes the common/base widgets through a single API, and for specialized widgets I handle compatibility at the call site. It’s open-sourced but not packaged on PyPI; you can use it directly from source. Supported range: Maya 2017–2025 and Python 2.7–3.12. https://github.com/cpcgskill/cpform
I just saw this: Looks like Qt.py 2.0 has dropped support for Qt4 and python < 3.7
So maybe there’s fewer qt4-isms to get in the way. I haven’t really had time to check.
I’ve used Qt.py in the past. But I don;t think our code base really justifies it. I would prefer to just update all tools to whatever PySide is used by the current project’s Maya version. But then, our code base tends to be project specific. We’re not maintaining 15 year old Maya / PySide tools to be backwards compatible.