52 lines
2.5 KiB
Python
52 lines
2.5 KiB
Python
"""Run-owned Isaac configuration without unrelated robot demonstration downloads.
|
|
|
|
Derive both SDK profiles, retaining every renderer/physics setting and every
|
|
other dependency. Never edit the installed SDK or inherit persistent UI state.
|
|
"""
|
|
|
|
import hashlib
|
|
import json
|
|
import tomllib
|
|
from pathlib import Path
|
|
|
|
|
|
DEMO = '"isaacsim.robot.policy.examples" = {}'
|
|
BASE = '"isaacsim.exp.base" = {}'
|
|
|
|
|
|
def prepare_experience(apps, directory):
|
|
apps, directory = Path(apps).resolve(), Path(directory).resolve()
|
|
base_path = apps / "isaacsim.exp.base.kit"
|
|
python_path = apps / "isaacsim.exp.base.python.kit"
|
|
base, python = base_path.read_text(), python_path.read_text()
|
|
parsed_base, parsed_python = tomllib.loads(base), tomllib.loads(python)
|
|
if not all(p["package"]["version"] == "6.1.0" for p in (parsed_base, parsed_python)):
|
|
raise RuntimeError("Unsupported Isaac experience profile; expected 6.1.0")
|
|
if base.count(DEMO) != 1 or python.count(BASE) != 1:
|
|
raise RuntimeError("Isaac experience dependencies changed; review required")
|
|
if parsed_python["settings"]["app"]["settings"]["persistent"] is not False:
|
|
raise RuntimeError("Native simulation must not inherit persistent UI settings")
|
|
# JSON strings are also valid TOML strings, including Windows path escaping.
|
|
sdk = json.dumps(apps.as_posix())[1:-1]
|
|
base = base.replace(DEMO, "").replace("${app}", sdk)
|
|
python = python.replace(BASE, '"missioncore.native.base" = {}').replace("${app}", sdk)
|
|
# Keep the SDK search paths and add only this run's derived base profile.
|
|
folders = "'++' = ["
|
|
if python.count(folders) != 1:
|
|
raise RuntimeError("Isaac extension search paths changed; review required")
|
|
python = python.replace(folders, folders + "\n " + json.dumps(directory.as_posix()) + ",", 1)
|
|
tomllib.loads(base); tomllib.loads(python)
|
|
directory.mkdir(parents=True, exist_ok=True)
|
|
derived_base = directory / "missioncore.native.base.kit"
|
|
derived_python = directory / "missioncore.native.python.kit"
|
|
derived_base.write_text(base)
|
|
derived_python.write_text(python)
|
|
receipt = {
|
|
"schema_version": "missioncore.native-experience/v1",
|
|
"excluded_dependency": "isaacsim.robot.policy.examples",
|
|
"sources": {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in (base_path, python_path)},
|
|
"derived": {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in (derived_base, derived_python)},
|
|
}
|
|
(directory / "receipt.json").write_text(json.dumps(receipt, indent=2))
|
|
return str(derived_python)
|