Skip to content

Commit 664c70b

Browse files
authored
build macos-arm64 wheel on M1 runners (deepmodeling#3206)
Today [GitHub introduced the new M1 runners](https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/), making it possible to build macos-arm64 wheels without cross-building. Remove old hacked codes for cross-building.
1 parent 7f069cc commit 664c70b

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

.github/workflows/build_wheel.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ jobs:
4141
cuda_version: 11.8
4242
dp_pkg_name: deepmd-kit-cu11
4343
# macos-x86-64
44-
- os: macos-latest
44+
- os: macos-13
4545
python: 311
4646
platform_id: macosx_x86_64
4747
dp_variant: cpu
4848
# macos-arm64
49-
- os: macos-latest
49+
- os: macos-14
5050
python: 311
5151
platform_id: macosx_arm64
5252
dp_variant: cpu

backend/find_tensorflow.py

-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ def find_tensorflow() -> Tuple[Optional[str], List[str]]:
5050
requires = []
5151

5252
tf_spec = None
53-
if os.environ.get("CIBUILDWHEEL", "0") == "1" and os.environ.get(
54-
"CIBW_BUILD", ""
55-
).endswith("macosx_arm64"):
56-
# cibuildwheel cross build
57-
site_packages = Path(os.environ.get("RUNNER_TEMP")) / "tensorflow"
58-
tf_spec = FileFinder(str(site_packages)).find_spec("tensorflow")
5953

6054
if (tf_spec is None or not tf_spec) and os.environ.get(
6155
"TENSORFLOW_ROOT"

pyproject.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,10 @@ manylinux-aarch64-image = "manylinux_2_28"
143143
[tool.cibuildwheel.macos]
144144
environment = { PIP_PREFER_BINARY="1", DP_LAMMPS_VERSION="stable_2Aug2023_update2", DP_ENABLE_IPI="1" }
145145
before-all = [
146+
# enable MPI for macos-arm64 in the next lammps release for compatibility
146147
"""if [[ "$CIBW_BUILD" != *macosx_arm64* ]]; then brew install mpich; fi""",
147148
]
148-
before-build = [
149-
"""if [[ "$CIBW_BUILD" == *macosx_arm64* ]]; then python -m pip install "tensorflow-macos>=2.13.0rc0" --platform macosx_12_0_arm64 --no-deps --target=$RUNNER_TEMP/tensorflow; fi""",
150-
]
151-
repair-wheel-command = """if [[ "$CIBW_BUILD" == *macosx_arm64* ]]; then rm -rf $RUNNER_TEMP/tensorflow; fi && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies"""
149+
repair-wheel-command = """delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies"""
152150

153151
[tool.cibuildwheel.linux]
154152
repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so --exclude _pywrap_tensorflow_internal.so --exclude libtensorflow_cc.so.2 -w {dest_dir} {wheel}"

0 commit comments

Comments
 (0)