Skip to content

Commit

Permalink
build-wheel: build only universal2 wheels on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotduarte committed Dec 30, 2024
1 parent 962861d commit 0a21bdb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ jobs:
include = [
{"os": "ubuntu-latest", "arch": "x86_64", "tag": "cp3*-manylinux_x86_64"},
{"os": "windows-latest", "arch": "x86_64", "tag": "cp3*-win_amd64"},
{"os": "macos-13", "arch": "x86_64", "tag": "cp3{9,10}-macosx_x86_64"},
{"os": "macos-14", "arch": "arm64", "tag": "cp3{11,12,13}-macosx_arm64"},
{"os": "macos-13", "arch": "universal2", "tag": "cp3{9,10,11}-macosx_universal2"},
{"os": "macos-14", "arch": "universal2", "tag": "cp3{12,13}*-macosx_universal2"},
]
if "${{ github.event_name }}" != "pull_request":
include += [
{"os": "ubuntu-latest", "arch": "x86_64", "tag": "cp3*-musllinux_x86_64"},
{"os": "ubuntu-latest", "arch": "arm64", "tag": "cp3*-manylinux_aarch64"},
{"os": "ubuntu-latest", "arch": "arm64", "tag": "cp3*-musllinux_aarch64"},
{"os": "ubuntu-latest", "arch": "ppc64le", "tag": "cp3*-manylinux_ppc64le"},
{"os": "macos-14", "arch": "universal2", "tag": "cp3{11,12,13}-macosx_universal2"},
]
with open(os.environ["GITHUB_OUTPUT"], "a+") as f:
print("data="+json.dumps({"include": include}), file=f)
Expand Down
12 changes: 6 additions & 6 deletions ci/build-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ PY_VERSION_NODOT=$($PYTHON -c "import sysconfig; print(sysconfig.get_config_var(
PYTHON_TAG=cp$PY_VERSION_NODOT
if [[ $PY_PLATFORM == linux* ]]; then
PLATFORM_TAG=many$(echo $PY_PLATFORM | sed 's/\-/_/')
PLATFORM_TAG_MASK=$(echo $PLATFORM_TAG | sed 's/_/*_/')
PLATFORM_TAG_MASK="$(echo $PLATFORM_TAG | sed 's/_/*_/')"
if ! [ "$CI" == "true" ] && which podman >/dev/null; then
export CIBW_CONTAINER_ENGINE=podman
fi
else
PLATFORM_TAG=$(echo $PY_PLATFORM | sed 's/\-/_/')
PLATFORM_TAG_MASK=$(echo $PLATFORM_TAG | sed 's/_/*/')
PLATFORM_TAG_MASK="$(echo $PLATFORM_TAG | sed 's/_/*/')"
fi

# Usage
Expand All @@ -42,7 +42,7 @@ while ! [ -z "$1" ]; do
BUILD_TAG=""
fi
else
BUILD_TAG=$1
BUILD_TAG="$1"
fi
shift
done
Expand Down Expand Up @@ -91,13 +91,13 @@ fi
echo "::group::Build wheel(s)"
if [ "$BUILD_TAG" == "--only" ]; then
DIRTY=$(_bump_my_version show scm_info.dirty)
FILEMASK=cx_Freeze-$VERSION_OK-$PYTHON_TAG-$PYTHON_TAG-$PLATFORM_TAG_MASK
FILEEXISTS=$(ls wheelhouse/$FILEMASK.whl 2>/dev/null || echo '')
FILEMASK="cx_Freeze-$VERSION_OK-$PYTHON_TAG-$PYTHON_TAG-$PLATFORM_TAG_MASK"
FILEEXISTS=$(ls "wheelhouse/$FILEMASK.whl" 2>/dev/null || echo '')
if [ "$DIRTY" != "False" ] || [ -z "$FILEEXISTS" ]; then
if [[ $PY_PLATFORM == win* ]]; then
uv build --no-build-isolation --wheel -o wheelhouse
else
_cibuildwheel --only $PYTHON_TAG-$PLATFORM_TAG
_cibuildwheel --only "$PYTHON_TAG-$PLATFORM_TAG"
fi
fi
elif ! [ -z "$BUILD_TAG" ]; then
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,11 @@ optional_value = "final"

[tool.cibuildwheel]
before-build = "uv pip install -r requirements.txt"
build = "cp3*"
build-frontend = "build[uv]"
build-verbosity = 1
skip = [
"cp3{9,10,13}-musllinux_*",
"cp3{9,10,13}-manylinux_ppc64le",
"cp3{9,10}-macosx_{universal2,arm64}",
]

[tool.cibuildwheel.linux]
Expand All @@ -179,7 +177,7 @@ cd /opt/_internal && tar -xvf static-libs-for-embedding-only.tar.xz
repair-wheel-command = "auditwheel repair -L /bases/lib -w {dest_dir} {wheel}"

[tool.cibuildwheel.macos]
archs = "x86_64 universal2 arm64"
archs = "universal2"
repair-wheel-command = """
delocate-listdeps {wheel} &&
delocate-wheel --require-archs {delocate_archs} -L bases/lib -w {dest_dir} {wheel}
Expand Down

0 comments on commit 0a21bdb

Please sign in to comment.