Skip to content

Commit 569962e

Browse files
jathukirklandsign
authored andcommitted
Turn on EXECUTORCH_BUILD_PYBIND when implicitly wanted (#9611)
### Summary We want `EXECUTORCH_BUILD_PYBIND` enabled if the user wants to build the bindings — so let's just do it. Unless of course, they explicitly choose not to by defining the arg themselves. ### Test plan CI cc @larryliu0820 @lucylq
1 parent 7cf498c commit 569962e

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

install_executorch.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def clean():
5252
print("Done cleaning build artifacts.")
5353

5454

55+
# Please keep this insync with `ShouldBuild.pybindings` in setup.py.
5556
VALID_PYBINDS = ["coreml", "mps", "xnnpack", "training"]
5657

5758

@@ -205,10 +206,8 @@ def main(args):
205206
cmake_args = [os.getenv("CMAKE_ARGS", "")]
206207
use_pytorch_nightly = True
207208

208-
has_pybindings = False
209209
wants_pybindings_off, pybind_defines = _list_pybind_defines(args)
210210
if not wants_pybindings_off:
211-
has_pybindings = True
212211
if len(pybind_defines) > 0:
213212
# If the user explicitly provides a list of bindings, just use them
214213
cmake_args += pybind_defines
@@ -217,9 +216,6 @@ def main(args):
217216
# a list, then turn on xnnpack by default
218217
cmake_args.append("-DEXECUTORCH_BUILD_XNNPACK=ON")
219218

220-
if has_pybindings:
221-
cmake_args.append("-DEXECUTORCH_BUILD_PYBIND=ON")
222-
223219
if args.clean:
224220
clean()
225221
return

setup.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,33 @@ def _is_cmake_arg_enabled(var: str, default: bool) -> bool:
107107

108108
@classmethod
109109
def pybindings(cls) -> bool:
110-
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_PYBIND", default=False)
110+
return cls._is_cmake_arg_enabled(
111+
"EXECUTORCH_BUILD_PYBIND",
112+
# If the user hasn't specified anything, we want to turn this on if any
113+
# bindings are requested explicitly.
114+
#
115+
# Please keep this in sync with `VALID_PYBINDS` in install_executorch.py.
116+
default=any(
117+
[
118+
cls.coreml(),
119+
cls.mps(),
120+
cls.xnnpack(),
121+
cls.training(),
122+
]
123+
),
124+
)
125+
126+
@classmethod
127+
def coreml(cls) -> bool:
128+
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_COREML", default=False)
129+
130+
@classmethod
131+
def mps(cls) -> bool:
132+
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_MPS", default=False)
133+
134+
@classmethod
135+
def xnnpack(cls) -> bool:
136+
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_XNNPACK", default=False)
111137

112138
@classmethod
113139
def training(cls) -> bool:

0 commit comments

Comments
 (0)