(args)
| 207 | |
| 208 | |
| 209 | def main(args): |
| 210 | if not python_is_compatible(): |
| 211 | sys.exit(1) |
| 212 | |
| 213 | args = _parse_args() |
| 214 | |
| 215 | if args.clean: |
| 216 | clean() |
| 217 | return |
| 218 | |
| 219 | check_and_update_submodules() |
| 220 | # This option is used in CI to make sure that PyTorch build from the pinned commit |
| 221 | # is used instead of nightly. CI jobs wouldn't be able to catch regression from the |
| 222 | # latest PT commit otherwise |
| 223 | use_pytorch_nightly = not args.use_pt_pinned_commit |
| 224 | |
| 225 | # Step 1: Install core dependencies first |
| 226 | install_requirements(use_pytorch_nightly) |
| 227 | |
| 228 | # Step 2: Install build dependencies for optional dependencies |
| 229 | # They need to be installed before optional dependencies due to --no-build-isolation |
| 230 | optional_build_dependencies: list[str] = [] |
| 231 | for optional_dep in args.optional_dependency: |
| 232 | match optional_dep: |
| 233 | case "cortex_m": |
| 234 | optional_build_dependencies.extend( |
| 235 | ["pybind11>=2.10", "scikit-build-core>=0.7"] |
| 236 | ) |
| 237 | if len(optional_build_dependencies) > 0: |
| 238 | cmd = [sys.executable, "-m", "pip", "install", *optional_build_dependencies] |
| 239 | subprocess.run(cmd, check=True) |
| 240 | |
| 241 | # Step 3: Install core package |
| 242 | package_spec = "." |
| 243 | if args.optional_dependency: |
| 244 | extras = ",".join(dict.fromkeys(args.optional_dependency)) |
| 245 | package_spec = f".[{extras}]" |
| 246 | cmd = ( |
| 247 | [ |
| 248 | sys.executable, |
| 249 | "-m", |
| 250 | "pip", |
| 251 | "install", |
| 252 | ] |
| 253 | + (["--editable"] if args.editable else []) |
| 254 | + [ |
| 255 | package_spec, |
| 256 | "--no-build-isolation", |
| 257 | "-v", |
| 258 | ] |
| 259 | ) |
| 260 | subprocess.run(cmd, check=True) |
| 261 | |
| 262 | # Step 4: Extra (optional) packages that is only useful for running examples. |
| 263 | if not args.minimal: |
| 264 | install_optional_example_requirements(use_pytorch_nightly) |
| 265 | |
| 266 |
no test coverage detected