[edge-infer] vllm_omni.windows: host-OS compatibility plugin for native Windows
One package that makes the POSIX assumptions measured in W0-W8 hold in every process vLLM / vLLM-Omni starts, and reports what it did: - provides fcntl (flock/lockf on msvcrt.locking; LOCK_SH served as exclusive) and uvloop (asyncio.run on a selector loop) when absent; - installs WindowsSelectorEventLoopPolicy and a signal.signal fallback for loop.add_signal_handler on the Windows loop classes; - replaces whole vLLM's get_open_zmq_ipc_path / find_loaded_library when the wheel lacks the branch patch and the upstream body hash is known; - verifies the wheel-only sites (sentinel poll, int64 seed) and reports wheel_required at the exact site instead of failing downstream; - shm_dir() replaces the /dev/shm literals; os.geteuid provided. Activated from vllm_omni/patch.py and as vllm.general_plugins / vllm_omni.general_plugins entry points (idempotent; no-op off Windows). prints the audit; the M0 placement report embeds it. 16 Linux tests through injected primitives. Design: analysis/design_windows_compat_plugin_20260921.md Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
97d97b6503
commit
00510ce38b
15 files changed
+1050
-2
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Filesystem places POSIX code hard-codes, and the one ``os`` function Windows lacks."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
_POSIX_SHM = "/dev/shm"
|
||||
|
||||
|
||||
def shm_dir() -> str:
|
||||
"""The directory for ``/dev/shm``-style lock and ack files.
|
||||
|
||||
``/dev/shm`` where it exists (Linux, WSL). On Windows a per-user directory
|
||||
under ``%LOCALAPPDATA%`` (falling back to the temp dir), created on first
|
||||
use. Callers that used to write ``f"/dev/shm/..."`` go through this so the
|
||||
path is the same on every platform that has one and a real one elsewhere.
|
||||
"""
|
||||
if os.path.isdir(_POSIX_SHM):
|
||||
return _POSIX_SHM
|
||||
base = os.environ.get("LOCALAPPDATA") or tempfile.gettempdir()
|
||||
path = Path(base) / "vllm_omni" / "shm"
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
return str(path)
|
||||
|
||||
|
||||
def shm_path(name: str) -> str:
|
||||
return os.path.join(shm_dir(), name)
|
||||
|
||||
|
||||
def provide_geteuid() -> str:
|
||||
"""``os.geteuid``/``os.getuid`` do not exist on Windows.
|
||||
|
||||
``host_weight_runtime`` compares ``st_uid`` against ``os.geteuid()`` for a
|
||||
"did we create this" check; Windows ``os.stat`` reports ``st_uid == 0``, so
|
||||
returning 0 makes the comparison mean the same thing it can mean there.
|
||||
"""
|
||||
if sys.platform != "win32":
|
||||
return "n/a"
|
||||
if hasattr(os, "geteuid"):
|
||||
return "already" if getattr(os.geteuid, "__vllm_omni_windows__", False) else "real"
|
||||
|
||||
def geteuid() -> int:
|
||||
return 0
|
||||
|
||||
geteuid.__vllm_omni_windows__ = True # type: ignore[attr-defined]
|
||||
os.geteuid = geteuid # type: ignore[attr-defined]
|
||||
if not hasattr(os, "getuid"):
|
||||
os.getuid = geteuid # type: ignore[attr-defined]
|
||||
return "provided"
|
||||
Reference in new issue
Block a user