PyObjC Framework InstallerPlugins

12.1 · active · verified Tue Apr 14

PyObjC is a bridge between Python and Objective-C, enabling Python scripts to interact with macOS frameworks and Cocoa libraries. The `pyobjc-framework-installerplugins` package provides Python wrappers specifically for the InstallerPlugins framework, which allows developers to extend the macOS installation process with custom steps and UI. The current version is 12.1, and PyObjC generally follows a release cadence tied to macOS SDK updates and Python version support, with major versions often introducing significant changes or dropping older Python support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `InstallerPlugins` framework and define a basic Objective-C compatible class in Python. Actual usage as an Installer Plugin requires a specific project structure, Objective-C class definition patterns, and bundling into a `.bundle` within an installer package, typically managed with tools like `py2app` and proper `InstallerSections.plist` configuration. This example focuses on the Python-side import and class definition.

from Foundation import NSObject
import objc
import InstallerPlugins

class MyCustomInstallerSection(NSObject):
    # The 'alloc().init()' pattern is standard for Objective-C object creation.
    # Python methods often use trailing underscores for Objective-C selector arguments.
    
    # Example: Defining a method that an Installer Plugin might call.
    # In a real plugin, you would override specific methods like 'initWithSection_'.
    @objc.python_method
    def myPluginMethod_(self, installerSection):
        print(f"My custom installer plugin method called by: {installerSection}")
        # You'd typically interact with installerSection here
        return True

# This simple script demonstrates importing the framework and defining a class.
# A real Installer Plugin requires specific project structure and bundling
# (e.g., using py2app) to be loaded by the macOS Installer.app.
if __name__ == '__main__':
    print("InstallerPlugins framework imported successfully.")
    # Instantiate the class (though it won't be 'used' without Installer.app)
    plugin_instance = MyCustomInstallerSection.alloc().init()
    print(f"Instance created: {plugin_instance}")
    # Demonstrate calling a custom method (for illustrative purposes)
    # In practice, the macOS Installer would call specific methods on your plugin.
    # Replace 'None' with a mock InstallerSection object if testing interaction.
    plugin_instance.myPluginMethod_(None)

view raw JSON →