pyblish / pyblish-qml

Pyblish QML frontend for Maya 2013+, Houdini 11+, Nuke 8+ and more
GNU Lesser General Public License v3.0
114 stars 44 forks source link

Pyside2 5.15.1/5.15.2: constant property commentEnabled throws TypeError (WRITE method or NOTIFY signal) #369

Closed OlafHaag closed 3 years ago

OlafHaag commented 3 years ago

Hi! Assume #368 would be solved. Then pyblish_qml.show() throws:

Pyblish: Registered C:\Users\user\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\pyblish_blender\plugins
Setting up Pyblish QML in Blender
uninstalling..
Installing..
Using Python @ 'C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\bin\python.EXE'
Using PyQt5 @ 'C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages'
Targets: default
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages\pyblish_qml\__main__.py", line 6, in <module>
from . import app
File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages\pyblish_qml\app.py", line 12, in <module>
from . import util, compat, control, settings, ipc
File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages\pyblish_qml\control.py", line 16, in <module>
class Controller(QtCore.QObject):
File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\python\lib\site-packages\pyblish_qml\control.py", line 310, in Controller
def commentEnabled(self):
TypeError: A constant property cannot have a WRITE method or a NOTIFY signal.

It's about this line:

    @QtCore.Property(bool, constant=True)
    def commentEnabled(self):
        return "comment" in self.host.cached_context.data

When changing it to @QtCore.Property(bool, constant=False), it works fine! Is it feasible for you to change this 1 line as long as it doesn't cause other issues, and make a new release on PyPI? I really want to fully implement pyblish at work. In the meantime I'd have to fall back on pyblish-lite.

mottosso commented 3 years ago

Thanks for reporting this.

A non-constant comment would be a lie, it is constant. I think the better solution is to find what procedure Qt now actually prefers to use for constant variables. Would you be interested in investigating this? I bet it's not an isolated issue and that other Qt-users around the web has run into it too. The goal is to simply expose this property to QML in a way that leaves it "constant" (i.e. it read-only).

OlafHaag commented 3 years ago

Thanks for the swift reply! It would only be a little white lie, haha! I investigated the issue and it's only related to PySide2 versions 5.15.1 & 5.15.2. The bug was fixed last November, but there hasn't yet been a new release since then. PyQt5 5.15.4 showed no such issue. So there's nothing to do for you here, except for maybe mentioning it in the docs. Close, if you like!

mottosso commented 3 years ago

Ah, perfect. The simplest solution is the one already solved. :) The documentation is right here, dated and searchable. Thanks @OlafHaag

aoblet commented 1 year ago

The fix has been released in 6.1.2.

@mottosso What would be the best approach to handle this issue with branch 5.15 ? (such as in maya 2022)

mottosso commented 1 year ago

This should really only be an issue in the standalone Python you use to run Pyblish QML, because the code running inside of Maya (and Blender too, I would have thought?) doesn't touch QML. So the solution should be the normal expected use of Pyblish QML:

  1. Install a dedicated Python distribution, such as 3.6. Whichever version does not have this bug.
  2. Install PySide or PyQt there
  3. Give both Maya and this external Python distribution access to the pyblish_qml module
  4. Reference the path to the external Python executable in Maya
  5. Profit

https://github.com/pyblish/pyblish-qml#usage

But now I'm curious, how else would you use Pyblish QML? Are you exposing Maya to QML? Are you using mayapy to launch Pyblish QML? 🤔