organize settings to dedicated sensors folder, json + assets
This commit is contained in:
@@ -5,6 +5,14 @@ from __future__ import annotations
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# Required files that must ship with the wheel for ORY-FINGER runtime/GUI.
|
||||
REQUIRED_ASSET_RELPATHS = (
|
||||
"finger/assets/30fps-0703/mesh.npz",
|
||||
"finger/assets/30fps-0703/camera_intrinsics.npz",
|
||||
"finger/assets/30fps-0703/world_to_cam.npy",
|
||||
"finger/assets/visualization/world_to_cam.npy",
|
||||
)
|
||||
|
||||
|
||||
def resolve_bundle_source_files(repo_root: Path, item: dict) -> list[Path]:
|
||||
"""Resolve explicit files and/or glob patterns for one bundle item."""
|
||||
@@ -37,6 +45,32 @@ def resolve_bundle_source_files(repo_root: Path, item: dict) -> list[Path]:
|
||||
return resolved
|
||||
|
||||
|
||||
def verify_required_assets(repo_root: Path, items: list[dict]) -> None:
|
||||
"""Fail early when required finger assets are missing from the bundle."""
|
||||
asset_items = [item for item in items if item.get("name") == "sensors"]
|
||||
if not asset_items:
|
||||
return
|
||||
|
||||
resolved: set[str] = set()
|
||||
for item in asset_items:
|
||||
src_dir = (repo_root / item["source"]).resolve()
|
||||
for path in resolve_bundle_source_files(repo_root, item):
|
||||
try:
|
||||
rel = path.resolve().relative_to(src_dir).as_posix()
|
||||
except ValueError:
|
||||
continue
|
||||
resolved.add(rel)
|
||||
|
||||
missing = [rel for rel in REQUIRED_ASSET_RELPATHS if rel not in resolved]
|
||||
if missing:
|
||||
joined = ", ".join(missing)
|
||||
raise FileNotFoundError(
|
||||
"Required finger assets are missing from the wheel bundle. "
|
||||
f"Missing: {joined}. Update [[tool.orisys.bundle.items]] patterns "
|
||||
"or restore assets under sensors/finger/assets/ before building."
|
||||
)
|
||||
|
||||
|
||||
def package_data_paths_for_item(item: dict) -> list[str]:
|
||||
"""Return setuptools package_data paths relative to the orisys package."""
|
||||
target = str(item["target"]).replace("\\", "/")
|
||||
@@ -54,6 +88,7 @@ def data_file_entries_for_item(item: dict) -> list[str]:
|
||||
|
||||
|
||||
def copy_bundle_items(repo_root: Path, pkg_dir: Path, items: list[dict]) -> dict[str, int]:
|
||||
verify_required_assets(repo_root, items)
|
||||
copied_counts: dict[str, int] = {}
|
||||
for item in items:
|
||||
name = item["name"]
|
||||
|
||||
Reference in New Issue
Block a user