fix: resolve macOS dependency conflict (#78)

fix: resolve macOS dependency conflict in extras
This commit is contained in:
Xu Lingrui 2026-04-16 20:33:10 +08:00 committed by GitHub
commit 21fb98bb36
6 changed files with 19 additions and 9 deletions

1
.gitignore vendored
View file

@ -17,6 +17,7 @@ Desktop.ini
.vscode/
.idea/
.pytest_cache/
.venv/
# Distribution / packaging
dist/

View file

@ -37,9 +37,11 @@ Set `"mode": "server"` in `openspace/config/config_grounding.json`:
<summary><b>macOS</b></summary>
```bash
pip install pyobjc-core pyobjc-framework-cocoa pyobjc-framework-quartz atomacos
pip install pyobjc-core pyobjc-framework-cocoa pyobjc-framework-quartz
```
> **Note:** `atomacos` is excluded because it requires `pyautogui<0.9.42` (appears unmaintained). Accessibility-tree features are currently unavailable.
**Permissions required** (macOS will prompt automatically on first run):
- **Accessibility** (for GUI control)
- **Screen Recording** (for screenshots and video capture)

View file

@ -5,11 +5,16 @@ from openspace.utils.logging import Logger
try:
import AppKit
import atomacos
MACOS_LIBS_AVAILABLE = True
except ImportError:
MACOS_LIBS_AVAILABLE = False
try:
import atomacos
ATOMACOS_AVAILABLE = True
except ImportError:
ATOMACOS_AVAILABLE = False
logger = Logger.get_logger(__name__)
_warning_shown = False
@ -20,8 +25,10 @@ class MacOSAdapter:
global _warning_shown
if not MACOS_LIBS_AVAILABLE and not _warning_shown:
logger.warning("macOS libraries are not fully installed, some features may not be available")
logger.info("To install missing libraries, run: pip install pyobjc-framework-Cocoa atomacos")
logger.info("To install missing libraries, run: pip install pyobjc-core pyobjc-framework-Cocoa pyobjc-framework-quartz")
_warning_shown = True
if not ATOMACOS_AVAILABLE:
logger.debug("atomacos not installed; accessibility-tree features unavailable (conflicts with pyautogui>=0.9.54)")
self.available = MACOS_LIBS_AVAILABLE
def capture_screenshot_with_cursor(self, output_path: str) -> bool:
@ -163,6 +170,8 @@ class MacOSAdapter:
"""
if not MACOS_LIBS_AVAILABLE:
return {'error': 'macOS accessibility libraries not available'}
if not ATOMACOS_AVAILABLE:
return {'error': 'atomacos is not installed; accessibility-tree features require it'}
try:
# Get frontmost application
@ -177,7 +186,6 @@ class MacOSAdapter:
logger.info(f"Getting accessibility tree: {app_name} ({bundle_id})")
# Use atomacos to get application reference
try:
if bundle_id:
app_ref = atomacos.getAppRefByBundleId(bundle_id)
@ -719,4 +727,4 @@ class MacOSAdapter:
except Exception as e:
logger.error(f"Failed to get terminal output: {e}")
return None
return None

View file

@ -8,7 +8,7 @@ requests>=2.32.0
# pyobjc-core>=12.0; sys_platform == 'darwin'
# pyobjc-framework-cocoa>=12.0; sys_platform == 'darwin'
# pyobjc-framework-quartz>=12.0; sys_platform == 'darwin'
# atomacos>=3.2.0; sys_platform == 'darwin'
# atomacos excluded: requires pyautogui<0.9.42, conflicts with >=0.9.54
# # Linux-specific dependencies (local server)
# python-xlib>=0.33; sys_platform == 'linux'
@ -18,4 +18,4 @@ requests>=2.32.0
# # Windows-specific dependencies (local server)
# pywinauto>=0.6.8; sys_platform == 'win32'
# pywin32>=306; sys_platform == 'win32'
# PyGetWindow>=0.0.9; sys_platform == 'win32'
# PyGetWindow>=0.0.9; sys_platform == 'win32'

View file

@ -35,7 +35,6 @@ macos = [
"pyobjc-core>=12.0",
"pyobjc-framework-cocoa>=12.0",
"pyobjc-framework-quartz>=12.0",
"atomacos>=3.2.0",
]
linux = [

View file

@ -19,7 +19,7 @@ requests>=2.32.0
# pyobjc-core>=12.0; sys_platform == 'darwin'
# pyobjc-framework-cocoa>=12.0; sys_platform == 'darwin'
# pyobjc-framework-quartz>=12.0; sys_platform == 'darwin'
# atomacos>=3.2.0; sys_platform == 'darwin'
# atomacos excluded: requires pyautogui<0.9.42, conflicts with >=0.9.54
# # Linux-specific dependencies (local server)
# python-xlib>=0.33; sys_platform == 'linux'