-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Isolate macOS wheel builds from Homebrew #8497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 28 commits
0fe55d6
fc35fcc
00809a2
06dbfed
5a8373e
140a06e
0961d3d
43c34fc
3e4be4b
0855468
8308bf3
c74a5bd
72d81e2
ec214e4
d1a4f80
6d13704
467f120
c6912f8
96ae15c
01270b5
51e3623
e82b539
904416b
4e35852
681a03b
378df7a
9dc6904
0e3eb70
54f2334
96b898c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,11 +1,34 @@ | ||||
| #!/bin/bash | ||||
| # Define custom utilities | ||||
| # Test for macOS with [ -n "$IS_MACOS" ] | ||||
| if [ -z "$IS_MACOS" ]; then | ||||
| export MB_ML_LIBC=${AUDITWHEEL_POLICY::9} | ||||
| export MB_ML_VER=${AUDITWHEEL_POLICY:9} | ||||
|
|
||||
| # Setup that needs to be done before multibuild utils are invoked | ||||
| PROJECTDIR=$(pwd) | ||||
| if [[ "$(uname -s)" == "Darwin" ]]; then | ||||
| # Safety check - macOS builds require that CIBW_ARCHS is set, and that it | ||||
| # only contains a single value (even though cibuildwheel allows multiple | ||||
| # values in CIBW_ARCHS). | ||||
| if [[ -z "$CIBW_ARCHS" ]]; then | ||||
| echo "ERROR: Pillow macOS builds require CIBW_ARCHS be defined." | ||||
| exit 1 | ||||
| fi | ||||
| if [[ "$CIBW_ARCHS" == *" "* ]]; then | ||||
| echo "ERROR: Pillow macOS builds only support a single architecture in CIBW_ARCHS." | ||||
| exit 1 | ||||
| fi | ||||
|
|
||||
| # Build macOS dependencies in `build/darwin` | ||||
| # Install them into `build/deps/darwin` | ||||
| WORKDIR=$(pwd)/build/darwin | ||||
| BUILD_PREFIX=$(pwd)/build/deps/darwin | ||||
| PLAT=$CIBW_ARCHS | ||||
| else | ||||
| # Build prefix will default to /usr/local | ||||
| WORKDIR=$(pwd)/build | ||||
| PLAT=$CIBW_ARCHS | ||||
| MB_ML_LIBC=${AUDITWHEEL_POLICY::9} | ||||
| MB_ML_VER=${AUDITWHEEL_POLICY:9} | ||||
| fi | ||||
| export PLAT=$CIBW_ARCHS | ||||
|
|
||||
| # Define custom utilities | ||||
| source wheels/multibuild/common_utils.sh | ||||
| source wheels/multibuild/library_builders.sh | ||||
| if [ -z "$IS_MACOS" ]; then | ||||
|
|
@@ -38,35 +61,44 @@ BZIP2_VERSION=1.0.8 | |||
| LIBXCB_VERSION=1.17.0 | ||||
| BROTLI_VERSION=1.1.0 | ||||
|
|
||||
| function build_pkg_config { | ||||
| if [ -e pkg-config-stamp ]; then return; fi | ||||
| # This essentially duplicates the Homebrew recipe: | ||||
| # https://github.com/Homebrew/homebrew-core/blob/master/Formula/p/pkg-config.rb | ||||
radarhere marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| ORIGINAL_CFLAGS=$CFLAGS | ||||
| CFLAGS="$CFLAGS -Wno-int-conversion" | ||||
| build_simple pkg-config 0.29.2 https://pkg-config.freedesktop.org/releases tar.gz \ | ||||
| --disable-debug --disable-host-tool --with-internal-glib \ | ||||
| --with-pc-path=$BUILD_PREFIX/share/pkgconfig:$BUILD_PREFIX/lib/pkgconfig \ | ||||
| --with-system-include-path=$(xcrun --show-sdk-path --sdk macosx)/usr/include | ||||
| CFLAGS=$ORIGINAL_CFLAGS | ||||
| export PKG_CONFIG=$BUILD_PREFIX/bin/pkg-config | ||||
| touch pkg-config-stamp | ||||
| } | ||||
|
|
||||
| function build_brotli { | ||||
| if [ -e brotli-stamp ]; then return; fi | ||||
| local cmake=$(get_modern_cmake) | ||||
| local out_dir=$(fetch_unpack https://github.com/google/brotli/archive/v$BROTLI_VERSION.tar.gz brotli-$BROTLI_VERSION.tar.gz) | ||||
| (cd $out_dir \ | ||||
| && $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \ | ||||
| && $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \ | ||||
| && make install) | ||||
| if [[ "$MB_ML_LIBC" == "manylinux" ]]; then | ||||
| cp /usr/local/lib64/libbrotli* /usr/local/lib | ||||
| cp /usr/local/lib64/pkgconfig/libbrotli* /usr/local/lib/pkgconfig | ||||
| fi | ||||
| touch brotli-stamp | ||||
| } | ||||
|
|
||||
| function build_harfbuzz { | ||||
| if [ -e harfbuzz-stamp ]; then return; fi | ||||
| python3 -m pip install meson ninja | ||||
|
|
||||
| local out_dir=$(fetch_unpack https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION/$HARFBUZZ_VERSION.tar.xz harfbuzz-$HARFBUZZ_VERSION.tar.xz) | ||||
| (cd $out_dir \ | ||||
| && meson setup build --buildtype=release -Dfreetype=enabled -Dglib=disabled) | ||||
| && meson setup build --prefix=$BUILD_PREFIX --libdir=$BUILD_PREFIX/lib --buildtype=release -Dfreetype=enabled -Dglib=disabled) | ||||
| (cd $out_dir/build \ | ||||
| && meson install) | ||||
| if [[ "$MB_ML_LIBC" == "manylinux" ]]; then | ||||
| cp /usr/local/lib64/libharfbuzz* /usr/local/lib | ||||
| fi | ||||
| touch harfbuzz-stamp | ||||
| } | ||||
|
|
||||
| function build { | ||||
| if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then | ||||
| sudo chown -R runner /usr/local | ||||
| fi | ||||
| build_xz | ||||
| if [ -z "$IS_ALPINE" ] && [ -z "$IS_MACOS" ]; then | ||||
| yum remove -y zlib-devel | ||||
|
|
@@ -77,67 +109,88 @@ function build { | |||
| if [ -n "$IS_MACOS" ]; then | ||||
| build_simple xorgproto 2024.1 https://www.x.org/pub/individual/proto | ||||
| build_simple libXau 1.0.11 https://www.x.org/pub/individual/lib | ||||
| build_simple libXdmcp 1.1.5 https://www.x.org/pub/individual/lib | ||||
|
||||
| PyImaging_GrabScreenX11(PyObject *self, PyObject *args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My recollection was that Xdmcp was needed for XCB to compile at all; but I've just removed it and done a clean build, and everything worked as expected (AFAICT). I'll remove it.
radarhere marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
radarhere marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
radarhere marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/builds/unix/configure.raw?ref_type=heads#L429 mentions --with-harfbuzz, but not --without-harfbuzz. What was the thinking here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"--with/--without" handing is a standard feature of autoconf, AFAIK; I think this change got made when I was trying to diagnose some harfbuzz issues. Happy to revert, as it's code churn with no explicit purpose.
radarhere marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -448,7 +448,7 @@ def _remove_extension(self, name: str) -> None: | |
| def get_macos_sdk_path(self) -> str | None: | ||
| try: | ||
| sdk_path = ( | ||
| subprocess.check_output(["xcrun", "--show-sdk-path"]) | ||
| subprocess.check_output(["xcrun", "--show-sdk-path", "--sdk", "macosx"]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the reason for this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitness. Xcode can manage multiple SDKs (iOS being an obvious one); adding the explicit |
||
| .strip() | ||
| .decode("latin1") | ||
| ) | ||
|
|
@@ -606,6 +606,7 @@ def build_extensions(self) -> None: | |
| _add_directory(library_dirs, "/usr/X11/lib") | ||
| _add_directory(include_dirs, "/usr/X11/include") | ||
|
|
||
| # Add the macOS SDK path. | ||
| sdk_path = self.get_macos_sdk_path() | ||
| if sdk_path: | ||
| _add_directory(library_dirs, os.path.join(sdk_path, "usr", "lib")) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.