@@ -79,97 +79,29 @@ def clean():
79
79
VALID_PYBINDS = ["coreml" , "mps" , "xnnpack" ]
80
80
81
81
82
- def main (args ):
83
- if not python_is_compatible ():
84
- sys .exit (1 )
85
-
86
- # Parse options.
87
-
88
- EXECUTORCH_BUILD_PYBIND = ""
89
- CMAKE_ARGS = os .getenv ("CMAKE_ARGS" , "" )
90
- CMAKE_BUILD_ARGS = os .getenv ("CMAKE_BUILD_ARGS" , "" )
91
- USE_PYTORCH_NIGHTLY = True
92
-
93
- parser = argparse .ArgumentParser (prog = "install_requirements" )
94
- parser .add_argument (
95
- "--pybind" ,
96
- action = "append" ,
97
- nargs = "+" ,
98
- help = "one or more of coreml/mps/xnnpack, or off" ,
99
- )
100
- parser .add_argument (
101
- "--clean" ,
102
- action = "store_true" ,
103
- help = "clean build artifacts and pip-out instead of installing" ,
104
- )
105
- parser .add_argument (
106
- "--use-pt-pinned-commit" ,
107
- action = "store_true" ,
108
- help = "build from the pinned PyTorch commit instead of nightly" ,
109
- )
110
- args = parser .parse_args (args )
111
-
112
- if args .clean :
113
- clean ()
114
- return
115
-
116
- if args .pybind :
117
- # Flatten list of lists.
118
- args .pybind = list (itertools .chain (* args .pybind ))
119
- if "off" in args .pybind :
120
- if len (args .pybind ) != 1 :
121
- raise Exception (
122
- f"Cannot combine `off` with other pybinds: { args .pybind } "
123
- )
124
- EXECUTORCH_BUILD_PYBIND = "OFF"
125
- else :
126
- for pybind_arg in args .pybind :
127
- if pybind_arg not in VALID_PYBINDS :
128
- raise Exception (
129
- f"Unrecognized pybind argument { pybind_arg } ; valid options are: { ", " .join (VALID_PYBINDS )} "
130
- )
131
- EXECUTORCH_BUILD_PYBIND = "ON"
132
- CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{ pybind_arg .upper ()} =ON"
82
+ # The pip repository that hosts nightly torch packages.
83
+ TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu"
133
84
134
- if args .use_pt_pinned_commit :
135
- # This option is used in CI to make sure that PyTorch build from the pinned commit
136
- # is used instead of nightly. CI jobs wouldn't be able to catch regression from the
137
- # latest PT commit otherwise
138
- USE_PYTORCH_NIGHTLY = False
139
85
140
- # If --pybind is not set explicitly for backends (e.g., --pybind xnnpack)
141
- # or is not turned off explicitly (--pybind off)
142
- # then install XNNPACK by default.
143
- if EXECUTORCH_BUILD_PYBIND == "" :
144
- EXECUTORCH_BUILD_PYBIND = "ON"
145
- CMAKE_ARGS += " -DEXECUTORCH_BUILD_XNNPACK=ON"
146
-
147
- # Use ClangCL on Windows.
148
- # ClangCL is an alias to Clang that configures it to work in an MSVC-compatible
149
- # mode. Using it on Windows to avoid compiler compatibility issues for MSVC.
150
- if os .name == "nt" :
151
- CMAKE_ARGS += " -T ClangCL"
152
-
153
- # Since ExecuTorch often uses main-branch features of pytorch, only the nightly
154
- # pip versions will have the required features.
155
- #
156
- # NOTE: If a newly-fetched version of the executorch repo changes the value of
157
- # NIGHTLY_VERSION, you should re-run this script to install the necessary
158
- # package versions.
159
- NIGHTLY_VERSION = "dev20250104"
86
+ # Since ExecuTorch often uses main-branch features of pytorch, only the nightly
87
+ # pip versions will have the required features.
88
+ #
89
+ # NOTE: If a newly-fetched version of the executorch repo changes the value of
90
+ # NIGHTLY_VERSION, you should re-run this script to install the necessary
91
+ # package versions.
92
+ NIGHTLY_VERSION = "dev20250104"
160
93
161
- # The pip repository that hosts nightly torch packages.
162
- TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu"
163
94
95
+ def install_requirements (use_pytorch_nightly ):
164
96
# pip packages needed by exir.
165
97
EXIR_REQUIREMENTS = [
166
- # Setting USE_PYTORCH_NIGHTLY to false to test the pinned PyTorch commit. Note
98
+ # Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note
167
99
# that we don't need to set any version number there because they have already
168
100
# been installed on CI before this step, so pip won't reinstall them
169
- f"torch==2.6.0.{ NIGHTLY_VERSION } " if USE_PYTORCH_NIGHTLY else "torch" ,
101
+ f"torch==2.6.0.{ NIGHTLY_VERSION } " if use_pytorch_nightly else "torch" ,
170
102
(
171
103
f"torchvision==0.22.0.{ NIGHTLY_VERSION } "
172
- if USE_PYTORCH_NIGHTLY
104
+ if use_pytorch_nightly
173
105
else "torchvision"
174
106
), # For testing.
175
107
"typing-extensions" ,
@@ -179,7 +111,7 @@ def main(args):
179
111
# TODO: Make each example publish its own requirements.txt
180
112
EXAMPLES_REQUIREMENTS = [
181
113
"timm==1.0.7" ,
182
- f"torchaudio==2.6.0.{ NIGHTLY_VERSION } " if USE_PYTORCH_NIGHTLY else "torchaudio" ,
114
+ f"torchaudio==2.6.0.{ NIGHTLY_VERSION } " if use_pytorch_nightly else "torchaudio" ,
183
115
"torchsr==1.0.4" ,
184
116
"transformers==4.47.1" ,
185
117
]
@@ -234,6 +166,79 @@ def main(args):
234
166
check = True ,
235
167
)
236
168
169
+
170
+ def main (args ):
171
+ if not python_is_compatible ():
172
+ sys .exit (1 )
173
+
174
+ # Parse options.
175
+
176
+ EXECUTORCH_BUILD_PYBIND = ""
177
+ CMAKE_ARGS = os .getenv ("CMAKE_ARGS" , "" )
178
+ CMAKE_BUILD_ARGS = os .getenv ("CMAKE_BUILD_ARGS" , "" )
179
+ use_pytorch_nightly = True
180
+
181
+ parser = argparse .ArgumentParser (prog = "install_requirements" )
182
+ parser .add_argument (
183
+ "--pybind" ,
184
+ action = "append" ,
185
+ nargs = "+" ,
186
+ help = "one or more of coreml/mps/xnnpack, or off" ,
187
+ )
188
+ parser .add_argument (
189
+ "--clean" ,
190
+ action = "store_true" ,
191
+ help = "clean build artifacts and pip-out instead of installing" ,
192
+ )
193
+ parser .add_argument (
194
+ "--use-pt-pinned-commit" ,
195
+ action = "store_true" ,
196
+ help = "build from the pinned PyTorch commit instead of nightly" ,
197
+ )
198
+ args = parser .parse_args (args )
199
+ if args .pybind :
200
+ # Flatten list of lists.
201
+ args .pybind = list (itertools .chain (* args .pybind ))
202
+ if "off" in args .pybind :
203
+ if len (args .pybind ) != 1 :
204
+ raise Exception (
205
+ f"Cannot combine `off` with other pybinds: { args .pybind } "
206
+ )
207
+ EXECUTORCH_BUILD_PYBIND = "OFF"
208
+ else :
209
+ for pybind_arg in args .pybind :
210
+ if pybind_arg not in VALID_PYBINDS :
211
+ raise Exception (
212
+ f"Unrecognized pybind argument { pybind_arg } ; valid options are: { ", " .join (VALID_PYBINDS )} "
213
+ )
214
+ EXECUTORCH_BUILD_PYBIND = "ON"
215
+ CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{ pybind_arg .upper ()} =ON"
216
+
217
+ if args .clean :
218
+ clean ()
219
+ return
220
+
221
+ if args .use_pt_pinned_commit :
222
+ # This option is used in CI to make sure that PyTorch build from the pinned commit
223
+ # is used instead of nightly. CI jobs wouldn't be able to catch regression from the
224
+ # latest PT commit otherwise
225
+ use_pytorch_nightly = False
226
+
227
+ install_requirements (use_pytorch_nightly )
228
+
229
+ # If --pybind is not set explicitly for backends (e.g., --pybind xnnpack)
230
+ # or is not turned off explicitly (--pybind off)
231
+ # then install XNNPACK by default.
232
+ if EXECUTORCH_BUILD_PYBIND == "" :
233
+ EXECUTORCH_BUILD_PYBIND = "ON"
234
+ CMAKE_ARGS += " -DEXECUTORCH_BUILD_XNNPACK=ON"
235
+
236
+ # Use ClangCL on Windows.
237
+ # ClangCL is an alias to Clang that configures it to work in an MSVC-compatible
238
+ # mode. Using it on Windows to avoid compiler compatibility issues for MSVC.
239
+ if os .name == "nt" :
240
+ CMAKE_ARGS += " -T ClangCL"
241
+
237
242
#
238
243
# Install executorch pip package. This also makes `flatc` available on the path.
239
244
# The --extra-index-url may be necessary if pyproject.toml has a dependency on a
0 commit comments