Skip to content

Commit 1e22937

Browse files
authored
Dynamically select Bazelisk architecture on macOS CI runners to support Apple Silicon (M1/M2 arm64) runners (#66)
* Integrate wheel build and PyPI publish steps into main build job; remove redundant 8-job pypi-publish matrix * Simplify wheel build command by omitting default python binary arg * Dynamically select Bazelisk architecture on macOS CI runners to support Apple Silicon (M1/M2 arm64) runners * Conditionally compile Arrow AVX SIMD optimization sources only when building for x86_64 CPU architecture to prevent Apple Silicon macOS errors
1 parent 0159ad1 commit 1e22937

3 files changed

Lines changed: 29 additions & 52 deletions

File tree

.bazelrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ build:sframe_fix --copt=-Wa,--gsframe=no
5050
build:sframe_fix --cxxopt=-Wa,--gsframe=no
5151
build:sframe_fix --host_copt=-Wa,--gsframe=no
5252
build:sframe_fix --host_cxxopt=-Wa,--gsframe=no
53-
build:linux --config=sframe_fix
5453

5554
build:macos --macos_minimum_os=10.12
5655

.github/workflows/build.yml

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ jobs:
3838
if [ "$RUNNER_OS" == "Linux" ]; then
3939
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64
4040
elif [ "$RUNNER_OS" == "macOS" ]; then
41-
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64
41+
ARCH=$(uname -m)
42+
if [ "$ARCH" == "arm64" ]; then
43+
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-arm64
44+
else
45+
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64
46+
fi
4247
fi
4348
chmod +x /tmp/bazelisk
4449
sudo mv /tmp/bazelisk /usr/local/bin/bazel
@@ -63,6 +68,18 @@ jobs:
6368
shell: bash -l {0}
6469
run: bazel build //...
6570

71+
- name: Build Release Wheel
72+
shell: bash -l {0}
73+
run: bazel run //:build_pip_package
74+
75+
- name: Publish Package to PyPI
76+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/r'))
77+
uses: pypa/gh-action-pypi-publish@release/v1
78+
with:
79+
password: ${{ secrets.PYPI_API_TOKEN }}
80+
packages-dir: dist/
81+
skip-existing: true
82+
6683
docker-serving-build:
6784
name: Build Docker Serving Image
6885
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -77,52 +94,3 @@ jobs:
7794
run: |
7895
cd struct2tensor/tools/tf_serving_docker
7996
docker build -t struct2tensor-serving:latest .
80-
81-
pypi-publish:
82-
name: Build and Publish Wheels to PyPI
83-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/r'))
84-
runs-on: ${{ matrix.os }}
85-
strategy:
86-
matrix:
87-
os: [ubuntu-latest, macos-latest]
88-
python-version: ["3.10", "3.11", "3.12", "3.13"]
89-
steps:
90-
- uses: actions/checkout@v4
91-
92-
- name: Set up conda environment
93-
uses: conda-incubator/setup-miniconda@v3
94-
with:
95-
auto-activate-base: false
96-
activate-environment: s2t-env
97-
environment-file: environment.yml
98-
python-version: ${{ matrix.python-version }}
99-
use-mamba: true
100-
101-
- name: Install Bazel
102-
shell: bash -l {0}
103-
run: |
104-
if [ "$RUNNER_OS" == "Linux" ]; then
105-
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64
106-
elif [ "$RUNNER_OS" == "macOS" ]; then
107-
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64
108-
fi
109-
chmod +x /tmp/bazelisk
110-
sudo mv /tmp/bazelisk /usr/local/bin/bazel
111-
112-
- name: Patch Apple CC toolchain (macOS only)
113-
if: runner.os == 'macOS'
114-
shell: bash -l {0}
115-
run: bazel build //:patch_local_config_apple_cc
116-
117-
- name: Build Release Wheel
118-
shell: bash -l {0}
119-
run: |
120-
./configure.sh
121-
bazel run --config=sframe_fix //:build_pip_package -- --python_bin_path python
122-
123-
- name: Publish Package to PyPI
124-
uses: pypa/gh-action-pypi-publish@release/v1
125-
with:
126-
password: ${{ secrets.PYPI_API_TOKEN }}
127-
packages-dir: dist/
128-
skip-existing: true

third_party/arrow.BUILD

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ fbs_headers = [
5353
"cpp/src/generated/Tensor_generated.h",
5454
]
5555

56+
arrow_simd_srcs = select({
57+
"@platforms//cpu:x86_64": glob([
58+
"cpp/src/arrow/compute/**/*_avx2.cc",
59+
"cpp/src/arrow/compute/**/*_avx512.cc",
60+
]),
61+
"//conditions:default": [],
62+
})
63+
5664
cc_library(
5765
name = "arrow",
5866
srcs = glob(
@@ -87,6 +95,8 @@ cc_library(
8795
"cpp/src/arrow/util/bpacking_avx512.*",
8896
"cpp/src/arrow/util/bpacking_neon*",
8997
"cpp/src/arrow/util/bpacking_simd*",
98+
"cpp/src/arrow/compute/**/*_avx2.*",
99+
"cpp/src/arrow/compute/**/*_avx512.*",
90100
"cpp/src/arrow/util/compression_brotli*",
91101
"cpp/src/arrow/util/compression_bz2*",
92102
"cpp/src/arrow/util/compression_lz4*",
@@ -106,7 +116,7 @@ cc_library(
106116
#"cpp/src/arrow/vendored/datetime/**",
107117
"cpp/src/parquet/encryption/encryption_internal.cc",
108118
],
109-
),
119+
) + arrow_simd_srcs,
110120
hdrs = [
111121
# Headers from above genrules.
112122
"cpp/src/arrow/util/config.h",

0 commit comments

Comments
 (0)