litellm/tests/windows_tests/check_windows_wheel_install.py
yuneng-jiang 635a718ba1
ci: cut CircleCI wall time without loosening test isolation (#43347)
* ci: cut CircleCI wall time without loosening test isolation

* fix(ci): parse integration split files that follow --results

The CircleCI machine image ships Python 3.12.2, whose argparse leaves the
files positional empty when it follows an option and another positional, so
every extensions node exited with 'unrecognized arguments'. Reproduced on
3.12.2; parse_intermixed_args selects the files on 3.12.2, 3.12.13 and 3.13

* test(ci): resolve command references in the Rust toolchain guard

The Windows rustup install moved into the install_windows_toolchain command,
which the guard only recognized for install_rust. It now accepts any command
that installs a pinned rustup and reads the Windows toolchain pin from it

* ci: cache the Windows release cargo build from main

windows_release_wheel rebuilt every dependency with fat LTO on each run. It now
restores the release target and cargo registry saved by main's scheduled run,
drops the workspace crates' fingerprints so they always rebuild from the
checked-out source, and still runs the full LTO link

* ci: run the Windows release wheel build on windows.xlarge

The fat-LTO release build is the slowest job in the pipeline; more cores
speed up the dependency compile ahead of the final link

* ci: skip the Windows fingerprint cleanup when the cargo cache missed

On a cold cache the release fingerprint directory does not exist, and the
CircleCI PowerShell wrapper failed the step on the suppressed not-found error
2026-09-26 15:34:53 -07:00

79 lines
2.6 KiB
Python

"""Reproduce a default-Windows ``pip install litellm`` to catch the 260-char
MAX_PATH regression that content-filter benchmark fixtures keep reintroducing
(#21941, #22039, #29536). Run after ``uv build --wheel --out-dir dist``.
"""
import glob
import os
import subprocess
import sys
import zipfile
MAX_PATH = 260
# Worst-case Windows site-packages prefix: long profile name + roaming AppData venv.
WORST_CASE_PREFIX = 100
def overlong_install_paths(wheel, prefix_len=WORST_CASE_PREFIX, max_path=MAX_PATH):
with zipfile.ZipFile(wheel) as zf:
names = zf.namelist()
return sorted(
(n for n in names if prefix_len + len(n) > max_path), key=len, reverse=True
)
def _deep_venv_dir(target_prefix=WORST_CASE_PREFIX):
drive = os.path.splitdrive(os.getcwd())[0] or "C:"
root = drive + os.sep + "lmwin" + os.sep
# +2: the sep joining the venv root to "Lib", plus the trailing sep before the entry
suffix = len(os.path.join("Lib", "site-packages")) + 2
return root + "x" * (target_prefix - suffix - len(root))
def _run(cmd):
print("+ " + subprocess.list2cmdline(cmd), flush=True)
return subprocess.call(cmd)
def main(argv):
wheels = glob.glob(os.path.join("dist", "*.whl"))
if not wheels:
print("::error::no wheel in dist/; run `uv build --wheel --out-dir dist` first")
return 1
wheel = max(wheels, key=os.path.getmtime)
offenders = overlong_install_paths(wheel)
if offenders:
print(
f"::error::{len(offenders)} packaged path(s) bust the Windows MAX_PATH limit "
f"at a {WORST_CASE_PREFIX}-char install prefix:"
)
for n in offenders[:15]:
print(f" on-disk {WORST_CASE_PREFIX + len(n):4} {n}")
return 1
if "--lengths-only" in argv:
print(f"ok: every path in {os.path.basename(wheel)} fits MAX_PATH at a {WORST_CASE_PREFIX}-char prefix")
return 0
venv = _deep_venv_dir()
os.makedirs(os.path.dirname(venv), exist_ok=True)
if _run(["uv", "venv", venv]) != 0:
return 1
python = os.path.join(venv, "Scripts", "python.exe")
if _run(["uv", "pip", "install", "--python", python, wheel]) != 0:
print(
f"::error::installing {os.path.basename(wheel)} into a deep prefix failed"
)
return 1
if _run([python, "-c", "import litellm; import litellm.types.utils"]) != 0:
print("::error::litellm did not import after install (half-unpacked package)")
return 1
print(
f"ok: {os.path.basename(wheel)} installs into a worst-case prefix and imports"
)
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))