Installing pyobjc-core on a non-macOS platform fails with:
Collecting pyobjc-core==6.1 Downloading pyobjc-core-6.1.tar.gz (791 kB) ... ERROR: Command errored out with exit status 1: command: ... Complete output (2 lines): running egg_info error: PyObjC requires macOS to build
While this if of course reasonable because pyobjc is only meant for macOS, it can cause problems for projects when trying to pin dependencies (e.g. using pip freeze, pip-tools, or pipenv)
For example, consider a library
foolib that is multi-platform, but requires
pyobjc-core as a dependency (and even restricts pyobjc’s installation to only macOS with
; sys_platform == "darwin") If one was on macOS and wanted to pin dependencies with
foolib, they may use:
$ pip install foolib $ pip freeze > requirements.txt $ cat requirements.txt foolib==1.0 pyobjc-core==6.1
However, if a Linux user (or CI system) takes their requirements.txt file and tries to install it with
pip install -r requirements.txt, it would fail because pyobjc raises an error.
(in our case, someone on macOS added a requirement that uses pyobjc as a downstream dependency and broke CI)
On the user’s end, a quick fix is to manually edit the requirements.txt (or requirements.in, Pipfile, etc.) to explicitly add
pyobjc-core ; sys_platform == "darwin" as a requirement and ensure it doesn’t get installed on non-macOS platforms.
For pyobjc, a more robust solution would be to allow installation on non-macOS platforms (and not compile anything) but raise an error at runtime when trying to use the library on non-macOS platforms.