Skip to content

Turn on EXECUTORCH_BUILD_PYBIND when implicitly wanted #9611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions install_executorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
28 changes: 27 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading