From da1df94e64413790f2257c05a8762a98302e803e Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 09:30:02 -0800 Subject: [PATCH 1/8] Update [ghstack-poisoned] --- install_requirements.py | 343 +++++++++++++++++++++------------------- 1 file changed, 183 insertions(+), 160 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index 26093cab84..0416a0710c 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -6,7 +6,9 @@ # LICENSE file in the root directory of this source tree. +import argparse import glob +import itertools import os import platform import re @@ -63,175 +65,196 @@ def python_is_compatible(): return True -if not python_is_compatible(): - sys.exit(1) +def clean(): + print("Cleaning build artifacts...") + print("Cleaning pip-out/...") + shutil.rmtree("pip-out/", ignore_errors=True) + dirs = glob.glob("cmake-out*/") + glob.glob("cmake-android-out/") + for d in dirs: + print(f"Cleaning {d}...") + shutil.rmtree(d, ignore_errors=True) + print("Done cleaning build artifacts.") -# Parse options. -EXECUTORCH_BUILD_PYBIND = "" -CMAKE_ARGS = os.getenv("CMAKE_ARGS", "") -CMAKE_BUILD_ARGS = os.getenv("CMAKE_BUILD_ARGS", "") -USE_PYTORCH_NIGHTLY = True +def main(args): + if not python_is_compatible(): + sys.exit(1) -args = sys.argv[1:] -for arg in args: - if arg == "--pybind": - pass - elif arg in ["coreml", "mps", "xnnpack"]: - if "--pybind" in args: - arg_upper = arg.upper() - EXECUTORCH_BUILD_PYBIND = "ON" - CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{arg_upper}=ON" - else: - print(f"Error: {arg} must follow --pybind") - sys.exit(1) - elif arg == "off": - if "--pybind" in args: - if EXECUTORCH_BUILD_PYBIND == "ON": - print("Cannot turnoff pybind option as it is already set.") - sys.exit(1) + # Parse options. + + EXECUTORCH_BUILD_PYBIND = "" + CMAKE_ARGS = os.getenv("CMAKE_ARGS", "") + CMAKE_BUILD_ARGS = os.getenv("CMAKE_BUILD_ARGS", "") + USE_PYTORCH_NIGHTLY = True + + parser = argparse.ArgumentParser(prog="install_requirements") + parser.add_argument( + "--pybind", + action="append", + nargs="+", + help="one or more of coreml/mps/xnnpack, or off", + ) + parser.add_argument( + "--clean", + action="store_true", + help="clean build artifacts and pip-out instead of installing", + ) + parser.add_argument( + "--use-pt-pinned-commit", + action="store_true", + help="build from the pinned PyTorch commit instead of nightly", + ) + args = parser.parse_args(args) + if args.pybind: + # Flatten list of lists. + args.pybind = list(itertools.chain(*args.pybind)) + if "off" in args.pybind: + if len(args.pybind) != 1: + raise Exception( + f"Cannot combine `off` with other pybinds: {args.pybind}" + ) EXECUTORCH_BUILD_PYBIND = "OFF" else: - print(f"Error: {arg} must follow --pybind") - sys.exit(1) - - elif arg == "--clean": - print("Cleaning build artifacts...") - print("Cleaning pip-out/...") - shutil.rmtree("pip-out/", ignore_errors=True) - dirs = glob.glob("cmake-out*/") + glob.glob("cmake-android-out/") - for d in dirs: - print(f"Cleaning {d}...") - shutil.rmtree(d, ignore_errors=True) - print("Done cleaning build artifacts.") - sys.exit(0) - elif arg == "--use-pt-pinned-commit": + for pybind_arg in args.pybind: + if pybind_arg not in ["coreml", "mps", "xnnpack"]: + continue + EXECUTORCH_BUILD_PYBIND = "ON" + CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{pybind_arg.upper()}=ON" + + if args.clean: + clean() + return + + if args.use_pt_pinned_commit: # This option is used in CI to make sure that PyTorch build from the pinned commit # is used instead of nightly. CI jobs wouldn't be able to catch regression from the # latest PT commit otherwise USE_PYTORCH_NIGHTLY = False - else: - print(f"Error: Unknown option {arg}") - sys.exit(1) -# If --pybind is not set explicitly for backends (e.g., --pybind xnnpack) -# or is not turned off explicitly (--pybind off) -# then install XNNPACK by default. -if EXECUTORCH_BUILD_PYBIND == "": - EXECUTORCH_BUILD_PYBIND = "ON" - CMAKE_ARGS += " -DEXECUTORCH_BUILD_XNNPACK=ON" - -# Use ClangCL on Windows. -# ClangCL is an alias to Clang that configures it to work in an MSVC-compatible -# mode. Using it on Windows to avoid compiler compatibility issues for MSVC. -if os.name == "nt": - CMAKE_ARGS += " -T ClangCL" - -# Since ExecuTorch often uses main-branch features of pytorch, only the nightly -# pip versions will have the required features. -# -# NOTE: If a newly-fetched version of the executorch repo changes the value of -# NIGHTLY_VERSION, you should re-run this script to install the necessary -# package versions. -NIGHTLY_VERSION = "dev20250104" - -# The pip repository that hosts nightly torch packages. -TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu" - -# pip packages needed by exir. -EXIR_REQUIREMENTS = [ - # Setting USE_PYTORCH_NIGHTLY to false to test the pinned PyTorch commit. Note - # that we don't need to set any version number there because they have already - # been installed on CI before this step, so pip won't reinstall them - f"torch==2.6.0.{NIGHTLY_VERSION}" if USE_PYTORCH_NIGHTLY else "torch", - ( - f"torchvision==0.22.0.{NIGHTLY_VERSION}" - if USE_PYTORCH_NIGHTLY - else "torchvision" - ), # For testing. - "typing-extensions", -] - -# pip packages needed to run examples. -# TODO: Make each example publish its own requirements.txt -EXAMPLES_REQUIREMENTS = [ - "timm==1.0.7", - f"torchaudio==2.6.0.{NIGHTLY_VERSION}" if USE_PYTORCH_NIGHTLY else "torchaudio", - "torchsr==1.0.4", - "transformers==4.47.1", -] - -# pip packages needed for development. -DEVEL_REQUIREMENTS = [ - "cmake", # For building binary targets. - "pip>=23", # For building the pip package. - "pyyaml", # Imported by the kernel codegen tools. - "setuptools>=63", # For building the pip package. - "tomli", # Imported by extract_sources.py when using python < 3.11. - "wheel", # For building the pip package archive. - "zstd", # Imported by resolve_buck.py. - "ai-edge-model-explorer>=0.1.16", # For visualizing ExportedPrograms -] - -# Assemble the list of requirements to actually install. -# TODO: Add options for reducing the number of requirements. -REQUIREMENTS_TO_INSTALL = EXIR_REQUIREMENTS + DEVEL_REQUIREMENTS + EXAMPLES_REQUIREMENTS - -# Install the requirements. `--extra-index-url` tells pip to look for package -# versions on the provided URL if they aren't available on the default URL. -subprocess.run( - [ - sys.executable, - "-m", - "pip", - "install", - *REQUIREMENTS_TO_INSTALL, - "--extra-index-url", - TORCH_NIGHTLY_URL, - ], - check=True, -) - -LOCAL_REQUIREMENTS = [ - "third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi. -] - -# Install packages directly from local copy instead of pypi. -# This is usually not recommended. -subprocess.run( - [ - sys.executable, - "-m", - "pip", - "install", - *LOCAL_REQUIREMENTS, - ], - check=True, -) + # If --pybind is not set explicitly for backends (e.g., --pybind xnnpack) + # or is not turned off explicitly (--pybind off) + # then install XNNPACK by default. + if EXECUTORCH_BUILD_PYBIND == "": + EXECUTORCH_BUILD_PYBIND = "ON" + CMAKE_ARGS += " -DEXECUTORCH_BUILD_XNNPACK=ON" + + # Use ClangCL on Windows. + # ClangCL is an alias to Clang that configures it to work in an MSVC-compatible + # mode. Using it on Windows to avoid compiler compatibility issues for MSVC. + if os.name == "nt": + CMAKE_ARGS += " -T ClangCL" + + # Since ExecuTorch often uses main-branch features of pytorch, only the nightly + # pip versions will have the required features. + # + # NOTE: If a newly-fetched version of the executorch repo changes the value of + # NIGHTLY_VERSION, you should re-run this script to install the necessary + # package versions. + NIGHTLY_VERSION = "dev20250104" + + # The pip repository that hosts nightly torch packages. + TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu" + + # pip packages needed by exir. + EXIR_REQUIREMENTS = [ + # Setting USE_PYTORCH_NIGHTLY to false to test the pinned PyTorch commit. Note + # that we don't need to set any version number there because they have already + # been installed on CI before this step, so pip won't reinstall them + f"torch==2.6.0.{NIGHTLY_VERSION}" if USE_PYTORCH_NIGHTLY else "torch", + ( + f"torchvision==0.22.0.{NIGHTLY_VERSION}" + if USE_PYTORCH_NIGHTLY + else "torchvision" + ), # For testing. + "typing-extensions", + ] + + # pip packages needed to run examples. + # TODO: Make each example publish its own requirements.txt + EXAMPLES_REQUIREMENTS = [ + "timm==1.0.7", + f"torchaudio==2.6.0.{NIGHTLY_VERSION}" if USE_PYTORCH_NIGHTLY else "torchaudio", + "torchsr==1.0.4", + "transformers==4.47.1", + ] + + # pip packages needed for development. + DEVEL_REQUIREMENTS = [ + "cmake", # For building binary targets. + "pip>=23", # For building the pip package. + "pyyaml", # Imported by the kernel codegen tools. + "setuptools>=63", # For building the pip package. + "tomli", # Imported by extract_sources.py when using python < 3.11. + "wheel", # For building the pip package archive. + "zstd", # Imported by resolve_buck.py. + "ai-edge-model-explorer>=0.1.16", # For visualizing ExportedPrograms + ] + + # Assemble the list of requirements to actually install. + # TODO: Add options for reducing the number of requirements. + REQUIREMENTS_TO_INSTALL = ( + EXIR_REQUIREMENTS + DEVEL_REQUIREMENTS + EXAMPLES_REQUIREMENTS + ) + + # Install the requirements. `--extra-index-url` tells pip to look for package + # versions on the provided URL if they aren't available on the default URL. + subprocess.run( + [ + sys.executable, + "-m", + "pip", + "install", + *REQUIREMENTS_TO_INSTALL, + "--extra-index-url", + TORCH_NIGHTLY_URL, + ], + check=True, + ) + + LOCAL_REQUIREMENTS = [ + "third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi. + ] + + # Install packages directly from local copy instead of pypi. + # This is usually not recommended. + subprocess.run( + [ + sys.executable, + "-m", + "pip", + "install", + *LOCAL_REQUIREMENTS, + ], + check=True, + ) + + # + # Install executorch pip package. This also makes `flatc` available on the path. + # The --extra-index-url may be necessary if pyproject.toml has a dependency on a + # pre-release or nightly version of a torch package. + # + + # Set environment variables + os.environ["EXECUTORCH_BUILD_PYBIND"] = EXECUTORCH_BUILD_PYBIND + os.environ["CMAKE_ARGS"] = CMAKE_ARGS + os.environ["CMAKE_BUILD_ARGS"] = CMAKE_BUILD_ARGS + + # Run the pip install command + subprocess.run( + [ + sys.executable, + "-m", + "pip", + "install", + ".", + "--no-build-isolation", + "-v", + "--extra-index-url", + TORCH_NIGHTLY_URL, + ], + check=True, + ) -# -# Install executorch pip package. This also makes `flatc` available on the path. -# The --extra-index-url may be necessary if pyproject.toml has a dependency on a -# pre-release or nightly version of a torch package. -# -# Set environment variables -os.environ["EXECUTORCH_BUILD_PYBIND"] = EXECUTORCH_BUILD_PYBIND -os.environ["CMAKE_ARGS"] = CMAKE_ARGS -os.environ["CMAKE_BUILD_ARGS"] = CMAKE_BUILD_ARGS - -# Run the pip install command -subprocess.run( - [ - sys.executable, - "-m", - "pip", - "install", - ".", - "--no-build-isolation", - "-v", - "--extra-index-url", - TORCH_NIGHTLY_URL, - ], - check=True, -) +if __name__ == "__main__": + main(sys.argv[1:]) From e411a1e597f37c13062021faf60fc27964656024 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 09:30:38 -0800 Subject: [PATCH 2/8] Update [ghstack-poisoned] --- install_requirements.py | 164 +++++++++++++++++++++------------------- 1 file changed, 85 insertions(+), 79 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index 0416a0710c..199d090d47 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -76,94 +76,29 @@ def clean(): print("Done cleaning build artifacts.") -def main(args): - if not python_is_compatible(): - sys.exit(1) +# The pip repository that hosts nightly torch packages. +TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu" - # Parse options. - EXECUTORCH_BUILD_PYBIND = "" - CMAKE_ARGS = os.getenv("CMAKE_ARGS", "") - CMAKE_BUILD_ARGS = os.getenv("CMAKE_BUILD_ARGS", "") - USE_PYTORCH_NIGHTLY = True - - parser = argparse.ArgumentParser(prog="install_requirements") - parser.add_argument( - "--pybind", - action="append", - nargs="+", - help="one or more of coreml/mps/xnnpack, or off", - ) - parser.add_argument( - "--clean", - action="store_true", - help="clean build artifacts and pip-out instead of installing", - ) - parser.add_argument( - "--use-pt-pinned-commit", - action="store_true", - help="build from the pinned PyTorch commit instead of nightly", - ) - args = parser.parse_args(args) - if args.pybind: - # Flatten list of lists. - args.pybind = list(itertools.chain(*args.pybind)) - if "off" in args.pybind: - if len(args.pybind) != 1: - raise Exception( - f"Cannot combine `off` with other pybinds: {args.pybind}" - ) - EXECUTORCH_BUILD_PYBIND = "OFF" - else: - for pybind_arg in args.pybind: - if pybind_arg not in ["coreml", "mps", "xnnpack"]: - continue - EXECUTORCH_BUILD_PYBIND = "ON" - CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{pybind_arg.upper()}=ON" - - if args.clean: - clean() - return - - if args.use_pt_pinned_commit: - # This option is used in CI to make sure that PyTorch build from the pinned commit - # is used instead of nightly. CI jobs wouldn't be able to catch regression from the - # latest PT commit otherwise - USE_PYTORCH_NIGHTLY = False - - # If --pybind is not set explicitly for backends (e.g., --pybind xnnpack) - # or is not turned off explicitly (--pybind off) - # then install XNNPACK by default. - if EXECUTORCH_BUILD_PYBIND == "": - EXECUTORCH_BUILD_PYBIND = "ON" - CMAKE_ARGS += " -DEXECUTORCH_BUILD_XNNPACK=ON" - - # Use ClangCL on Windows. - # ClangCL is an alias to Clang that configures it to work in an MSVC-compatible - # mode. Using it on Windows to avoid compiler compatibility issues for MSVC. - if os.name == "nt": - CMAKE_ARGS += " -T ClangCL" - - # Since ExecuTorch often uses main-branch features of pytorch, only the nightly - # pip versions will have the required features. - # - # NOTE: If a newly-fetched version of the executorch repo changes the value of - # NIGHTLY_VERSION, you should re-run this script to install the necessary - # package versions. - NIGHTLY_VERSION = "dev20250104" +# Since ExecuTorch often uses main-branch features of pytorch, only the nightly +# pip versions will have the required features. +# +# NOTE: If a newly-fetched version of the executorch repo changes the value of +# NIGHTLY_VERSION, you should re-run this script to install the necessary +# package versions. +NIGHTLY_VERSION = "dev20250104" - # The pip repository that hosts nightly torch packages. - TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu" +def install_requirements(use_pytorch_nightly): # pip packages needed by exir. EXIR_REQUIREMENTS = [ - # Setting USE_PYTORCH_NIGHTLY to false to test the pinned PyTorch commit. Note + # Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note # that we don't need to set any version number there because they have already # been installed on CI before this step, so pip won't reinstall them - f"torch==2.6.0.{NIGHTLY_VERSION}" if USE_PYTORCH_NIGHTLY else "torch", + f"torch==2.6.0.{NIGHTLY_VERSION}" if use_pytorch_nightly else "torch", ( f"torchvision==0.22.0.{NIGHTLY_VERSION}" - if USE_PYTORCH_NIGHTLY + if use_pytorch_nightly else "torchvision" ), # For testing. "typing-extensions", @@ -173,7 +108,7 @@ def main(args): # TODO: Make each example publish its own requirements.txt EXAMPLES_REQUIREMENTS = [ "timm==1.0.7", - f"torchaudio==2.6.0.{NIGHTLY_VERSION}" if USE_PYTORCH_NIGHTLY else "torchaudio", + f"torchaudio==2.6.0.{NIGHTLY_VERSION}" if use_pytorch_nightly else "torchaudio", "torchsr==1.0.4", "transformers==4.47.1", ] @@ -228,6 +163,77 @@ def main(args): check=True, ) + +def main(args): + if not python_is_compatible(): + sys.exit(1) + + # Parse options. + + EXECUTORCH_BUILD_PYBIND = "" + CMAKE_ARGS = os.getenv("CMAKE_ARGS", "") + CMAKE_BUILD_ARGS = os.getenv("CMAKE_BUILD_ARGS", "") + use_pytorch_nightly = True + + parser = argparse.ArgumentParser(prog="install_requirements") + parser.add_argument( + "--pybind", + action="append", + nargs="+", + help="one or more of coreml/mps/xnnpack, or off", + ) + parser.add_argument( + "--clean", + action="store_true", + help="clean build artifacts and pip-out instead of installing", + ) + parser.add_argument( + "--use-pt-pinned-commit", + action="store_true", + help="build from the pinned PyTorch commit instead of nightly", + ) + args = parser.parse_args(args) + if args.pybind: + # Flatten list of lists. + args.pybind = list(itertools.chain(*args.pybind)) + if "off" in args.pybind: + if len(args.pybind) != 1: + raise Exception( + f"Cannot combine `off` with other pybinds: {args.pybind}" + ) + EXECUTORCH_BUILD_PYBIND = "OFF" + else: + for pybind_arg in args.pybind: + if pybind_arg not in ["coreml", "mps", "xnnpack"]: + continue + EXECUTORCH_BUILD_PYBIND = "ON" + CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{pybind_arg.upper()}=ON" + + if args.clean: + clean() + return + + if args.use_pt_pinned_commit: + # This option is used in CI to make sure that PyTorch build from the pinned commit + # is used instead of nightly. CI jobs wouldn't be able to catch regression from the + # latest PT commit otherwise + use_pytorch_nightly = False + + install_requirements(use_pytorch_nightly) + + # If --pybind is not set explicitly for backends (e.g., --pybind xnnpack) + # or is not turned off explicitly (--pybind off) + # then install XNNPACK by default. + if EXECUTORCH_BUILD_PYBIND == "": + EXECUTORCH_BUILD_PYBIND = "ON" + CMAKE_ARGS += " -DEXECUTORCH_BUILD_XNNPACK=ON" + + # Use ClangCL on Windows. + # ClangCL is an alias to Clang that configures it to work in an MSVC-compatible + # mode. Using it on Windows to avoid compiler compatibility issues for MSVC. + if os.name == "nt": + CMAKE_ARGS += " -T ClangCL" + # # Install executorch pip package. This also makes `flatc` available on the path. # The --extra-index-url may be necessary if pyproject.toml has a dependency on a From 6e9745ccf560f032d6a619f305631fc0d206f178 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 09:30:51 -0800 Subject: [PATCH 3/8] Update [ghstack-poisoned] --- install_requirements.py | 26 +++++++------------------- requirements-dev.txt | 2 ++ requirements-examples.txt | 5 +++++ 3 files changed, 14 insertions(+), 19 deletions(-) create mode 100644 requirements-dev.txt create mode 100644 requirements-examples.txt diff --git a/install_requirements.py b/install_requirements.py index 199d090d47..e959b891bc 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -101,34 +101,16 @@ def install_requirements(use_pytorch_nightly): if use_pytorch_nightly else "torchvision" ), # For testing. - "typing-extensions", ] - # pip packages needed to run examples. - # TODO: Make each example publish its own requirements.txt EXAMPLES_REQUIREMENTS = [ - "timm==1.0.7", f"torchaudio==2.6.0.{NIGHTLY_VERSION}" if use_pytorch_nightly else "torchaudio", - "torchsr==1.0.4", - "transformers==4.47.1", - ] - - # pip packages needed for development. - DEVEL_REQUIREMENTS = [ - "cmake", # For building binary targets. - "pip>=23", # For building the pip package. - "pyyaml", # Imported by the kernel codegen tools. - "setuptools>=63", # For building the pip package. - "tomli", # Imported by extract_sources.py when using python < 3.11. - "wheel", # For building the pip package archive. - "zstd", # Imported by resolve_buck.py. - "ai-edge-model-explorer>=0.1.16", # For visualizing ExportedPrograms ] # Assemble the list of requirements to actually install. # TODO: Add options for reducing the number of requirements. REQUIREMENTS_TO_INSTALL = ( - EXIR_REQUIREMENTS + DEVEL_REQUIREMENTS + EXAMPLES_REQUIREMENTS + EXIR_REQUIREMENTS + EXAMPLES_REQUIREMENTS ) # Install the requirements. `--extra-index-url` tells pip to look for package @@ -139,6 +121,10 @@ def install_requirements(use_pytorch_nightly): "-m", "pip", "install", + "-r", + "requirements-dev.txt", + "-r", + "requirements-examples.txt", *REQUIREMENTS_TO_INSTALL, "--extra-index-url", TORCH_NIGHTLY_URL, @@ -158,6 +144,8 @@ def install_requirements(use_pytorch_nightly): "-m", "pip", "install", + # Without --no-build-isolation, setup.py can't find the torch module. + "--no-build-isolation", *LOCAL_REQUIREMENTS, ], check=True, diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000000..4771fb13c3 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +# For visualizing ExportedPrograms +ai-edge-model-explorer >= 0.1.16 diff --git a/requirements-examples.txt b/requirements-examples.txt new file mode 100644 index 0000000000..d4126a178a --- /dev/null +++ b/requirements-examples.txt @@ -0,0 +1,5 @@ +# pip packages needed to run examples. +# TODO: Make each example publish its own requirements.txt +timm == 1.0.7 +torchsr == 1.0.4 +transformers ==4.47.1 From ac71f8dd53104b14599a5d8fced31160c724a82c Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 11:49:19 -0800 Subject: [PATCH 4/8] Update [ghstack-poisoned] --- install_requirements.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index e959b891bc..ac674770c9 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -109,9 +109,7 @@ def install_requirements(use_pytorch_nightly): # Assemble the list of requirements to actually install. # TODO: Add options for reducing the number of requirements. - REQUIREMENTS_TO_INSTALL = ( - EXIR_REQUIREMENTS + EXAMPLES_REQUIREMENTS - ) + REQUIREMENTS_TO_INSTALL = EXIR_REQUIREMENTS + EXAMPLES_REQUIREMENTS # Install the requirements. `--extra-index-url` tells pip to look for package # versions on the provided URL if they aren't available on the default URL. From 9a1dddefabce33c1cdd0a70b2b485d57f4610a91 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 13:35:16 -0800 Subject: [PATCH 5/8] Update [ghstack-poisoned] --- install_requirements.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index 0416a0710c..f2b4510a08 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -76,6 +76,9 @@ def clean(): print("Done cleaning build artifacts.") +VALID_PYBINDS = ["coreml", "mps", "xnnpack"] + + def main(args): if not python_is_compatible(): sys.exit(1) @@ -105,6 +108,11 @@ def main(args): help="build from the pinned PyTorch commit instead of nightly", ) args = parser.parse_args(args) + + if args.clean: + clean() + return + if args.pybind: # Flatten list of lists. args.pybind = list(itertools.chain(*args.pybind)) @@ -116,15 +124,13 @@ def main(args): EXECUTORCH_BUILD_PYBIND = "OFF" else: for pybind_arg in args.pybind: - if pybind_arg not in ["coreml", "mps", "xnnpack"]: - continue + if pybind_arg not in VALID_PYBINDS: + raise Exception( + f"Unrecognized pybind argument {pybind_arg}; valid options are: {", ".join(VALID_PYBINDS)}" + ) EXECUTORCH_BUILD_PYBIND = "ON" CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{pybind_arg.upper()}=ON" - if args.clean: - clean() - return - if args.use_pt_pinned_commit: # This option is used in CI to make sure that PyTorch build from the pinned commit # is used instead of nightly. CI jobs wouldn't be able to catch regression from the From a8933913fbd8ade1013248c79d74eabe5be568dc Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 14:11:23 -0800 Subject: [PATCH 6/8] Update [ghstack-poisoned] --- install_requirements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_requirements.py b/install_requirements.py index fc75011669..1081967d8f 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -209,7 +209,7 @@ def main(args): for pybind_arg in args.pybind: if pybind_arg not in VALID_PYBINDS: raise Exception( - f"Unrecognized pybind argument {pybind_arg}; valid options are: {", ".join(VALID_PYBINDS)}" + f"Unrecognized pybind argument {pybind_arg}; valid options are: {', '.join(VALID_PYBINDS)}" ) EXECUTORCH_BUILD_PYBIND = "ON" CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{pybind_arg.upper()}=ON" From bf753a8dfdab241785063d9d624adc84f171255a Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 14:20:01 -0800 Subject: [PATCH 7/8] Update [ghstack-poisoned] --- install_requirements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_requirements.py b/install_requirements.py index f2b4510a08..f1e0c75fd5 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -90,7 +90,7 @@ def main(args): CMAKE_BUILD_ARGS = os.getenv("CMAKE_BUILD_ARGS", "") USE_PYTORCH_NIGHTLY = True - parser = argparse.ArgumentParser(prog="install_requirements") + parser = argparse.ArgumentParser() parser.add_argument( "--pybind", action="append", From 1d4dfab7b47fed36dd2b5f5d53382e27272c7dc0 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 16 Jan 2025 15:31:09 -0800 Subject: [PATCH 8/8] Update [ghstack-poisoned] --- install_requirements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_requirements.py b/install_requirements.py index 649502c399..c16cacca46 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -126,7 +126,7 @@ def main(args): for pybind_arg in args.pybind: if pybind_arg not in VALID_PYBINDS: raise Exception( - f"Unrecognized pybind argument {pybind_arg}; valid options are: {", ".join(VALID_PYBINDS)}" + f"Unrecognized pybind argument {pybind_arg}; valid options are: {', '.join(VALID_PYBINDS)}" ) EXECUTORCH_BUILD_PYBIND = "ON" CMAKE_ARGS += f" -DEXECUTORCH_BUILD_{pybind_arg.upper()}=ON"