ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
563 stars 47 forks source link

pyobjc-framework-ApplicationServices crashes on import without pyobjc-framework-CoreText but does not include Python dependency metadata about it #581

Closed glyph closed 11 months ago

glyph commented 11 months ago

Describe the bug

pyobjc-framework-ApplicationServices should install_requires pyobjc-framework-CoreText, since pip install-ing it by itself causes an error.

Platform information

3.11.6

python.org

To Reproduce

In a new virtualenv:

$ pip install pyobjc-framework-ApplicationServices
Looking in indexes: http://127.0.0.1:3141/root/plus/+simple/
Collecting pyobjc-framework-ApplicationServices
  Downloading http://127.0.0.1:3141/root/pypi/%2Bf/ebb/e656c8b1a8fb3/pyobjc_framework_ApplicationServices-10.0-cp311-cp311-macosx_10_9_universal2.whl (33 kB)
Collecting pyobjc-core>=10.0 (from pyobjc-framework-ApplicationServices)
  Downloading http://127.0.0.1:3141/root/pypi/%2Bf/99b/72cda4593e0c6/pyobjc_core-10.0-cp311-cp311-macosx_10_9_universal2.whl (738 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 738.6/738.6 kB 583.6 MB/s eta 0:00:00
Collecting pyobjc-framework-Cocoa>=10.0 (from pyobjc-framework-ApplicationServices)
  Downloading http://127.0.0.1:3141/root/pypi/%2Bf/018/7cba228976a45/pyobjc_framework_Cocoa-10.0-cp311-cp311-macosx_10_9_universal2.whl (391 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 391.2/391.2 kB 599.5 MB/s eta 0:00:00
Collecting pyobjc-framework-Quartz>=10.0 (from pyobjc-framework-ApplicationServices)
  Downloading http://127.0.0.1:3141/root/pypi/%2Bf/528/48a5e283a508c/pyobjc_framework_Quartz-10.0-cp311-cp311-macosx_10_9_universal2.whl (230 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 230.6/230.6 kB 629.3 MB/s eta 0:00:00
Installing collected packages: pyobjc-core, pyobjc-framework-Cocoa, pyobjc-framework-Quartz, pyobjc-framework-ApplicationServices
Successfully installed pyobjc-core-10.0 pyobjc-framework-ApplicationServices-10.0 pyobjc-framework-Cocoa-10.0 pyobjc-framework-Quartz-10.0
$ python -c 'import ApplicationServices'          
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/glyph/.virtualenvs/tmp-571af869e15bf2/lib/python3.11/site-packages/ApplicationServices/__init__.py", line 31, in <module>
    globals().pop("_setup")()
  File "/Users/glyph/.virtualenvs/tmp-571af869e15bf2/lib/python3.11/site-packages/ApplicationServices/__init__.py", line 10, in _setup
    import CoreText
ModuleNotFoundError: No module named 'CoreText'
$ pip install pyobjc-framework-CoreText           
Looking in indexes: http://127.0.0.1:3141/root/plus/+simple/
Collecting pyobjc-framework-CoreText
  Downloading http://127.0.0.1:3141/root/pypi/%2Bf/c8e/c3d634b440b53/pyobjc_framework_CoreText-10.0-cp311-cp311-macosx_10_9_universal2.whl (32 kB)
Requirement already satisfied: pyobjc-core>=10.0 in ./.virtualenvs/tmp-571af869e15bf2/lib/python3.11/site-packages (from pyobjc-framework-CoreText) (10.0)
Requirement already satisfied: pyobjc-framework-Cocoa>=10.0 in ./.virtualenvs/tmp-571af869e15bf2/lib/python3.11/site-packages (from pyobjc-framework-CoreText) (10.0)
Requirement already satisfied: pyobjc-framework-Quartz>=10.0 in ./.virtualenvs/tmp-571af869e15bf2/lib/python3.11/site-packages (from pyobjc-framework-CoreText) (10.0)
Installing collected packages: pyobjc-framework-CoreText
Successfully installed pyobjc-framework-CoreText-10.0
$ python -c 'import ApplicationServices'
$ 

Expected behavior

I would not expect to see those tracebacks.

ronaldoussoren commented 11 months ago

Thanks for the report! This was the only significant missing requirement, but I found some more when scanning for the issue:

* pyobjc-framework-ApplicationServices depends on pyobjc-framework-CoreText but doesn't require it
* pyobjc-framework-CoreServices depends on pyobjc-framework-Cocoa but doesn't require it
* pyobjc-framework-ScreenCaptureKit depends on pyobjc-framework-Cocoa but doesn't require it
* pyobjc-framework-libdispatch depends on pyobjc-framework-Cocoa but doesn't require it
* pyobjc-framework-libxpc depends on pyobjc-framework-Cocoa but doesn't require it