PyObjC Framework Automator
The `pyobjc-framework-automator` library provides Python wrappers for the macOS Automator framework, enabling Python applications to develop Automator actions and run workflows. It is part of the larger PyObjC bridge, which allows Python scripts to use and extend Objective-C class libraries, notably Apple's Cocoa. The current version is 12.1, released on 2025-11-14. PyObjC maintains an active development pace with several major and minor releases per year, often tied to macOS SDK updates and Python version support changes.
Warnings
- breaking PyObjC 12.0 dropped support for Python 3.9. Projects targeting older Python versions must use an earlier PyObjC version.
- breaking PyObjC 11.0 dropped support for Python 3.8. Projects targeting Python 3.8 must use an earlier PyObjC version.
- breaking PyObjC 11.1 introduced alignment with `clang`'s Automatic Reference Counting (ARC) documentation for initializer methods. This change means methods in the 'init' family now correctly steal a reference to `self` and return a new reference, which may alter memory management behavior in existing code that relies on previous PyObjC reference counting for `init` methods.
- breaking The "IMServicePlugIn" framework bindings were removed in PyObjC 10.0 because the framework was deprecated in macOS 10.13 and completely removed in macOS 14. Code relying on these bindings will no longer function.
- gotcha There was a temporary breaking change in PyObjC 10.3 where calling `__init__` on subclasses of Objective-C classes was broken if the user also implemented `__new__`. While this was partially reverted in 10.3.1 to support `__init__` when a user-implemented `__new__` exists, users relying on PyObjC's provided `__new__` still cannot use `__init__`.
- gotcha As of PyObjC 12.1, Key-Value Observing (KVO) usage is automatically disabled for subclasses of `NSProxy` defined in Python. If your application relies on KVO with Python subclasses of `NSProxy`, this change will affect its behavior.
Install
-
pip install pyobjc-framework-automator
Imports
- AMWorkflow
from Automator import AMWorkflow
- AMWorkflowController
from Automator import AMWorkflowController
Quickstart
import Automator
from Foundation import NSURL, NSArray # Foundation is often used with PyObjC frameworks
# This example confirms that core Automator classes are accessible.
# Actual execution of Automator workflows or creating complex actions
# typically involves a full macOS application context (e.g., via py2app)
# and specific workflow files.
print(f"PyObjC Automator framework version: {Automator.__version__}")
try:
# Check for the presence of key Automator classes
if hasattr(Automator, 'AMWorkflow'):
print(f"Automator.AMWorkflow class found: {Automator.AMWorkflow}")
if hasattr(Automator, 'AMWorkflowController'):
print(f"Automator.AMWorkflowController class found: {Automator.AMWorkflowController}")
# Example: Trying to get system-wide Automator actions (conceptual)
# Note: Requires a running Cocoa event loop in a real application
# or careful setup for console tools.
# For a simple check, we just confirm the class exists.
# AMAction.allActionsWithSearchFor_("PDF") # Requires a real app context.
print("PyObjC Automator framework classes successfully accessed.")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure you are running on macOS and the pyobjc-framework-automator is installed.")