feat(sdk): bundle shared Office authoring resources
This commit is contained in:
1 parent
1e3afc63ad
commit
37983d9298
28 files changed
+367
-58
No files matched your search
@@ -8,6 +8,7 @@ import email
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
@@ -227,6 +228,8 @@ def stage_runtime(destination: Path, version: str, executable: Path, executable_
|
||||
shutil.copy2(source_directory / filename, runtime_dir / filename)
|
||||
office = office_sidecar_name(executable_name)
|
||||
shutil.copytree(source_directory / office, runtime_dir / office)
|
||||
resources = f"{executable_name.removesuffix('.exe')}-resources"
|
||||
shutil.copytree(source_directory / resources, runtime_dir / resources)
|
||||
|
||||
|
||||
def verify_office_payload(archive: zipfile.ZipFile, office_modules: str, platform_tag: str) -> None:
|
||||
@@ -272,16 +275,17 @@ def verify_wheel(
|
||||
platform: tuple[str, str] | None,
|
||||
) -> None:
|
||||
expected_tag = "py3-none-any" if platform is None else f"py3-none-{platform[0]}"
|
||||
expected_distribution = SDK_DISTRIBUTION if package == "sdk" else RUNTIME_DISTRIBUTION
|
||||
dist_info = f"{expected_distribution.replace('-', '_')}-{version}.dist-info"
|
||||
with zipfile.ZipFile(wheel) as archive:
|
||||
wheel_metadata_path = next(name for name in archive.namelist() if name.endswith(".dist-info/WHEEL"))
|
||||
metadata_path = next(name for name in archive.namelist() if name.endswith(".dist-info/METADATA"))
|
||||
wheel_metadata_path = f"{dist_info}/WHEEL"
|
||||
metadata_path = f"{dist_info}/METADATA"
|
||||
wheel_metadata = email.message_from_bytes(archive.read(wheel_metadata_path))
|
||||
metadata = email.message_from_bytes(archive.read(metadata_path))
|
||||
if wheel_metadata.get_all("Tag") != [expected_tag]:
|
||||
raise RuntimeError(f"{wheel} has wrong WHEEL tags: {wheel_metadata.get_all('Tag')}")
|
||||
if metadata.get("Version") != version:
|
||||
raise RuntimeError(f"{wheel} has version {metadata.get('Version')}, expected {version}")
|
||||
expected_distribution = SDK_DISTRIBUTION if package == "sdk" else RUNTIME_DISTRIBUTION
|
||||
if metadata.get("Name") != expected_distribution:
|
||||
raise RuntimeError(
|
||||
f"{wheel} has distribution name {metadata.get('Name')}, expected {expected_distribution}"
|
||||
@@ -302,12 +306,16 @@ def verify_wheel(
|
||||
if package == "runtime":
|
||||
assert platform is not None
|
||||
office = office_sidecar_name(platform[1])
|
||||
expected_files = sorted((*runtime_filenames(platform[1]), office))
|
||||
resources = f"{platform[1].removesuffix('.exe')}-resources"
|
||||
expected_files = sorted((*runtime_filenames(platform[1]), office, resources))
|
||||
found_files = sorted({name.split("/runtime/", 1)[1].split("/", 1)[0] for name in runtime_payload})
|
||||
if found_files != expected_files:
|
||||
raise RuntimeError(f"{wheel} runtime payload must be {expected_files}, found {found_files}")
|
||||
office_modules = f"deepseek_harness_runtime/runtime/{office}/node_modules"
|
||||
verify_office_payload(archive, office_modules, platform[0])
|
||||
validate = runpy.run_path(str(ROOT / "python/sdk-runtime/src/deepseek_harness_runtime/_resources.py"))["validate_resources"]
|
||||
target = next(name for name, value in PLATFORMS.items() if value == platform)
|
||||
validate(zipfile.Path(archive, f"deepseek_harness_runtime/runtime/{resources}/"), target)
|
||||
for runtime_file in runtime_payload:
|
||||
if "/" in runtime_file.split("/runtime/", 1)[1]:
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user