Force usage of 10.x wheel in MacOS Big Sur

Viewed 769

I've recently upgraded my MacOS to Big Sur. When I try to install Python packages using pip no wheel is found and everything is forced to be built from source resulting in very slow installation and, worst, many installation errors because of limitations of the build environment. Check for instance https://pypi.org/simple/numpy/. Given that I'm using Python 3.8, the closest available wheel is numpy-1.19.4-cp38-cp38-macosx_10_9_x86_64.whl. I would like to force pip using these wheels for macosx_10_9 and see what happens. Do you know of any way to achieve that?

1 Answers

I'm answering to myself with a workaround to force the platform, for example for numpy:

pip install --platform macosx_10_9_x86_64 --only-binary=:all: --target=/usr/local/lib/python3.8/site-packages numpy

Sadly the --target option is necessary although there are plans to remove this requirement (https://github.com/pypa/pip/issues/5453).

I've requested that pip takes macosx_10_9 as valid for Big Sur in https://github.com/pypa/pip/issues/9138, but I guess the probability that this proposal will be rejected is high.

I don't know how long it takes for new wheels to be built for a new platform, but I assume the workaround is good enough in the meantime.


A second, dirtier but more convenient hack is to override version_str:

    version_str, _, cpu_arch = platform.mac_ver()  # type: ignore
    version_str = "10.15.1"

in site-packages/pip/_vendor/packaging/tags.py

Related