contrib: add a script to build all of the wheels on macOS
This is mostly a translation of `contrib/packaging/build-windows-wheels.bat`,
except the default pythons to build can be inferred from `setup.py` and/or
`pyproject.toml`, and all use the same configuration. All we need to do is
force the building of translation files, tell it to skip pypy wheels, and tell
it to build universal2 wheels instead of for the current architecture.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packaging/build-macos-wheels.sh Fri Nov 15 21:52:31 2024 -0500
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# This is a convenience script to build all of the wheels outside of the CI
+# system. It requires the cibuildwheel package to be installed, and the
+# executable on PATH, as well as `msgfmt` from gettext, which can be installed
+# with `brew` as follows:
+#
+# $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+# $ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
+# <logout>
+# $ brew install gettext
+#
+# A system-wide installation of the version of python corresponding to each
+# wheel is required. They can be installed by this script by setting `CI=true`
+# in the environment before running it, and providing the `sudo` password when
+# prompted.
+
+set -e
+
+# Build translations; requires msgfmt on PATH.
+export MERCURIAL_SETUP_FORCE_TRANSLATIONS=1
+
+if ! which msgfmt 2>/dev/null 1>/dev/null; then
+ echo "msgfmt executable not found" >&2
+ exit 1
+fi
+
+# Prevent building pypy wheels, which is broken.
+export CIBW_SKIP=pp*
+
+export CIBW_ARCHS=universal2
+
+# TODO: purge the repo?
+
+cibuildwheel --output-dir dist/wheels