-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
build: Install tensorflow-macos on Apple silicon Macs #2119
Conversation
* 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 machine: >>> import platform >>> platform.machine() 'x86_64' >>> platform.system() 'Linux' - AArch64 machine: >>> import platform >>> platform.machine() 'aarch64' >>> platform.system() 'Linux' - Apple silicon machine: >>> import platform >>> platform.machine() 'arm64' >>> platform.system() 'Darwin'
pyproject.toml
Outdated
@@ -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 #1962 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purposefully over specified with both platform_machine
and platform_system
as I do not know for certain that arm64
will be reserved for Apple silicon machines forever.
Codecov ReportBase: 98.30% // Head: 98.30% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #2119 +/- ##
=======================================
Coverage 98.30% 98.30%
=======================================
Files 69 69
Lines 4531 4531
Branches 645 645
=======================================
Hits 4454 4454
Misses 45 45
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@alexander-held @lukasheinrich as you both have Apple silicon machines can you check that this PR works? Just $ python -m pip install --upgrade -e '.[backends]' should be enough. |
I was able to get this tested on a M2 machine and it works there, so as @kratsg has signed off I'm going to merge this. 👍 |
Description
Use
hatchling
's environment markers system to use platform information to determine when the installing machine is an Apple silicon Mac and installtensorflow-macos
instead oftensorflow
in this situation. This works because of the following:This is a nice workaround for tensorflow/tensorflow#57185.
The check for an Apple silicon Mac is purposefully over specified with both
platform_machine
andplatform_system
as I do not know for certain thatarm64
will be reserved for Apple silicon machines forever.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: