Registry / type-stubs / pyobjc-framework-osakit

pyobjc-framework-osakit

JSON →
library12.2pypypiunverified

PyObjC is a bridge between Python and the Objective-C runtime, enabling Python scripts to interact with Apple's Cocoa frameworks. This specific package, `pyobjc-framework-osakit`, provides Python bindings for the OSAKit framework on macOS, allowing for the creation, compilation, and execution of AppleScripts and other scripting components. The current version is 12.1. Releases are frequent, often correlating with new macOS SDKs and Python version support changes.

pip install pyobjc-framework-osakit
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-O
P
pyobjc-framework-osakit
type-stubspythonv12.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.

OSAKit
import OSAKit
The OSAKit framework bindings are directly imported as a top-level module named `OSAKit`.
Foundation
import Foundation
Often required for basic Objective-C data types like `NSDictionary` used in error handling or other common operations.

This quickstart demonstrates how to use `pyobjc-framework-osakit` to programmatically compile and execute a simple AppleScript. It initializes an `OSAScript` object with source code, attempts to compile it, and if successful, executes it. Error handling follows the common PyObjC pattern using `NSDictionary` to capture Objective-C errors.

import OSAKit import Foundation import os # Source for a simple AppleScript script_source = """ display dialog "Hello from PyObjC OSAKit!" with title "PyObjC" return "AppleScript executed successfully." """ try: # Create an OSAScript instance script = OSAKit.OSAScript.alloc().initWithSource_(script_source) # Prepare an error dictionary (Objective-C style error handling) error = Foundation.NSDictionary.dictionary() # Compile the script compiled = script.compileAndReturnError_(error) if not compiled: print(f"Error compiling script: {error}") else: print("Script compiled successfully.") # Execute the script result_desc, error_exec = script.executeAndReturnError_(error) if error_exec: print(f"Error executing script: {error_exec}") else: # OSADisplayResult is often an NSAppleEventDescriptor, use stringValue() to get Python string print(f"Script output: {result_desc.stringValue()}") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingPyObjC 12.0 (and thus `pyobjc-framework-osakit` 12.0) dropped support for Python 3.9. Ensure your project uses Python 3.10 or newer.
fix
Upgrade your Python environment to 3.10 or later.
affects: >=12.0
breakingPyObjC 11.0 dropped support for Python 3.8. Ensure your project uses Python 3.9 or newer.
fix
Upgrade your Python environment to 3.9 or later.
affects: >=11.0
gotchaObjective-C method selectors with colons (e.g., `someMethod:withArgument:`) are translated to Python methods using underscores (e.g., `someMethod_withArgument_`). Remember to add a trailing underscore for single-argument methods.
fix
When calling Objective-C methods, replace colons in the selector with underscores and append an underscore if the original selector ends with one (i.e., takes an argument). Example: `alloc().initWithSource_(source)`.
affects: all
gotchaPyObjC 11.1 aligned the core bridge's behavior with `clang`'s Automatic Reference Counting (ARC) documentation for initializer methods. Methods in the 'init' family now correctly steal a reference to `self` and return a new reference, which might affect reference counting in specific, complex scenarios.
fix
Review code that interacts closely with Objective-C object lifecycle, especially `alloc` and `init` methods, to ensure correct reference management under the new ARC model.
affects: >=11.1
gotchaIn PyObjC 10.3, the ability to use `__init__` in Python classes that also implement `__new__` (or inherit from a class that implements it) was temporarily broken, but later reintroduced in 10.3.1. However, classes relying on `PyObjC`'s default `__new__` still cannot use `__init__`.
fix
If implementing custom `__new__` methods in PyObjC-bridged classes, be mindful of how `__init__` is called. For classes using PyObjC's `__new__`, `__init__` is generally not supported for object creation.
affects: >=10.3
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredThis package provides the core bridging functionality between Python and Objective-C, upon which all PyObjC framework wrappers are built.
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
pyobjc-framework-osakit — pip install pyobjc-framework-osakit · libregistry