Skip to content

Commit

Permalink
build: Install tensorflow-macos on Apple silicon Macs (#2119)
Browse files Browse the repository at this point in the history
* 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'
  • Loading branch information
matthewfeickert committed Feb 16, 2023
1 parent 46ce316 commit 74441ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74441ab

Please sign in to comment.