Skip to content

Commit 512ea9d

Browse files
elvischenvxuebwang-amd
authored andcommitted
[Doc] Add --force-overwrite option to generate_cmake_presets.py (vllm-project#24375)
Signed-off-by: elvischenv <219235043+elvischenv@users.noreply.github.com> Signed-off-by: xuebwang-amd <xuebwang@amd.com>
1 parent 183140f commit 512ea9d

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

docs/contributing/incremental_build.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ python tools/generate_cmake_presets.py
4040

4141
The script will prompt you if it cannot automatically determine certain paths (e.g., `nvcc` or a specific Python executable for your vLLM development environment). Follow the on-screen prompts. If an existing `CMakeUserPresets.json` is found, the script will ask for confirmation before overwriting it.
4242

43+
**Force overwrite existing file:**
44+
45+
To automatically overwrite an existing `CMakeUserPresets.json` without prompting, use the `--force-overwrite` flag:
46+
47+
```console
48+
python tools/generate_cmake_presets.py --force-overwrite
49+
```
50+
51+
This is particularly useful in automated scripts or CI/CD environments where interactive prompts are not desired.
52+
4353
After running the script, a `CMakeUserPresets.json` file will be created in the root of your vLLM repository.
4454

4555
### Example `CMakeUserPresets.json`

tools/generate_cmake_presets.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3+
import argparse
34
import json
45
import multiprocessing
56
import os
@@ -26,7 +27,8 @@ def get_cpu_cores():
2627
return multiprocessing.cpu_count()
2728

2829

29-
def generate_presets(output_path="CMakeUserPresets.json"):
30+
def generate_presets(output_path="CMakeUserPresets.json",
31+
force_overwrite=False):
3032
"""Generates the CMakeUserPresets.json file."""
3133

3234
print("Attempting to detect your system configuration...")
@@ -143,12 +145,15 @@ def generate_presets(output_path="CMakeUserPresets.json"):
143145
output_file_path = os.path.join(project_root, output_path)
144146

145147
if os.path.exists(output_file_path):
146-
overwrite = input(
147-
f"'{output_file_path}' already exists. Overwrite? (y/N): ").strip(
148-
).lower()
149-
if overwrite != 'y':
150-
print("Generation cancelled.")
151-
return
148+
if force_overwrite:
149+
print(f"Overwriting existing file '{output_file_path}'")
150+
else:
151+
overwrite = input(
152+
f"'{output_file_path}' already exists. Overwrite? (y/N): "
153+
).strip().lower()
154+
if overwrite != 'y':
155+
print("Generation cancelled.")
156+
return
152157

153158
try:
154159
with open(output_file_path, "w") as f:
@@ -166,4 +171,12 @@ def generate_presets(output_path="CMakeUserPresets.json"):
166171

167172

168173
if __name__ == "__main__":
169-
generate_presets()
174+
parser = argparse.ArgumentParser()
175+
parser.add_argument(
176+
"--force-overwrite",
177+
action="store_true",
178+
help="Force overwrite existing CMakeUserPresets.json without prompting"
179+
)
180+
181+
args = parser.parse_args()
182+
generate_presets(force_overwrite=args.force_overwrite)

0 commit comments

Comments
 (0)