Registry / observability / pyobjc-framework-metrickit

pyobjc-framework-metrickit

JSON →
library12.2pypypiunverified

This package provides Python bindings for the MetricKit framework on macOS, allowing Python applications to access Apple's system for collecting power and performance metrics. It is part of the larger PyObjC project, which provides comprehensive Objective-C bridge functionality. The library is actively maintained, with new versions often aligning with macOS SDK updates and Python releases.

pip install pyobjc-framework-metrickit
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-M
P
pyobjc-framework-metrickit
observabilitypythonv12.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MXMetricManager
from MetricKit import MXMetricManager
MXDiagnosticPayload
from MetricKit import MXDiagnosticPayload
MXMetricPayload
from MetricKit import MXMetricPayload

This quickstart demonstrates how to import and access the shared `MXMetricManager` instance, which is the entry point for MetricKit. MetricKit is primarily designed for macOS applications or extensions to submit performance and diagnostic metrics to Apple. While you can access its symbols in a script, active data collection and submission usually require an application context.

import objc from MetricKit import MXMetricManager from Foundation import NSLog # Used for Objective-C style logging def get_metrickit_manager(): """ Retrieves the shared MetricKit manager instance. MetricKit is used for collecting power and performance metrics from an app. Note: This is primarily designed for macOS apps/extensions to submit data to Apple, not typically for standalone console scripts to actively collect and process. """ manager = MXMetricManager.sharedManager() NSLog(f"MetricKit Shared Manager: {manager}") # In a full application, you would typically add a subscriber (an NSObject subclass) # manager.addSubscriber_(my_subscriber_instance) return manager if __name__ == "__main__": print("Attempting to get MetricKit manager...") manager = get_metrickit_manager() if manager: print(f"Successfully retrieved MetricKit manager: {manager}") else: print("Failed to retrieve MetricKit manager.")
Debug
Known issues
breakingPyObjC 12.0 dropped support for Python 3.9. Projects targeting older Python versions must use an older PyObjC release (e.g., PyObjC 11.x for Python 3.9).
fix
Upgrade your Python environment to 3.10 or later, or pin pyobjc-framework-metrickit to a version less than 12.0 (e.g., `pyobjc-framework-metrickit<12`).
affects: >=12.0
breakingPyObjC 11.0 dropped support for Python 3.8. Users on Python 3.8 need to use PyObjC 10.x or earlier.
fix
Upgrade your Python environment to 3.9 or later, or pin pyobjc-framework-metrickit to a version less than 11.0 (e.g., `pyobjc-framework-metrickit<11`).
affects: >=11.0
breakingPyObjC 11.1 introduced significant changes to how initializer methods are handled, aligning the core bridge with clang's Automatic Reference Counting (ARC) documentation. Methods in the 'init' family now correctly steal a reference to self and return a new reference, which can affect custom memory management or interactions with `alloc`.
fix
Review any custom `__init__` or `__new__` implementations, especially those interacting directly with Objective-C `alloc` or `init` patterns, and ensure ARC semantics are respected. In most cases, standard Python usage should be unaffected.
affects: >=11.1
gotchaIn PyObjC 10.3, calling `__init__` was initially restricted for classes implementing `__new__`, causing breaks in some projects. While partially re-introduced in 10.3.1, users defining custom `__new__` methods should be cautious, as the behavior around `__init__` might still differ from older PyObjC versions or standard Python class initialization.
fix
If encountering issues with `__init__` not being called correctly after `__new__`, consider if your `__new__` method is returning an Objective-C object directly or relying on PyObjC's `__new__` implementation. Review PyObjC 10.3/10.3.1 release notes for specific scenarios.
affects: >=10.3, <10.3.2
gotchaMetricKit is designed for deep integration into macOS applications or extensions to report metrics to Apple. While its APIs are exposed, successfully collecting and submitting metrics usually requires running within an appropriate application context with an `NSApplication` runloop, rather than a simple command-line Python script. Payloads are delivered asynchronously.
fix
If developing a macOS app, integrate MetricKit into your application delegate or relevant lifecycle hooks. For testing purposes in scripts, understand that payloads might not be delivered, or the environment might not fully support MetricKit's intended operation. Use `PyObjCTools.AppHelper.runConsoleEventLoop()` to keep a console application alive for callbacks if needed.
affects: All
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredProvides the core bridge between Python and Objective-C, required for all PyObjC framework bindings.
pyobjc-framework-FoundationrequiredMetricKit depends on core Foundation classes like NSObject and NSLog.
pyobjc-framework-libdispatchrequiredRequired for dispatch-related functionality.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
3
Resources
pyobjc-framework-metrickit — pip install pyobjc-framework-metrickit · libregistry