@@ -75,49 +75,58 @@ def python_is_compatible():
7575
7676
7777def 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 ():
78+ is_intel_mac = is_intel_mac_os ()
79+
80+ # Skip pip install on Intel macOS if using nightly.
81+ if use_pytorch_nightly and is_intel_mac :
8082 sys .exit (1 )
8183
8284 # pip packages needed by exir.
8385 EXIR_REQUIREMENTS = [
8486 # Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note
8587 # that we don't need to set any version number there because they have already
8688 # been installed on CI before this step, so pip won't reinstall them
87- f"torch==2.8.0.{ NIGHTLY_VERSION } " if use_pytorch_nightly else "torch" ,
88- (
89- f"torchvision==0.22.0.{ NIGHTLY_VERSION } "
90- if use_pytorch_nightly
91- else "torchvision"
92- ), # For testing.
89+ f"torch==2.8.0.{ NIGHTLY_VERSION } " if use_pytorch_nightly else "torch"
9390 ]
9491
95- EXAMPLES_REQUIREMENTS = [
96- f"torchaudio==2.6.0.{ NIGHTLY_VERSION } " if use_pytorch_nightly else "torchaudio" ,
97- ]
92+ EXAMPLES_REQUIREMENTS = []
93+
94+ # Only pip install torchvision and torchaudio if not building PyTorch from source on Intel macOS,
95+ # to avoid installing incompatible prebuilt wheels from PyPI.
96+ if not is_intel_mac :
97+ EXIR_REQUIREMENTS .append (
98+ f"torchvision==0.22.0.{ NIGHTLY_VERSION } "
99+ ) # For testing.
100+
101+ EXAMPLES_REQUIREMENTS = [
102+ f"torchaudio==2.6.0.{ NIGHTLY_VERSION } " ,
103+ ]
98104
99105 # Assemble the list of requirements to actually install.
100106 # TODO: Add options for reducing the number of requirements.
101107 REQUIREMENTS_TO_INSTALL = EXIR_REQUIREMENTS + EXAMPLES_REQUIREMENTS
102108
103109 # Install the requirements. `--extra-index-url` tells pip to look for package
104110 # versions on the provided URL if they aren't available on the default URL.
105- subprocess .run (
106- [
107- sys .executable ,
108- "-m" ,
109- "pip" ,
110- "install" ,
111- "-r" ,
112- "requirements-examples.txt" ,
113- "-r" ,
114- "requirements-dev.txt" ,
115- * REQUIREMENTS_TO_INSTALL ,
116- "--extra-index-url" ,
117- TORCH_NIGHTLY_URL ,
118- ],
119- check = True ,
120- )
111+ pip_args = [
112+ sys .executable ,
113+ "-m" ,
114+ "pip" ,
115+ "install" ,
116+ "-r" ,
117+ "requirements-examples.txt" ,
118+ "-r" ,
119+ "requirements-dev.txt" ,
120+ * REQUIREMENTS_TO_INSTALL ,
121+ "--extra-index-url" ,
122+ TORCH_NIGHTLY_URL ,
123+ ]
124+
125+ # If pytorch is built from source add no-deps flag to stop dependencies from changing torch version
126+ if not use_pytorch_nightly :
127+ pip_args .append ("--no-deps" )
128+
129+ subprocess .run (pip_args , check = True )
121130
122131 LOCAL_REQUIREMENTS = [
123132 "third-party/ao" , # We need the latest kernels for fast iteration, so not relying on pypi.
@@ -143,18 +152,18 @@ def install_requirements(use_pytorch_nightly):
143152 )
144153
145154
146- # Prebuilt binaries for Intel-based macOS are no longer available on PyPI; users must compile from source.
155+ # Prebuilt wheels for Intel macOS are no longer available on PyPI; users must compile from source.
147156# PyTorch stopped building macOS x86_64 binaries since version 2.3.0 (January 2024).
148157def is_intel_mac_os ():
149- # Returns True if running on Intel-based macOS
158+ # Returns True if running on Intel macOS
150159 if platform .system ().lower () == "darwin" and platform .machine ().lower () in (
151160 "x86" ,
152161 "x86_64" ,
153162 "i386" ,
154163 ):
155164 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" ,
165+ "ERROR: Prebuilt PyTorch wheels are no longer available for Intel-based macOS.\n "
166+ "Please build from source by following https://pytorch.org/executorch/0.6/using-executorch-building-from-source.html" ,
158167 file = sys .stderr ,
159168 )
160169 return True
0 commit comments