icub_pybullet.runtime_paths

Cross-platform runtime paths, user workspace/cache helpers, config/mesh resolution, and OS-agnostic process/network utilities for pyCub.

Attributes

SKIP_IFACE_PREFIXES

Functions

user_documents_dir() → str

Return the fallback path to the user's Documents directory.

is_frozen() → bool

Return True when running inside a frozen bundle (e.g. PyInstaller).

to_posix(path) → str

Normalize a path and convert separators to forward slashes (safe inside URDF XML on Windows).

is_writable_dir(directory) → bool

Return True only if directory is writable and NOT inside a frozen bundle directory.

get_user_workspace_dir() → pathlib.Path

Return the user's writable pyCub workspace directory (default: ~/Documents/pyCub).

ensure_user_workspace() → pathlib.Path

Ensure standard user workspace subdirectories exist and return root path.

get_extra_packages_dir() → pathlib.Path

Return the writable extra Python packages directory (~/Documents/pyCub/extra_packages).

get_user_cache_dir() → pathlib.Path

Return writable cache directory for generated URDFs and dynamic VHACD collision meshes.

get_user_log_dir([package_dir]) → pathlib.Path

Return writable log directory (falls back to user data dir when package_dir/logs is read-only).

write_text_atomic(target_path, content) → str

Write text atomically via temp file + os.replace so concurrent instances never read partial URDFs.

resolve_config_path(config, package_dir[, caller_file]) → str

Resolve a YAML config path across:

resolve_robot_urdf_path(robot_urdf_rel, package_dir[, ...]) → str

Resolve robot_urdf_path across absolute path, config dir, user workspace, and bundled package dir.

resolve_mesh_or_urdf_path(obj_path, package_dir[, ...]) → str

Resolve an object .obj or .urdf path referenced in config.urdfs.paths across:

file_fingerprint(path) → str

Fast fingerprint combining canonical path, size, and mtime_ns.

get_vhacd_cache_path(col_path[, force_vhacd]) → Tuple[str, bool]

Locate an existing pre-baked *_vhacd.obj or return a writable cache path.

get_cached_urdf_path(stem, key[, subdir]) → str

Return a deterministic path in the user cache for a generated/patched URDF.

local_ipv4_addresses() → List[str]

Cross-platform IPv4 LAN addresses discovery (Windows, macOS, Linux).

terminate_process_tree(procs[, timeout]) → None

Cross-platform termination of child processes and all their descendants using psutil.

Module Contents

icub_pybullet.runtime_paths.user_documents_dir() → str

Return the fallback path to the user’s Documents directory.

icub_pybullet.runtime_paths.SKIP_IFACE_PREFIXES = ('lo', 'docker', 'br-', 'veth', 'virbr', 'lxc', 'tailscale', 'utun', 'awdl', 'llw')
icub_pybullet.runtime_paths.is_frozen() → bool

Return True when running inside a frozen bundle (e.g. PyInstaller).

icub_pybullet.runtime_paths.to_posix(path: str | os.PathLike) → str

Normalize a path and convert separators to forward slashes (safe inside URDF XML on Windows).

icub_pybullet.runtime_paths.is_writable_dir(directory: str | os.PathLike) → bool

Return True only if directory is writable and NOT inside a frozen bundle directory.

icub_pybullet.runtime_paths.get_user_workspace_dir() → pathlib.Path

Return the user’s writable pyCub workspace directory (default: ~/Documents/pyCub).

icub_pybullet.runtime_paths.ensure_user_workspace() → pathlib.Path

Ensure standard user workspace subdirectories exist and return root path.

icub_pybullet.runtime_paths.get_extra_packages_dir() → pathlib.Path

Return the writable extra Python packages directory (~/Documents/pyCub/extra_packages).

icub_pybullet.runtime_paths.get_user_cache_dir() → pathlib.Path

Return writable cache directory for generated URDFs and dynamic VHACD collision meshes.

icub_pybullet.runtime_paths.get_user_log_dir(package_dir: str | None = None) → pathlib.Path

Return writable log directory (falls back to user data dir when package_dir/logs is read-only).

icub_pybullet.runtime_paths.write_text_atomic(target_path: str | os.PathLike, content: str) → str

Write text atomically via temp file + os.replace so concurrent instances never read partial URDFs.

icub_pybullet.runtime_paths.resolve_config_path(config: str, package_dir: str, caller_file: str | None = None) → str
Resolve a YAML config path across:
  1. Direct / absolute path or relative to CWD

  2. Relative to caller script directory

  3. User workspace (~/Documents/pyCub/worlds, configs, root)

  4. Bundled icub_pybullet/configs

icub_pybullet.runtime_paths.resolve_robot_urdf_path(robot_urdf_rel: str, package_dir: str, config_dir: str | None = None) → str

Resolve robot_urdf_path across absolute path, config dir, user workspace, and bundled package dir.

icub_pybullet.runtime_paths.resolve_mesh_or_urdf_path(obj_path: str, package_dir: str, config_dir: str | None = None) → str
Resolve an object .obj or .urdf path referenced in config.urdfs.paths across:
  1. Absolute path

  2. Relative to the loaded config file’s directory

  3. Relative to CWD

  4. User workspace (~/Documents/pyCub/meshes and root)

  5. Bundled icub_pybullet/other_meshes and package root

icub_pybullet.runtime_paths.file_fingerprint(path: str) → str

Fast fingerprint combining canonical path, size, and mtime_ns.

icub_pybullet.runtime_paths.get_vhacd_cache_path(col_path: str, force_vhacd: bool = False) → Tuple[str, bool]

Locate an existing pre-baked *_vhacd.obj or return a writable cache path. Returns (vhacd_mesh_path, needs_compute).

icub_pybullet.runtime_paths.get_cached_urdf_path(stem: str, key: str, subdir: str = 'generated_urdf') → str

Return a deterministic path in the user cache for a generated/patched URDF.

icub_pybullet.runtime_paths.local_ipv4_addresses() → List[str]

Cross-platform IPv4 LAN addresses discovery (Windows, macOS, Linux).

icub_pybullet.runtime_paths.terminate_process_tree(procs: Iterable, timeout: float = 5.0) → None

Cross-platform termination of child processes and all their descendants using psutil.