Skip to content

Commit

Permalink
build macos-arm64 wheel on M1 runners (deepmodeling#3206)
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 664c70b)
  • Loading branch information
njzjz committed Feb 3, 2024
1 parent 0167413 commit fc868a9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
cuda_version: 11.8
dp_pkg_name: deepmd-kit-cu11
# macos-x86-64
- os: macos-latest
- os: macos-13
python: 311
platform_id: macosx_x86_64
dp_variant: cpu
# macos-arm64
- os: macos-latest
- os: macos-14
python: 311
platform_id: macosx_arm64
dp_variant: cpu
Expand Down
6 changes: 0 additions & 6 deletions backend/find_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ def find_tensorflow() -> Tuple[Optional[str], List[str]]:
requires = []

tf_spec = None
if os.environ.get("CIBUILDWHEEL", "0") == "1" and os.environ.get(
"CIBW_BUILD", ""
).endswith("macosx_arm64"):
# cibuildwheel cross build
site_packages = Path(os.environ.get("RUNNER_TEMP")) / "tensorflow"
tf_spec = FileFinder(str(site_packages)).find_spec("tensorflow")

if (tf_spec is None or not tf_spec) and os.environ.get(
"TENSORFLOW_ROOT"
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ manylinux-aarch64-image = "manylinux_2_28"
[tool.cibuildwheel.macos]
environment = { PIP_PREFER_BINARY="1", DP_LAMMPS_VERSION="stable_2Aug2023_update2", DP_ENABLE_IPI="1" }
before-all = [
# enable MPI for macos-arm64 in the next lammps release for compatibility
"""if [[ "$CIBW_BUILD" != *macosx_arm64* ]]; then brew install mpich; fi""",
]
before-build = [
"""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""",
]
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"""
repair-wheel-command = """delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies"""

[tool.cibuildwheel.linux]
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}"
Expand Down

0 comments on commit fc868a9

Please sign in to comment.