Coverage for src/videodataset/__init__.py: 84%
19 statements
« prev ^ index » next coverage.py v7.11.3, created at 2025-12-25 11:33 +0800
« prev ^ index » next coverage.py v7.11.3, created at 2025-12-25 11:33 +0800
1"""
2Copyright (c) 2025 agibot. All rights reserved.
4videodataset: A GPU-accelerated library that enables random frame access and efficient video decoding for data loading.
5"""
7from __future__ import annotations
9import importlib
10import os
11import platform
14def _setup_environment() -> None:
15 """Setup environment variables and paths"""
16 if platform.system() == "Linux":
17 # Linux: Update LD_LIBRARY_PATH
18 lib_paths: list[str] = []
20 # Add torch library path for _decoder extension
21 try:
22 torch = importlib.import_module("torch")
23 lib_paths.append(torch.__path__[0] + "/lib")
24 except ImportError as e:
25 err_msg = "Unable to import torch. Please ensure torch is installed."
26 raise ImportError(err_msg) from e
28 if "LD_LIBRARY_PATH" in os.environ:
29 lib_paths.extend(os.environ["LD_LIBRARY_PATH"].split(":"))
31 os.environ["LD_LIBRARY_PATH"] = ":".join(filter(None, lib_paths))
34_setup_environment()
36from videodataset._decoder import VideoDecoder # noqa: E402
38__all__ = ["VideoDecoder"]