Registry / data / pyobjc-framework-sensitivecontentanalysis

pyobjc-framework-sensitivecontentanalysis

JSON →
library12.2pypypiunverified

PyObjC-framework-SensitiveContentAnalysis provides Python wrappers for Apple's macOS SensitiveContentAnalysis framework (macOS 14.0+). This framework enables apps to check images and videos for nudity, supporting features like Sensitive Content Warning and Communication Safety parental controls. The library is part of the larger PyObjC project, which acts as a bridge between Python and Objective-C, allowing Python applications to leverage macOS's native Cocoa APIs. Version 12.1 is the latest release, with regular updates aligning with macOS SDK changes and Python versions.

pip install pyobjc-framework-sensitivecontentanalysis
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-S
P
pyobjc-framework-sensitivecontentanalysis
datapythonv12.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.

SCSensitivityAnalyzer
from SensitiveContentAnalysis import SCSensitivityAnalyzer
Main class for analyzing sensitive content in images and videos.
SCSensitivityAnalysis
from SensitiveContentAnalysis import SCSensitivityAnalysis
Class representing the results of a content sensitivity check.

This quickstart demonstrates how to initialize `SCSensitivityAnalyzer` and call its `analyzeCGImage_completionHandler_` method. It includes a critical warning about the required `com.apple.developer.sensitivecontentanalysis.client` entitlement, which is a common footgun and necessary for the framework to function correctly. Without this entitlement, the analysis will likely fail or return no sensitive results. Due to the nature of the framework, a real `CGImage` object is needed, which would typically be obtained via a graphics framework like `Quartz` (e.g., `Quartz.CGImageSourceCreateWithURL`). The example uses a placeholder for brevity.

import SensitiveContentAnalysis import objc from PyObjCTools import AppHelper # NOTE: For SensitiveContentAnalysis to return positive results, # your macOS application MUST be signed with the # 'com.apple.developer.sensitivecontentanalysis.client' entitlement. # This is typically added via Xcode capabilities, not Python code. # Without it, analysis might always return 'None' or errors like 'User Safety not enabled'. # Placeholder for a CGImage. In a real app, you'd load this # from a file (e.g., using Quartz.CGImageSourceCreateWithURL). # For a runnable example, we define a dummy function. def create_dummy_cgimage(): # In a real application, you would load a CGImage from a file or buffer. # This is a conceptual placeholder. print("\n--- Placeholder: Create a dummy CGImage ---") print("In a real app, load an image using e.g., Quartz.CGImageSourceCreateWithURL.") # A real CGImage object from a framework like Quartz would be passed here. # For demonstration, we'll return None and assume external setup. return None # Replace with an actual CGImage object def analysis_completion_handler(result, error): if error: print(f"Analysis Error: {error}") if 'User Safety either not entitled' in str(error): print("HINT: Ensure your app has the 'com.apple.developer.sensitivecontentanalysis.client' entitlement.") elif result: print(f"Sensitive Content Analysis Result: {result.isSensitive()}") if result.isSensitive(): print("Intervention guidance:", result.interventionPolicy()) else: print("No result or error provided.") AppHelper.stopEventLoop() def perform_analysis(): image = create_dummy_cgimage() if image is None: print("Cannot proceed without a real CGImage object. Please set up image loading.") return analyzer = SensitiveContentAnalysis.SCSensitivityAnalyzer.alloc().init() analyzer.analyzeCGImage_completionHandler_(image, analysis_completion_handler) if __name__ == '__main__': print("Starting SensitiveContentAnalysis example...") # To run this in a context where the framework actually works, # you'd typically embed it in a py2app created application bundle # that has the necessary entitlements. AppHelper.callAfter(perform_analysis) AppHelper.runEventLoop() print("SensitiveContentAnalysis example finished.")
Debug
Known issues
gotchaThe SensitiveContentAnalysis framework requires a specific code-signing entitlement (`com.apple.developer.sensitivecontentanalysis.client`) for your macOS application bundle to return meaningful results. Without this entitlement, the framework may not detect sensitive content or may return errors indicating 'User Safety not enabled'. This entitlement must be added via Xcode capabilities, not programmatically in Python.
fix
Ensure your macOS application's `Info.plist` includes the `com.apple.developer.sensitivecontentanalysis.client` entitlement. Typically, this is managed by enabling the 'Sensitive Content Analysis' capability in Xcode.
affects: All versions (macOS 14.0+ requirement)
breakingPyObjC 12.0 dropped support for Python 3.9. Projects targeting older Python versions should use PyObjC 11.x or earlier. PyObjC 11.0 dropped support for Python 3.8.
fix
Upgrade your Python environment to 3.10 or later for PyObjC 12.x, or to 3.9 or later for PyObjC 11.x. Always check `requires_python` in PyPI for specific version compatibility.
affects: 12.0+
breakingPyObjC 11.1 introduced changes to how `init` family methods (constructors) handle object references, aligning with `clang`'s Automatic Reference Counting (ARC) documentation. This means `[NSObject alloc]` proxies now correctly model that `init` methods steal a reference to `self` and return a new one. Incorrect usage in previous versions, which might have accidentally worked, could now lead to crashes.
fix
Review `init` method calls, particularly if manually managing object lifecycles or seeing unexpected crashes during object initialization. The more Pythonic `SomeClass(...)` constructor form (introduced in PyObjC 10.3) is generally safer than `SomeClass.alloc().init()`.
affects: 11.1+
gotchaThere was a change in PyObjC 10.3 regarding `__init__` not being called when a user implements `__new__`. While PyObjC 10.3.1 partially reintroduced the ability to use `__init__` in such cases, code relying on the PyObjC-provided `__new__` still cannot use `__init__`.
fix
If your Python classes subclass Objective-C classes and implement `__new__`, be aware of this interaction. If `__init__` is not being called as expected, consider restructuring your class or explicitly calling `__init__` where appropriate, or rely on the `SomeClass(...)` constructor style introduced in PyObjC 10.3 for a more consistent experience.
affects: 10.3, 10.3.1+
deprecatedThe `isAlloc` attribute of `objc.selector` is deprecated and will be removed in PyObjC 12. This attribute was related to internal reference counting mechanisms that are no longer used by the bridge.
fix
Avoid using `objc.selector.isAlloc` in your code. Replace with alternative checks if necessary, or update your code to rely on PyObjC's modern object handling.
affects: 10.0 - 11.x (removal in 12.0)
breakingPyObjC 12.1 automatically disables Key-Value Observing (KVO) usage for subclasses of `NSProxy` defined in Python. If your application relies on KVO with such custom proxy classes, this change will prevent it from working as before.
fix
If you have Python-defined subclasses of `NSProxy` that use KVO, you may need to refactor your code to avoid KVO on these specific classes or find alternative observation mechanisms.
affects: 12.1+
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredThis package provides the core Python-Objective-C bridge functionality, which is essential for all PyObjC framework wrappers.
Agent activity
9 hits · last 30 days
node
6
OpenAI (training)
2
Resources
pyobjc-framework-sensitivecontentanalysis — pip install pyobjc-framework-sensitivecontentanalysis · libregistry