{"library":"pyobjc-framework-fsevents","title":"PyObjC FSEvents Framework","description":"This library provides Python wrappers for the macOS FSEvents framework, allowing applications to monitor file system events efficiently. It is part of the larger PyObjC project, which bridges Python and the Objective-C runtime on macOS. The project follows macOS SDK updates closely, often releasing new versions with each major OS release, and is currently at version 12.1.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-fsevents"],"cli":null},"imports":["from FSEvents import FSEventStreamCreate","import objc"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import objc\nfrom FSEvents import (\n    FSEventStreamCreate,\n    FSEventStreamScheduleWithRunLoop,\n    FSEventStreamStart,\n    FSEventStreamStop,\n    FSEventStreamRelease,\n    kFSEventStreamEventFlagNone,\n    kFSEventStreamEventFlagFileEvents,\n    kFSEventStreamCreateFlagUseCFTypes\n)\nfrom Foundation import CFRunLoopGetCurrent, CFRunLoopRunInMode, kCFRunLoopDefaultMode, CFRunLoopStop\n\ndef my_callback(streamRef, clientCallBackInfo, numEvents, eventPaths, eventFlags, eventIds):\n    print(f\"Detected {numEvents} events:\")\n    for i in range(numEvents):\n        path = eventPaths[i]\n        flags = eventFlags[i]\n        print(f\"  Path: {path}, Flags: {flags}\")\n\n\npath_to_monitor = \"./temp_monitor_dir\" # Change to a directory you want to monitor\nimport os\nif not os.path.exists(path_to_monitor):\n    os.makedirs(path_to_monitor)\n\n\ncb = objc.selector(my_callback, signature='v@iiii@*Q')\n\nstream = FSEventStreamCreate(\n    None, # allocator\n    cb, # callback\n    None, # context\n    [path_to_monitor], # pathsToWatch (array of CFStringRef)\n    0, # sinceWhen\n    1.0, # latency\n    kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamEventFlagFileEvents # flags\n)\n\nif stream is None:\n    print(\"Failed to create FSEventStream\")\nelse:\n    print(f\"Monitoring '{path_to_monitor}' for file system events. Press Ctrl+C to stop...\")\n    runLoop = CFRunLoopGetCurrent()\n    FSEventStreamScheduleWithRunLoop(stream, runLoop, kCFRunLoopDefaultMode)\n    FSEventStreamStart(stream)\n\n    try:\n        # Run the run loop for a short period, or forever for continuous monitoring\n        # For this example, we'll run for a fixed time or until stopped by user\n        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 30.0, False) # Run for 30 seconds\n    except KeyboardInterrupt:\n        print(\"\\nStopping monitoring...\")\n    finally:\n        FSEventStreamStop(stream)\n        FSEventStreamRelease(stream)\n        CFRunLoopStop(runLoop)\n        print(\"FSEventStream stopped and released.\")\n\n\n# Clean up the temporary directory if created by this script\n# if os.path.exists(path_to_monitor):\n#     os.rmdir(path_to_monitor)\n","lang":"python","description":"This quickstart demonstrates how to use `pyobjc-framework-fsevents` to monitor a specified directory for file system events. It sets up an `FSEventStream` with a Python callback function and schedules it on the current thread's `CFRunLoop`. It will monitor for 30 seconds or until a `KeyboardInterrupt` occurs. Remember that `pyobjc-framework-fsevents` is macOS-specific.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.5,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-fsevents","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}