Bundle PyObjc with Présentation.app
The problem
The pyobjc bindings that comes with the OS are ancient and buggy. The AVFoundation frameworks raises an exception when imported and is not properly exposed to python:
% python
Python 2.7.16 (default, Feb 29 2020, 01:55:37)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import objc
>>> objc.__version__
'2.5.1'
>>> import AVFoundation
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py:674: RuntimeWarning: Error parsing BridgeSupport data for AVFoundation: PyObjCRT_SkipTypeSpec: Unhandled type '5d' ]}
warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
That's why constants have to be defined by hand.
That's also why functions expecting callback can not be used.
To update movie playback slider, we have to rely on a timer instead of the proper AVPlayer.addPeriodicTimeObserverForInterval:queue:usingBlock:
method.
We can not use the AVCaptureDevice.requestAccessForMediaType:completionHandler:
method, and thus the video stream can not be used from the app unless launching it from the command line (see #91 (closed)).
Way forward
I have tried to fix the bindings in app, but without luck. The author of pyobjc is not very optimistic [0] that it can be done.
So we will probably have to bite the bullet and provide a more recent version of pyobjc alongside the app. This would be a radical change since Présentation.app have been a standalone script for a long time, only disguising as an app (it can be run as a simple script from the command line).
If we do that, it's also probably a good time to switch to python3 only (the source is py/py3 at some cost), since python3 is shipped with Catalina (without pyobjc).
Open questions
- Should we keep 2 versions (python2 for pre-Catalina vs. python3+objc for Catalina+)?
- Should we use py2app or a simpler venv/makefile based solution?