
    hr                        S r SSKrSSKrSSKrSSKrSSKJr  SSKrSSKJ	r	  \R                  " \5      r\" \5      R                  R                  S-  rS\4S jrS\S\4S jrS	 rS
 r " S S\R,                  5      rS rS rg)zModule to implement logics used for initializing extensions.

The implementations here should be stateless.
They should not depend on external state.
Anything that depends on external state should happen in __init__.py
    N)Path)eval_envlibc                 R    [         R                  S:X  a  SOSn[        U  SU 3-  nU$ )Nntpydso.)osname_LIB_DIR)r   suffixpaths      S/var/www/auris/envauris/lib/python3.13/site-packages/torchaudio/_extension/utils.py_get_lib_pathr      s-    ggoU4FQvh''DK    returnc                     [        U 5      nUR                  5       (       d  g[        R                  R	                  U5        g)a  Load extension module

Note:
    In case `torchaudio` is deployed with `pex` format, the library file
    is not in a standard location.
    In this case, we expect that `libtorchaudio` is available somewhere
    in the search path of dynamic loading mechanism, so that importing
    `_torchaudio` will have library loader find and load `libtorchaudio`.
    This is the reason why the function should not raising an error when the library
    file is not found.

Returns:
    bool:
        True if the library file is found AND the library loaded without failure.
        False if the library file is not found (like in the case where torchaudio
        is deployed with pex format, thus the shared library file is
        in a non-standard location.).
        If the library file is found but there is an issue loading the library,
        (such as missing dependency) then this function raises the exception as-is.

Raises:
    Exception:
        If the library file is found, but there is an issue loading the library file,
        (when underlying `ctype.DLL` throws an exception), this function will pass
        the exception as-is, instead of catching it and returning bool.
        The expected case is `OSError` thrown by `ctype.DLL` when a dynamic dependency
        is not found.
        This behavior was chosen because the expected failure case is not recoverable.
        If a dependency is missing, then users have to install it.
FT)r   existstorchopsload_library)r   r   s     r   	_load_libr      s1    > D;;==	II4 r   c                     [         R                  S:X  a  [        S5      e[        SS5      (       d  [        S5      eSn [        R
                  R                  U 5      (       d  [        S5      e[        S5        [        R                  " U 5      $ )	Nr   z)sox extension is not supported on WindowsTORCHAUDIO_USE_SOXTz1sox extension is disabled. (TORCHAUDIO_USE_SOX=0)ztorchaudio.lib._torchaudio_soxzfTorchAudio is not built with sox extension. Please build TorchAudio with libsox support. (BUILD_SOX=1)libtorchaudio_sox)	r   r   RuntimeErrorr   	importlibutil	find_specr   import_module)exts    r   _import_sox_extr#   @   s|    	ww$FGG($//NOO
*C>>##C((I
 	
 !"""3''r   c            	      p   [        5       n U R                  S5        SS Kn[        R                  R
                  R                  5         UR                  [        R                  R
                  R                  5        / SQnU H1  n[        X[        [        R                  R
                  U5      5        M3     U $ )Nr   )get_infoload_audio_filesave_audio_fileapply_effects_tensorapply_effects_file)r#   set_verbosityatexitr   r   torchaudio_soxinitialize_sox_effectsregistershutdown_sox_effectssetattrgetattr)r"   r+   keyskeys       r   	_init_soxr4   T   s    

Ca	II335
OOEII,,AAB
D '%))":":C@A  Jr   c                   J   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	rU =r$ )
_LazyImporterm   zLazily import module/extension.c                 >   > [         TU ]  U5        X l        S U l        g N)super__init__import_funcmodule)selfr   r<   	__class__s      r   r;   _LazyImporter.__init__p   s    &r   c                 N    U R                  5         [        U R                  U5      $ r9   )_import_oncer1   r=   )r>   items     r   __getattr___LazyImporter.__getattr__x   s    t{{D))r   c                     U R                   c4  SU R                   SU R                  R                   SU R                   S3$ [        U R                   5      $ )Nz	<module 'r
   z("z")'>)r=   
__module__r?   __name__r   reprr>   s    r   __repr___LazyImporter.__repr__|   sK    ;;t/q1H1H0ITYYKW\]]DKK  r   c                 L    U R                  5         [        U R                  5      $ r9   )rB   dirr=   rJ   s    r   __dir___LazyImporter.__dir__   s    4;;r   c                     U R                   cE  U R                  5       U l         U R                  R                  U R                   R                  5        g g r9   )r=   r<   __dict__updaterJ   s    r   rB   _LazyImporter._import_once   s?    ;;**,DK
 MM  !5!56 r   c                 F     U R                  5         g! [         a     gf = f)NFT)rB   	ExceptionrJ   s    r   is_available_LazyImporter.is_available   s,    	   		s    
  )r<   r=   )rH   rG   __qualname____firstlineno____doc__r;   rD   rK   rO   rB   rW   __static_attributes____classcell__)r?   s   @r   r6   r6   m   s)    )*!
 7 r   r6   c                     [         R                  R                  SS5      R                  S5       H@  n [         R                  R                  U 5      (       d  M)   [         R                  " U 5        MB     g ! [         a     MR  f = f)NPATH ;)r   environgetsplitr   r   add_dll_directoryrV   )r   s    r   _init_dll_pathrf      sb     

vr*00577>>$$$T* 6  s   A55
BBc                  \   SS K n U R                  R                  R                  5       nUb  [        R
                  R                  be  [        U5      nUS S  SUS    3n[        R
                  R                  R                  S5      nUS    SUS    3nX4:w  a  [        SU SU S35      eU$ )	Nr   r
      zjDetected that PyTorch and TorchAudio were compiled with different CUDA versions. PyTorch has CUDA version z% whereas TorchAudio has CUDA version zJ. Please install the TorchAudio version that matches your PyTorch version.)
torchaudio.lib._torchaudior   _torchaudiocuda_versionr   versioncudastrrd   r   )
torchaudiorn   version_str
ta_version	t_versions        r   _check_cuda_versionru      s    %nn((557Gu}}11='l#CR();r?*;<
MM&&,,S1	 |nAil^4	",,5;6[\f[g h[[ 
 Nr   )r[   r   loggingr   typespathlibr   r   !torchaudio._internal.module_utilsr   	getLoggerrH   _LG__file__parentr   rp   r   boolr   r#   r4   
ModuleTyper6   rf   ru    r   r   <module>r      s      	    6!>  ''%/s #3 #4 #L((2&E$$ &Rr   