mirror of
https://github.com/vllm-project/vllm.git
synced 2025-10-20 23:03:52 +08:00
[Doc] Add --force-overwrite option to generate_cmake_presets.py (#24375)
Signed-off-by: elvischenv <219235043+elvischenv@users.noreply.github.com>
This commit is contained in:
@ -40,6 +40,16 @@ python tools/generate_cmake_presets.py
|
||||
|
||||
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.
|
||||
|
||||
**Force overwrite existing file:**
|
||||
|
||||
To automatically overwrite an existing `CMakeUserPresets.json` without prompting, use the `--force-overwrite` flag:
|
||||
|
||||
```console
|
||||
python tools/generate_cmake_presets.py --force-overwrite
|
||||
```
|
||||
|
||||
This is particularly useful in automated scripts or CI/CD environments where interactive prompts are not desired.
|
||||
|
||||
After running the script, a `CMakeUserPresets.json` file will be created in the root of your vLLM repository.
|
||||
|
||||
### Example `CMakeUserPresets.json`
|
||||
|
@ -1,5 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import argparse
|
||||
import json
|
||||
import multiprocessing
|
||||
import os
|
||||
@ -26,7 +27,8 @@ def get_cpu_cores():
|
||||
return multiprocessing.cpu_count()
|
||||
|
||||
|
||||
def generate_presets(output_path="CMakeUserPresets.json"):
|
||||
def generate_presets(output_path="CMakeUserPresets.json",
|
||||
force_overwrite=False):
|
||||
"""Generates the CMakeUserPresets.json file."""
|
||||
|
||||
print("Attempting to detect your system configuration...")
|
||||
@ -143,9 +145,12 @@ def generate_presets(output_path="CMakeUserPresets.json"):
|
||||
output_file_path = os.path.join(project_root, output_path)
|
||||
|
||||
if os.path.exists(output_file_path):
|
||||
if force_overwrite:
|
||||
print(f"Overwriting existing file '{output_file_path}'")
|
||||
else:
|
||||
overwrite = input(
|
||||
f"'{output_file_path}' already exists. Overwrite? (y/N): ").strip(
|
||||
).lower()
|
||||
f"'{output_file_path}' already exists. Overwrite? (y/N): "
|
||||
).strip().lower()
|
||||
if overwrite != 'y':
|
||||
print("Generation cancelled.")
|
||||
return
|
||||
@ -166,4 +171,12 @@ def generate_presets(output_path="CMakeUserPresets.json"):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_presets()
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--force-overwrite",
|
||||
action="store_true",
|
||||
help="Force overwrite existing CMakeUserPresets.json without prompting"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
generate_presets(force_overwrite=args.force_overwrite)
|
||||
|
Reference in New Issue
Block a user