python: close runtime packaging and platform wheels
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import platform
|
||||
import stat
|
||||
from pathlib import Path
|
||||
|
||||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||
|
||||
|
||||
_PLATFORMS = {
|
||||
"linux-x64": ("manylinux_2_28_x86_64", "dsh-jsonrpc-agent-pkg-linux-x64"),
|
||||
"linux-arm64": ("manylinux_2_28_aarch64", "dsh-jsonrpc-agent-pkg-linux-arm64"),
|
||||
"macos-arm64": ("macosx_11_0_arm64", "dsh-jsonrpc-agent-pkg-macos-arm64"),
|
||||
}
|
||||
|
||||
|
||||
def _host_platform_tag() -> str:
|
||||
machine = platform.machine().lower()
|
||||
arch = "arm64" if machine in {"arm64", "aarch64"} else "x64" if machine in {"x86_64", "amd64"} else machine
|
||||
system = platform.system().lower()
|
||||
key = f"macos-{arch}" if system == "darwin" else f"linux-{arch}" if system == "linux" else system
|
||||
try:
|
||||
return _PLATFORMS[key][0]
|
||||
except KeyError as exc:
|
||||
raise RuntimeError(f"unsupported deepseek-harness-runtime-bin build platform: {key}") from exc
|
||||
|
||||
|
||||
class RuntimeBuildHook(BuildHookInterface):
|
||||
"""Assign the native wheel tag and reject incomplete or mixed-platform payloads."""
|
||||
|
||||
def initialize(self, version: str, build_data: dict[str, object]) -> None:
|
||||
if version == "editable":
|
||||
return
|
||||
if self.target_name == "sdist":
|
||||
raise RuntimeError(
|
||||
"deepseek-harness-runtime-bin is wheel-only; build and publish platform wheels only."
|
||||
)
|
||||
|
||||
platform_tag = os.environ.get("DSH_RUNTIME_PLATFORM_TAG") or _host_platform_tag()
|
||||
matches = [value for value in _PLATFORMS.values() if value[0] == platform_tag]
|
||||
if len(matches) != 1:
|
||||
supported = ", ".join(value[0] for value in _PLATFORMS.values())
|
||||
raise RuntimeError(
|
||||
f"unsupported DSH_RUNTIME_PLATFORM_TAG {platform_tag!r}; expected one of {supported}"
|
||||
)
|
||||
expected_executable = matches[0][1]
|
||||
runtime_dir = Path(self.root) / "src" / "deepseek_harness_runtime" / "runtime"
|
||||
executables = sorted(runtime_dir.glob("dsh-jsonrpc-agent-pkg-*") if runtime_dir.is_dir() else [])
|
||||
if [path.name for path in executables] != [expected_executable]:
|
||||
found = ", ".join(path.name for path in executables) or "none"
|
||||
raise RuntimeError(
|
||||
f"runtime wheel {platform_tag} must contain only {expected_executable}; found {found}"
|
||||
)
|
||||
if executables[0].stat().st_mode & stat.S_IXUSR == 0:
|
||||
raise RuntimeError(f"runtime executable is not executable: {executables[0]}")
|
||||
|
||||
build_data["pure_python"] = False
|
||||
build_data["infer_tag"] = False
|
||||
build_data["tag"] = f"py3-none-{platform_tag}"
|
||||
@@ -33,10 +33,14 @@
|
||||
"@deepseek-ai/dsh-llm-deepseek": "workspace:^",
|
||||
"@deepseek-ai/dsh-llm-pi-ai": "workspace:^",
|
||||
"@deepseek-ai/dsh-repeat-tool-guard": "workspace:^",
|
||||
"@deepseek-ai/dsh-sandbox": "workspace:^",
|
||||
"@deepseek-ai/dsh-scope": "workspace:^",
|
||||
"@deepseek-ai/dsh-session": "workspace:^",
|
||||
"@deepseek-ai/dsh-session-persistence": "workspace:^",
|
||||
"@deepseek-ai/dsh-session-persistence-jsonl": "workspace:^",
|
||||
"@deepseek-ai/dsh-session-persistence-sqlite": "workspace:^",
|
||||
"@deepseek-ai/dsh-skill": "workspace:^",
|
||||
"@deepseek-ai/dsh-skill-local": "workspace:^",
|
||||
"@deepseek-ai/dsh-subagent": "workspace:^",
|
||||
"@deepseek-ai/dsh-subagent-acp": "workspace:^",
|
||||
"@deepseek-ai/dsh-subagent-fork": "workspace:^",
|
||||
@@ -50,11 +54,13 @@
|
||||
"@deepseek-ai/dsh-tool-bash": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-cordis": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-fs": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-skill": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-subagent": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-todo": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-web": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-workflow": "workspace:^",
|
||||
"@deepseek-ai/dsh-tools": "workspace:^",
|
||||
"@deepseek-ai/dsh-user-approval": "workspace:^",
|
||||
"@deepseek-ai/dsh-user-interaction": "workspace:^",
|
||||
"@deepseek-ai/dsh-web": "workspace:^",
|
||||
"@deepseek-ai/dsh-web-fetch-local": "workspace:^",
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "deepseek-harness-runtime-bin"
|
||||
version = "0.0.0-dev"
|
||||
version = "0.0.0.dev0"
|
||||
description = "Pinned DeepSeek Harness runtime for the Python SDK"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
@@ -19,3 +19,7 @@ exclude = ["src/deepseek_harness_runtime/runtime/node"]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/deepseek_harness_runtime"]
|
||||
|
||||
[tool.hatch.build.targets.wheel.hooks.custom]
|
||||
|
||||
[tool.hatch.build.targets.sdist.hooks.custom]
|
||||
@@ -4,14 +4,14 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "deepseek-harness"
|
||||
version = "0.0.0-dev"
|
||||
version = "0.0.0.dev0"
|
||||
description = "Python SDK for DeepSeek Harness"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
license = { text = "BSD-3-Clause" }
|
||||
dependencies = [
|
||||
"pydantic>=2.12",
|
||||
"deepseek-harness-runtime-bin==0.0.0-dev",
|
||||
"deepseek-harness-runtime-bin==0.0.0.dev0",
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
|
||||
Reference in New Issue
Block a user