Buckets:
bbkdevops/unicosys-hypergraph-bucket / tinymind-native-8b-remote-handoff /bundle /model /sandbox_sdk_profile.py
| """SDK inventory profile for TinyMind sandbox environments.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| import json | |
| from pathlib import Path | |
| import shutil | |
| import subprocess | |
| from typing import Iterable | |
| class SDKSpec: | |
| language: str | |
| commands: tuple[str, ...] | |
| install_hint_linux: str | |
| SDK_SPECS: tuple[SDKSpec, ...] = ( | |
| SDKSpec("C/C++", ("gcc", "g++", "clang", "clang++", "cmake", "make"), "apk/apt install build-base clang cmake make"), | |
| SDKSpec("Rust", ("rustc", "cargo"), "install rustup, then rustup toolchain install stable"), | |
| SDKSpec("Python", ("python", "python3", "pip", "pip3"), "apk/apt install python3 py3-pip"), | |
| SDKSpec("Node.js/TypeScript", ("node", "npm", "npx", "tsc"), "install nodejs npm typescript"), | |
| SDKSpec("Go", ("go",), "install golang"), | |
| SDKSpec("Java/Kotlin", ("java", "javac", "jar", "gradle", "kotlinc"), "install openjdk gradle kotlin"), | |
| SDKSpec("C#", ("dotnet",), "install dotnet-sdk"), | |
| SDKSpec("Lua", ("lua", "luac"), "install lua"), | |
| SDKSpec("Ruby", ("ruby", "gem"), "install ruby"), | |
| SDKSpec("PHP", ("php", "composer"), "install php composer"), | |
| SDKSpec("Swift", ("swift", "swiftc"), "install swift toolchain"), | |
| SDKSpec("Shell/Linux Base", ("git", "tar", "gzip", "bzip2", "zstd", "openssl", "find", "which", "whois", "dig", "ping"), "already declared in base package set"), | |
| ) | |
| def command_version(command: str) -> dict: | |
| path = shutil.which(command) | |
| if not path: | |
| return {"command": command, "present": False, "path": None, "version": None} | |
| version = "" | |
| for args in ([command, "--version"], [command, "-version"], [command, "-v"]): | |
| try: | |
| proc = subprocess.run( | |
| args, | |
| capture_output=True, | |
| text=True, | |
| encoding="utf-8", | |
| errors="replace", | |
| timeout=5, | |
| check=False, | |
| ) | |
| except (OSError, subprocess.SubprocessError): | |
| continue | |
| text = (proc.stdout or proc.stderr).strip() | |
| if text: | |
| version = text.splitlines()[0][:240] | |
| break | |
| return {"command": command, "present": True, "path": path, "version": version} | |
| def build_sdk_inventory(out_dir: str | Path, specs: Iterable[SDKSpec] = SDK_SPECS) -> dict: | |
| rows = [] | |
| for spec in specs: | |
| commands = [command_version(cmd) for cmd in spec.commands] | |
| rows.append( | |
| { | |
| "language": spec.language, | |
| "commands": commands, | |
| "present_commands": [cmd["command"] for cmd in commands if cmd["present"]], | |
| "missing_commands": [cmd["command"] for cmd in commands if not cmd["present"]], | |
| "ready": any(cmd["present"] for cmd in commands), | |
| "install_hint_linux": spec.install_hint_linux, | |
| } | |
| ) | |
| report = { | |
| "schema_version": "tinymind-sandbox-sdk-inventory-v1", | |
| "base_system": "linux", | |
| "declared_base_packages": [ | |
| "bind-utils", | |
| "bzip2", | |
| "findutils", | |
| "git", | |
| "gzip", | |
| "iputils", | |
| "libicu", | |
| "libjpeg", | |
| "libpng", | |
| "ncurses-libs", | |
| "openssl", | |
| "openssl-libs", | |
| "procps", | |
| "tar", | |
| "unzip", | |
| "which", | |
| "whois", | |
| "zstd", | |
| ], | |
| "sdks": rows, | |
| "summary": { | |
| "languages_total": len(rows), | |
| "languages_with_any_command_present": sum(1 for row in rows if row["ready"]), | |
| "fully_installed_claim_allowed": all(not row["missing_commands"] for row in rows), | |
| }, | |
| } | |
| out = Path(out_dir) | |
| out.mkdir(parents=True, exist_ok=True) | |
| json_path = out / "sandbox_sdk_inventory.json" | |
| report["json_path"] = str(json_path) | |
| json_path.write_text(json.dumps(report, ensure_ascii=False, indent=2, sort_keys=True), encoding="utf-8") | |
| return report | |
Xet Storage Details
- Size:
- 4.05 kB
- Xet hash:
- 62ed5773c34462db473e68d6ae788e84c10dd4743056a4f0a3bef3eb7948e4de
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.