PyObjC Framework ExecutionPolicy
PyObjC is a bridge between Python and Objective-C, enabling Python scripts to interact with macOS frameworks and Cocoa libraries. This specific package, `pyobjc-framework-executionpolicy`, provides Python bindings for Apple's ExecutionPolicy framework. It is actively maintained with releases frequently updated to support new macOS SDKs and Python versions. The current version is 12.1.
Warnings
- breaking PyObjC 12.0 dropped support for Python 3.9. Projects using older Python versions must upgrade to 3.10 or newer.
- breaking PyObjC 11.0 dropped support for Python 3.8. Projects using this version must upgrade their Python environment.
- breaking PyObjC 11.1 aligned its Automatic Reference Counting (ARC) behavior for 'init' family methods to strictly follow `clang`'s documentation. This change affects how references to 'self' are managed by initializer methods, which now steal a reference to self and return a new one.
- gotcha PyObjC automatically disables Key-Value Observing (KVO) for subclasses of `NSProxy` defined in Python.
Install
-
pip install pyobjc-framework-executionpolicy
Imports
- ExecutionPolicy
from ExecutionPolicy import *
Quickstart
import objc
from Foundation import NSString, NSLog
from ExecutionPolicy import *
def main():
# Example using Foundation, as direct ExecutionPolicy framework usage
# often requires specific macOS context and knowledge of its APIs.
hello_string = NSString.stringWithString_("Hello from PyObjC and ExecutionPolicy context!")
NSLog("%@", hello_string)
# To interact with the ExecutionPolicy framework, you would typically
# call specific functions or instantiate classes from the 'ExecutionPolicy'
# module, according to Apple's documentation for the framework.
# For example, if a function 'EPCopyAssessmentInfo' exists:
# try:
# info = EPCopyAssessmentInfo("/Applications/Safari.app")
# NSLog("Assessment Info: %@", info)
# except Exception as e:
# NSLog("Could not get assessment info: %@", str(e))
if __name__ == "__main__":
main()