Skip to content

Commit 11a582e

Browse files
committed
Add intel-macOS system check
1 parent 61076a4 commit 11a582e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

install_requirements.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ def python_is_compatible():
7575

7676

7777
def install_requirements(use_pytorch_nightly):
78+
# Prevent pip install attempt on Intel-based macOS (no prebuilt PyTorch binaries available)
79+
if use_pytorch_nightly and is_intel_mac_os():
80+
sys.exit(1)
81+
7882
# pip packages needed by exir.
7983
EXIR_REQUIREMENTS = [
8084
# Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note
@@ -139,6 +143,24 @@ def install_requirements(use_pytorch_nightly):
139143
)
140144

141145

146+
# Prebuilt binaries for Intel-based macOS are no longer available on PyPI; users must compile from source.
147+
# PyTorch stopped building macOS x86_64 binaries since version 2.3.0 (January 2024).
148+
def is_intel_mac_os():
149+
# Returns True if running on Intel-based macOS
150+
if platform.system().lower() == "darwin" and platform.machine().lower() in (
151+
"x86",
152+
"x86_64",
153+
"i386",
154+
):
155+
print(
156+
"ERROR: Prebuilt PyTorch binaries are no longer available for Intel-based macOS.\n"
157+
"Please compile from source by following https://pytorch.org/executorch/0.6/using-executorch-building-from-source.html",
158+
file=sys.stderr,
159+
)
160+
return True
161+
return False
162+
163+
142164
def main(args):
143165
parser = argparse.ArgumentParser()
144166
parser.add_argument(

0 commit comments

Comments
 (0)