Skip to content

Add macOS (Apple Silicon / arm64) build, packaging, and CI support - #1123

Draft
vruotolo wants to merge 1 commit into
tensorflow:masterfrom
vruotolo:fix-469454306
Draft

vruotolo wants to merge 1 commit into
tensorflow:masterfrom
vruotolo:fix-469454306

Conversation

@vruotolo

Copy link
Copy Markdown

Enable building, testing, and packaging TensorFlow Quantum on macOS (Apple Silicon / arm64) with TensorFlow 2.19.1:

  • configure.sh & third_party/tf/:
    • Detect libtensorflow_framework*.dylib on Darwin and configure @local_config_tf//:libtensorflow_framework to output libtensorflow_framework.dylib on macOS.
    • Guard Linux-only libstdc++ ABI and GCC warning flags (-Wno-stringop-overflow, -Wno-maybe-uninitialized) on macOS.
    • Add macOS Bazel flags (--macos_minimum_os=12.0, --host_cxxopt=-std=c++17, -DGRPC_BAZEL_BUILD, -Wl,-undefined,dynamic_lookup, and @loader_path rpaths to tensorflow).
    • Enforce CPU build (TF_NEED_CUDA=0) when configuring on macOS.
  • Packaging & custom op loading:
    • Update release/build_pip_package.sh to dereference Bazel runfiles symlinks portably on BSD/macOS cp (-LR), avoid clobbering the macOS TMPDIR environment variable, and normalize relative destination paths.
    • Replace removed-in-3.12 distutils.sysconfig.get_python_lib with stdlib sysconfig.get_path("platlib") in tensorflow_quantum/core/ops/load_module.py.
    • Add native macOS build and delocate-wheel repair paths to release/build_distribution.sh, release/clean_distribution.sh, and release/build_release.sh.
  • CI & scripts:
    • Update scripts/ci_install.sh to install Bazel 6.5.0 on Darwin (arm64/x86_64).
    • Guard x86-only -msse2/-msse3/-msse4 flags behind uname -m == x86_64 in test and benchmark scripts.
    • Add macos-14 jobs to .github/workflows/ci.yaml and .github/workflows/ci-nightly-build-test.yaml.
  • Docs & metadata:
    • Add macOS and Linux OS classifiers in release/setup.py and update README.md, docs/install.md, and release/README.md.

Enable building, testing, and packaging TensorFlow Quantum on macOS
(Apple Silicon / arm64) with TensorFlow 2.19.1:

- configure.sh & third_party/tf/:
  - Detect `libtensorflow_framework*.dylib` on Darwin and configure
    `@local_config_tf//:libtensorflow_framework` to output
    `libtensorflow_framework.dylib` on macOS.
  - Guard Linux-only `libstdc++` ABI and GCC warning flags (`-Wno-stringop-overflow`,
    `-Wno-maybe-uninitialized`) on macOS.
  - Add macOS Bazel flags (`--macos_minimum_os=12.0`, `--host_cxxopt=-std=c++17`,
    `-DGRPC_BAZEL_BUILD`, `-Wl,-undefined,dynamic_lookup`, and `@loader_path`
    rpaths to `tensorflow`).
  - Enforce CPU build (`TF_NEED_CUDA=0`) when configuring on macOS.
- Packaging & custom op loading:
  - Update `release/build_pip_package.sh` to dereference Bazel runfiles symlinks
    portably on BSD/macOS `cp` (`-LR`), avoid clobbering the macOS `TMPDIR`
    environment variable, and normalize relative destination paths.
  - Replace removed-in-3.12 `distutils.sysconfig.get_python_lib` with stdlib
    `sysconfig.get_path("platlib")` in `tensorflow_quantum/core/ops/load_module.py`.
  - Add native macOS build and `delocate-wheel` repair paths to
    `release/build_distribution.sh`, `release/clean_distribution.sh`, and
    `release/build_release.sh`.
- CI & scripts:
  - Update `scripts/ci_install.sh` to install Bazel 6.5.0 on Darwin (`arm64`/`x86_64`).
  - Guard x86-only `-msse2`/`-msse3`/`-msse4` flags behind `uname -m == x86_64` in
    test and benchmark scripts.
  - Add `macos-14` jobs to `.github/workflows/ci.yaml` and
    `.github/workflows/ci-nightly-build-test.yaml`.
- Docs & metadata:
  - Add macOS and Linux OS classifiers in `release/setup.py` and update
    `README.md`, `docs/install.md`, and `release/README.md`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant