Skip to content

Commit 025cef0

Browse files
committed
fix USE_CPP=0 during local build
Summary: Looks like this env var no longer matches its original intent (Python-only build) as various other c++ extensions were added, fixing. Test Plan: ``` with-proxy USE_CPP=0 pip install -e . ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: a231a6e ghstack-comment-id: 2694959518 Pull Request resolved: #1812
1 parent 7963f9c commit 025cef0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

setup.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def read_version(file_path="version.txt"):
4747

4848
import platform
4949

50-
build_torchao_experimental = (
50+
build_cpp = (
5151
use_cpp == "1"
5252
and platform.machine().startswith("arm64")
5353
and platform.system() == "Darwin"
@@ -75,9 +75,9 @@ def use_debug_mode():
7575
CUDAExtension,
7676
)
7777

78-
build_torchao_experimental_mps = (
78+
build_cpp_mps = (
7979
os.getenv("TORCHAO_BUILD_EXPERIMENTAL_MPS") == "1"
80-
and build_torchao_experimental
80+
and build_cpp
8181
and torch.mps.is_available()
8282
)
8383

@@ -188,7 +188,7 @@ def build_cmake(self, ext):
188188
if not os.path.exists(self.build_temp):
189189
os.makedirs(self.build_temp)
190190

191-
build_mps_ops = "ON" if build_torchao_experimental_mps else "OFF"
191+
build_mps_ops = "ON" if build_cpp_mps else "OFF"
192192

193193
subprocess.check_call(
194194
[
@@ -214,6 +214,9 @@ def __init__(self, name, sourcedir=""):
214214

215215

216216
def get_extensions():
217+
if not build_cpp:
218+
return []
219+
217220
debug_mode = use_debug_mode()
218221
if debug_mode:
219222
print("Compiling in debug mode")
@@ -309,13 +312,12 @@ def get_extensions():
309312
)
310313
)
311314

312-
if build_torchao_experimental:
313-
ext_modules.append(
314-
CMakeExtension(
315-
"torchao.experimental",
316-
sourcedir="torchao/experimental",
317-
)
315+
ext_modules.append(
316+
CMakeExtension(
317+
"torchao.experimental",
318+
sourcedir="torchao/experimental",
318319
)
320+
)
319321

320322
return ext_modules
321323

0 commit comments

Comments
 (0)