Thanks for pinging me!
I definitely looked into this recently, however I never tried to trigger a Pyblish interface in that standalone process. Also I never really used Pyblish-lite either, but run Pyblish-QML.
Anyway, you can test whether the pyblish functionality works in the standalone maya mode by running:
import pyblish.util
context = pyblish.util.publish()
print(context)
Of course you can read out the returned context for errors/printed data and alike to check whether it succeeded.
If that all works, then we know your pyblish plug-ins are set and the maya functionality works too and we’ve found that it is a problem with Pyblish-lite. I believe Pyblish-lite will try to install itself into the host using the local Qt library found, which will be Maya’s Qt which I’m not sure will run correctly when in standalone mode. It should be able to though, just not sure.
Anyway, so I quickly tried Pyblish QML through mayapy.exe
and found two issues:
- Whenever you run
pyblish_qml.show()
prior to maya.standalone.initialize()
then you will get the following error:
>>> import pyblish_qml
>>> pyblish_qml.show()
Setting up Pyblish QML in Maya
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "P:\pipeline\2.1_dev\git\avalon-setup\git\pyblish-qml\pyblish_qml\__init__.py", line 16, in show
return host.show(parent, targets, modal, auto_publish, auto_validate)
File "P:\pipeline\2.1_dev\git\avalon-setup\git\pyblish-qml\pyblish_qml\host.py", line 97, in show
install(modal)
File "P:\pipeline\2.1_dev\git\avalon-setup\git\pyblish-qml\pyblish_qml\host.py", line 68, in install
install_host(use_threaded_wrapper)
File "P:\pipeline\2.1_dev\git\avalon-setup\git\pyblish-qml\pyblish_qml\host.py", line 242, in install_host
install(use_threaded_wrapper)
File "P:\pipeline\2.1_dev\git\avalon-setup\git\pyblish-qml\pyblish_qml\host.py", line 526, in _install_maya
if cmds.about(version=True) == "2018":
AttributeError: 'module' object has no attribute 'about'
As such the error originates from this line since Maya has not been initialized yet and does not have the functions available in maya.cmds
, as such maya.cmds.about
does not exist yet.
This is resolved by first running:
import maya.standalone
maya.standalone.initialize()
Which you’ll likely need to do before you can really run any decent Maya commands anyway, as such to also have your pyblish plug-ins run correctly.
- Qt runs into a Dead lock when executing in the main thread of
mayapy.exe
, see:
>>> import pyblish_qml
>>> pyblish_qml.show()
Setting up Pyblish QML in Maya
Setting up Pyblish QML in Maya
uninstalling..
Installing..
pyblish_qml.host : INFO : Headless host
Using Python @ 'P:/pipeline/2.1_dev/bin/windows/python36\python.exe'
Using PyQt5 @ 'None'
Targets: default, local
pyblish_qml.host : INFO : Success. QML server available as pyblish_qml.api.current_server()
<pyblish_qml.ipc.server.Server object at 0x0000025E2476CD68>
>>> Starting pyblish-qml
Done, don't forget to call `show()`
Entering state: "hidden"
Entering state: "ready"
Entering state: "clean"
Entering state: "alive"
Settings:
WindowPosition = [100, 100]
WindowSize = [430, 600]
HiddenSections = ['Collect']
HeartbeatInterval = 60
WindowTitle = Pyblish (Maya)
ContextLabel = Maya
Qt: Dead lock detected while activating a BlockingQueuedConnection: Sender is TmainThreadScriptExecutor(0x25e23f917a0), receiver is TmainThreadScriptExecutor(0x25e23f917a0)
So Pyblish-QML does try to start and actually pops up but instantly hangs as soon as it tries to push a command back into the Mayapy process, using this maya.utils.executeInMainThreadWithResult
. This might be fixed by recognizing correctly that it’s a Maya standalone process and using another method of evaluating in the local process in that case.
Pyblish-Lite however does not function that way and just runs the code locally. As such, Pyblish-lite should work - but I haven’t tested it.