forked from pyblish/pyblish-base
-
Notifications
You must be signed in to change notification settings - Fork 1
Writing Integrations
Marcus Ottosson edited this page May 20, 2015
·
3 revisions
This article summarises best practises for developing integrations of Pyblish into hosts, such as Autodesk Maya and SideFx Houdini.
An integration, as opposed to an Extension, is distinguished by providing a host with access to Pyblish facilities, such as launching it's user interface.
Each integration must provide a series of selectors that append data common amongst integrations.
Key | Value |
---|---|
currentFile | The currently opened file |
currentWorkspace | Optional and where relevant, the currently opened workspace or project |
Example
# pyblish-maya/select_current_file.py
import os
import pyblish.api
from maya import cmds
@pyblish.api.log
class SelectCurrentFile(pyblish.api.Selector):
"""Inject the current working file into context."""
hosts = ['maya']
def process_context(self, context):
"""Todo, inject the current working file"""
current_file = cmds.file(sceneName=True, query=True)
# Maya returns forward-slashes by default
normalised = os.path.normpath(current_file)
context.set_data('currentFile', value=normalised)
Any integration with Pyblish must be prefixed with pyblish-
and it's inner Python package with pyblish_
.
Integrations conform to a standard Python distribution directory layout, adopted from setuptools.
pyblish-<hostname>
├── README
├── setup.py
├── pyblish_<hostname>
│ ├── plugins
│ │ └── <plugin>.py
│ └── __init__.py
└── tests
├── __init__.py
└── <test>.py
For example.
pyblish-maya
├── README
├── setup.py
├── pyblish_maya
│ ├── plugins
│ │ └── select_current_file.py
│ └── __init__.py
└── tests
├── __init__.py
└── test_selectors.py
This wiki is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.