From 149e5bcc38164026fa44c7541b372307c1a988eb Mon Sep 17 00:00:00 2001 From: jathu Date: Tue, 25 Mar 2025 16:05:38 -0700 Subject: [PATCH] test --- install_executorch.py | 6 +----- setup.py | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/install_executorch.py b/install_executorch.py index dc06a5849f9..85703903ffc 100644 --- a/install_executorch.py +++ b/install_executorch.py @@ -52,6 +52,7 @@ def clean(): print("Done cleaning build artifacts.") +# Please keep this insync with `ShouldBuild.pybindings` in setup.py. VALID_PYBINDS = ["coreml", "mps", "xnnpack", "training"] @@ -205,10 +206,8 @@ def main(args): cmake_args = [os.getenv("CMAKE_ARGS", "")] use_pytorch_nightly = True - has_pybindings = False wants_pybindings_off, pybind_defines = _list_pybind_defines(args) if not wants_pybindings_off: - has_pybindings = True if len(pybind_defines) > 0: # If the user explicitly provides a list of bindings, just use them cmake_args += pybind_defines @@ -217,9 +216,6 @@ def main(args): # a list, then turn on xnnpack by default cmake_args.append("-DEXECUTORCH_BUILD_XNNPACK=ON") - if has_pybindings: - cmake_args.append("-DEXECUTORCH_BUILD_PYBIND=ON") - if args.clean: clean() return diff --git a/setup.py b/setup.py index fd19b5c690f..a1c94aee4e9 100644 --- a/setup.py +++ b/setup.py @@ -107,7 +107,33 @@ def _is_cmake_arg_enabled(var: str, default: bool) -> bool: @classmethod def pybindings(cls) -> bool: - return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_PYBIND", default=False) + return cls._is_cmake_arg_enabled( + "EXECUTORCH_BUILD_PYBIND", + # If the user hasn't specified anything, we want to turn this on if any + # bindings are requested explicitly. + # + # Please keep this in sync with `VALID_PYBINDS` in install_executorch.py. + default=any( + [ + cls.coreml(), + cls.mps(), + cls.xnnpack(), + cls.training(), + ] + ), + ) + + @classmethod + def coreml(cls) -> bool: + return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_COREML", default=False) + + @classmethod + def mps(cls) -> bool: + return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_MPS", default=False) + + @classmethod + def xnnpack(cls) -> bool: + return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_XNNPACK", default=False) @classmethod def training(cls) -> bool: