|
2 | 2 |
|
3 | 3 | import ctypes |
4 | 4 | import importlib.util |
| 5 | +import json |
5 | 6 | import logging |
6 | 7 | import os |
7 | 8 | import re |
@@ -269,16 +270,41 @@ class repackage_wheel(build_ext): |
269 | 270 | """Extracts libraries and other files from an existing wheel.""" |
270 | 271 |
|
271 | 272 | def get_base_commit_in_main_branch(self) -> str: |
272 | | - import subprocess |
| 273 | + # Force to use the nightly wheel. This is mainly used for CI testing. |
| 274 | + if envs.VLLM_TEST_USE_PRECOMPILED_NIGHTLY_WHEEL: |
| 275 | + return "nightly" |
273 | 276 |
|
274 | 277 | try: |
| 278 | + # Get the latest commit hash of the upstream main branch. |
| 279 | + resp_json = subprocess.check_output([ |
| 280 | + "curl", "-s", |
| 281 | + "https://api.github.com/repos/vllm-project/vllm/commits/main" |
| 282 | + ]).decode("utf-8") |
| 283 | + upstream_main_commit = json.loads(resp_json)["sha"] |
| 284 | + |
| 285 | + # Check if the local main branch is up-to-date. This is to ensure |
| 286 | + # the base commit we found is the most recent commit on the main |
| 287 | + # branch. |
| 288 | + local_main_commit = subprocess.check_output( |
| 289 | + ["git", "rev-parse", "main"]).decode("utf-8").strip() |
| 290 | + if local_main_commit != upstream_main_commit: |
| 291 | + raise ValueError( |
| 292 | + f"Local main branch ({local_main_commit}) is not " |
| 293 | + "up-to-date with upstream main branch " |
| 294 | + f"({upstream_main_commit}). Please pull the latest " |
| 295 | + "changes from upstream main branch first.") |
| 296 | + |
| 297 | + # Then get the commit hash of the current branch that is the same as |
| 298 | + # the upstream main commit. |
275 | 299 | current_branch = subprocess.check_output( |
276 | 300 | ["git", "branch", "--show-current"]).decode("utf-8").strip() |
277 | 301 |
|
278 | 302 | base_commit = subprocess.check_output( |
279 | 303 | ["git", "merge-base", "main", |
280 | 304 | current_branch]).decode("utf-8").strip() |
281 | 305 | return base_commit |
| 306 | + except ValueError as err: |
| 307 | + raise ValueError(err) from None |
282 | 308 | except Exception as err: |
283 | 309 | logger.warning( |
284 | 310 | "Failed to get the base commit in the main branch. " |
|
0 commit comments