File tree Expand file tree Collapse file tree
src/torchaudio/_extension Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121]
2222
2323
24- if os .name == "nt" and (3 , 8 ) <= sys .version_info < (3 , 9 ):
24+ if os .name == "nt" : # and (3, 8) <= sys.version_info < (3, 9):
2525 _init_dll_path ()
2626
2727# When the extension module is built, we initialize it.
2828# In case of an error, we do not catch the failure as it suggests there is something
2929# wrong with the installation.
3030_IS_TORCHAUDIO_EXT_AVAILABLE = _load_lib ("_torchaudio" )
31+ assert _IS_TORCHAUDIO_EXT_AVAILABLE
3132_IS_ALIGN_AVAILABLE = False
3233if _IS_TORCHAUDIO_EXT_AVAILABLE :
3334 if not _load_lib ("libtorchaudio" ):
Original file line number Diff line number Diff line change 77import logging
88import os
99import types
10+ import warnings
1011from pathlib import Path
1112
1213import torch
1617
1718
1819def _get_lib_path (lib : str ):
19- suffix = "pyd" if os .name == "nt" else "so"
20+ suffix = ".pyd" if os .name == "nt" else ".so"
21+ paths = _LIB_DIR .glob (f"{ lib } *{ suffix } " )
2022 path = _LIB_DIR / f"{ lib } .{ suffix } "
2123 return path
2224
@@ -52,10 +54,14 @@ def _load_lib(lib: str) -> bool:
5254 This behavior was chosen because the expected failure case is not recoverable.
5355 If a dependency is missing, then users have to install it.
5456 """
55- path = _get_lib_path (lib )
56- if not path .exists ():
57+ suffix = ".pyd" if os .name == "nt" else ".so"
58+ paths = list (_LIB_DIR .glob (f"{ lib } *{ suffix } " ))
59+ print (f"_load_lib: { lib = } { paths = } " )
60+ if not paths :
5761 return False
58- torch .ops .load_library (path )
62+ if len (paths ) > 1 :
63+ warnings .warn (f"Expected a single file path to { lib } , got { paths = } " )
64+ torch .ops .load_library (paths [0 ])
5965 return True
6066
6167
You can’t perform that action at this time.
0 commit comments