Install fails on non-macOS platforms

Issue #291 wontfix
Flynn created an issue

Summary

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)

Solution

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.

Comments (4)

  1. Ronald Oussoren repo owner

    I won’t change pyobjc to install on other platforms because that will result in support calls by folks that have installed the package but cannot use it. The solution is as you say: adjust your requirements file.

    I’m keeping this issue open because I want to check if I can tweak the package metadata to tell pip that this package won’t install on platforms other than macOS.

  2. Flynn reporter

    Yeah if there’s a way to tell pip to gracefully not install pyobjc that would be preferred. I don’t know a way off the top of my head.

    Manually adjusting the requirements file is not a great solution because it can surprise users who install a package that installs pyobjc downstream. This seems to be happening to a few users over at watchdog.

    (thanks for maintaining this library and the quick reply!!)

  3. Ronald Oussoren repo owner

    I’ve checked what pywin32 does, which is a Windows only library, and that fails to install on anything but Windows.

    They avoid any problems with trying to compile the extension from source by not providing sdists on PyPI. I could do that, but prefer to ship the sources corresponding to releases next to Python wheels.

  4. Ronald Oussoren repo owner

    Closing this issue as "wont fix" because there's no good solution and I prefer the status quo over the proposed change.

  5. Log in to comment