Skip to content

Commit 8d4a86d

Browse files
committed
parallel build
1 parent 12a2644 commit 8d4a86d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ jobs:
253253
- name: Install SDist
254254
env:
255255
CMAKE_ARGS: "-DBUILD_CMAKE_FROM_SOURCE:BOOL=OFF"
256+
CMAKE_BUILD_PARALLEL_LEVEL: "4"
256257
run: |
257258
python -m pip install -v --no-binary='cmake,ninja' dist/*.tar.gz
258259
rm -rf dist

_build_backend/backend.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,17 @@ def _bootstrap_build(temp_path: str, config_settings: dict[str, list[str] | str]
9696
with tarfile.open(source_tarball) as tar:
9797
tar.extractall(path=temp_path_, **tar_filter_kwargs)
9898

99+
parallel_str = env.get("CMAKE_BUILD_PARALLEL_LEVEL", "1")
100+
parallel = max(0, int(parallel_str) if parallel_str.isdigit() else 1) or os.cpu_count() or 1
101+
99102
bootstrap_path = next(temp_path_.glob("cmake-*/bootstrap"))
100103
prefix_path = temp_path_ / "cmake-install"
101-
bootstrap_args = [f"--prefix={prefix_path}", "--no-qt-gui", "--no-debugger"]
104+
bootstrap_args = [f"--prefix={prefix_path}", "--no-qt-gui", "--no-debugger", "--parallel={parallel}"]
102105
previous_cwd = Path().absolute()
103106
os.chdir(bootstrap_path.parent)
104107
try:
105108
subprocess.run([bootstrap_path, *bootstrap_args], env=env, check=True)
106-
subprocess.run([make_path], env=env, check=True)
109+
subprocess.run([make_path, "-j", f"{parallel}"], env=env, check=True)
107110
subprocess.run([make_path, "install"], env=env, check=True)
108111
finally:
109112
os.chdir(previous_cwd)

0 commit comments

Comments
 (0)