Skip to content

Commit 94ab2de

Browse files
authored
Merge pull request #523 from miaooo0000OOOO/main
optimize CMake multi core parallel
2 parents 72d09f3 + 0cdc446 commit 94ab2de

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,13 @@ def build_extension(self, ext) -> None:
308308
"-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
309309

310310
if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
311+
cpu_count = os.cpu_count()
312+
if cpu_count is None:
313+
cpu_count = 1
311314
if hasattr(self, "parallel") and self.parallel:
312-
build_args += [f"-j{self.parallel}"]
315+
build_args += [f"--parallel={self.parallel}"]
316+
else:
317+
build_args += [f"--parallel={cpu_count}"]
313318
print("CMake args:", cmake_args)
314319
build_temp = Path(ext.sourcedir) / "build"
315320
if not build_temp.exists():

0 commit comments

Comments
 (0)