From 74441abeb59cfd3ab1938a60cf2453ad19a8042d Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Thu, 16 Feb 2023 12:50:46 -0600 Subject: [PATCH] build: Install tensorflow-macos on Apple silicon Macs (#2119) * Use hatchling's environment markers system to use platform information to determine when the installing machine is an Apple silicon Mac and install tensorflow-macos instead of tensorflow in this situation. - c.f. https://hatch.pypa.io/latest/config/dependency/#environment-markers * This works because of the following: - x86-64 Linux machine: >>> import platform >>> platform.machine() 'x86_64' >>> platform.system() 'Linux' - x86-64 Apple machine: >>> import platform >>> platform.machine() 'x86_64' >>> platform.system() 'Darwin' - AArch64 machine: >>> import platform >>> platform.machine() 'aarch64' >>> platform.system() 'Linux' - Apple silicon machine: >>> import platform >>> platform.machine() 'arm64' >>> platform.system() 'Darwin' --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bb2d30930a..07336892d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,8 @@ Homepage = "https://github.com/scikit-hep/pyhf" [project.optional-dependencies] shellcomplete = ["click_completion"] tensorflow = [ - "tensorflow>=2.7.0", # c.f. PR #1962 + "tensorflow>=2.7.0; platform_machine != 'arm64'", # c.f. PR #1962 + "tensorflow-macos>=2.7.0; platform_machine == 'arm64' and platform_system == 'Darwin'", # c.f. PR #2119 "tensorflow-probability>=0.11.0", # c.f. PR #1657 ] torch = ["torch>=1.10.0"] # c.f. PR #1657