Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

整理: ランタイム DLL ロードのコメント付け #1132

Merged
merged 4 commits into from
Mar 29, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions voicevox_engine/core/core_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ class CoreError(Exception):


def load_runtime_lib(runtime_dirs: list[Path]) -> None:
"""
ランタイム DLL をロードする。検索対象ディレクトリは引数 `runtime_dirs` およびシステム検索対象ディレクトリ。
tarepan marked this conversation as resolved.
Show resolved Hide resolved

Args:
runtime_dirs - 直下にランタイム DLL が存在するディレクトリの一覧
"""
# OS を検出し、対応する `lib_file_names` および `lib_names` を決定する
tarepan marked this conversation as resolved.
Show resolved Hide resolved
if platform.system() == "Windows":
# DirectML.dllはonnxruntimeと互換性のないWindows標準搭載のものを優先して読み込むことがあるため、明示的に読み込む
# 参考 1. https://github.com/microsoft/onnxruntime/issues/3360
Expand All @@ -40,12 +47,16 @@ def load_runtime_lib(runtime_dirs: list[Path]) -> None:
lib_names = ["onnxruntime"]
else:
raise RuntimeError("不明なOSです")
for lib_path in runtime_dirs:
for file_name in lib_file_names:

# 引数指定ディレクトリ直下のランタイム DLL をロードする
for runtime_dir in runtime_dirs:
for lib_file_name in lib_file_names:
try:
CDLL(str((lib_path / file_name).resolve(strict=True)))
CDLL(str((runtime_dir / lib_file_name).resolve(strict=True)))
except OSError:
pass

# システム検索ディレクトリ直下のランタイム DLL をロードする
for lib_name in lib_names:
try:
CDLL(find_library(lib_name))
Expand Down
Loading