PyObjC Framework MetalFX
PyObjC Framework MetalFX provides Python wrappers for Apple's MetalFX framework on macOS. It enables Python developers to interact with MetalFX APIs, which are part of Apple's graphics technologies for upscaling, anti-aliasing, and other visual effects. The library is part of the broader PyObjC project, which bridges Python and Objective-C, offering bindings to most macOS Objective-C frameworks. Version 12.1 was released in November 2025 and the project maintains an active release cadence, typically aligning with macOS SDK updates.
Warnings
- breaking PyObjC 12.0 (and thus its framework wrappers) dropped support for Python 3.9. Projects must upgrade to Python 3.10 or later. PyObjC 11.0 dropped Python 3.8 support.
- gotcha PyObjC 11.1 introduced significant changes to how initializer methods (`init` family) are handled, aligning with `clang`'s Automatic Reference Counting documentation. Incorrect handling of `self` reference stealing in initializers can lead to unexpected behavior.
- gotcha While PyObjC 11.0 introduced experimental support for Python 3.13's free-threading (PEP 703), PyObjC itself does not currently support this experimental feature. Using PyObjC with free-threading enabled in Python 3.13 may lead to instability.
- gotcha In PyObjC 10.3, support for calling `__init__` in Python subclasses when a user-defined `__new__` was present was temporarily dropped, breaking some projects. This was partially reintroduced in 10.3.1, but code relying on PyObjC's provided `__new__` still cannot use `__init__`.
- breaking The `IMServicePlugIn` framework bindings were removed entirely in PyObjC 10.0, as the framework was deprecated in macOS 10.13 and removed in macOS 14. Code relying on these bindings will fail.
Install
-
pip install pyobjc-framework-metalfx
Imports
- MetalFX
import MetalFX
Quickstart
import Foundation
import MetalFX
# Basic import to verify the MetalFX framework bindings are accessible.
print(f"MetalFX module imported: {MetalFX}")
# Attempt to access a known class from the MetalFX framework
# (e.g., MTLFXTemporalScaler is a prominent class in MetalFX for temporal upscaling)
# Note: Actual usage requires a Metal-compatible GPU and specific setup.
try:
MTLFXTemporalScaler = MetalFX.MTLFXTemporalScaler
print(f"Successfully accessed MetalFX.MTLFXTemporalScaler: {MTLFXTemporalScaler}")
print(f"Objective-C class name: {MTLFXTemporalScaler.className()}")
except AttributeError:
print("Could not find MTLFXTemporalScaler, perhaps due to SDK version or framework availability.")
print("Verify your macOS SDK supports the class or check PyObjC documentation for alternatives.")
# Example showing interaction with a common Foundation class (often used alongside other frameworks)
NSObject = Foundation.NSObject
class MyPythonObject(NSObject):
def init(self):
self = super().init()
if self:
print("MyPythonObject (subclassing Foundation.NSObject) initialized!")
return self
my_obj = MyPythonObject.alloc().init()