
    0-Ph                         d Z ddlZddlZddlZej                            ej                            e                    ZdZ	d Z
ddZddZdS )zG This module contains generic code to find and load a dynamic library.
    NFc                 ,   |                                  } t          j                            d          r|                     d          S t          j                            d          r|                     d          S |                     d          pd| v S )zReturns True if the given filename looks like a dynamic library.
    Based on extension, but cross-platform and more flexible.
    winz.dlldarwinz.dylibz.soz.so.)lowersysplatform
startswithendswith)fnames    T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/imageio/core/findlib.py	looks_libr      s     KKMME
|u%% 8~~f%%%		 	 	*	* 8~~h'''~~e$$7%7    c           	      
   |pg }g d}g d}d |D             }t          t          d          r|d |D             z  }t          j                            d          fddD             }||z   |z   |z   }g }|D ]:}t          j                            |          r||vr|                    |           ;g }|D ]}	t          j        |	          }
t          t          |
                    }
t          |
t          	          }
| D ]p}|
D ]k}|                                                    |          rBt          |          r3|                    t          j                            |	|                     lqd
 |D             }||fS )zGenerate a list of candidate filenames of what might be the dynamic
    library corresponding with the given list of names.
    Returns (lib_dirs, lib_paths)
    )z/libz/usr/libz/usr/lib/x86_64-linux-gnuz/usr/lib/aarch64-linux-gnuz/usr/local/libz/opt/local/lib)binlibDLLszLibrary/binsharedc                 b    g | ],}t           j                            t          j        |          -S  )ospathjoinr   prefix.0ds     r   
<listcomp>z+generate_candidate_libs.<locals>.<listcomp>3   s*    DDD127<<
A..DDDr   base_prefixc                 b    g | ],}t           j                            t          j        |          -S r   )r   r   r   r   r   r   s     r   r   z+generate_candidate_libs.<locals>.<listcomp>5   s*    NNNQS_a88NNNr   ~c                 P    g | ]"}t           j                            |          #S r   )r   r   r   )r   r   home_dirs     r   r   z+generate_candidate_libs.<locals>.<listcomp>9   s)    @@@1RW\\(A..@@@r   )r   )keyc                 P    g | ]#}t           j                            |          !|$S r   )r   r   isfile)r   lps     r   r   z+generate_candidate_libs.<locals>.<listcomp>Q   s+    >>>27>>"+=+=>>>>r   )hasattrr   r   r   
expanduserisdirappendlistdirreversedsortedlenr   r	   r   r   )	lib_nameslib_dirssys_lib_dirspy_sub_dirspy_lib_dirsuser_lib_dirspotential_lib_dirsld	lib_pathslib_dirfileslib_namer   r"   s                @r   generate_candidate_libsr;       s   
 ~2H  L BAAKDDDDDKsM"" ONN+NNNN w!!#&&H@@@@@@@M "L0;>NH     7== 	 8!3!3OOB I 	C 	C
7##''u#&&&! 	C 	CH C C;;==++H55 C)E:J:J C$$RW\\'5%A%ABBBC	C ?>i>>>IYr   c                 2   t          | t                    sJ t          |t                    sJ |t          |t                    sJ d | D             } d |D             }|r	|d         }n| r	| d         }nt          d          t          rg g }}nt	          ||          \  }}| |z   }t
          j                            d          rt          j	        }nt          j
        }d}g }|D ]K}	 |                    |          } n2# t          $ r%}	|| vr|                    ||	f           Y d}	~	Dd}	~	ww xY w|`|r5d |D             }
d}t          ||d	                    |
          fz            d
}t          ||d                    |          fz            ||fS )a  load_lib(exact_lib_names, lib_names, lib_dirs=None)

    Load a dynamic library.

    This function first tries to load the library from the given exact
    names. When that fails, it tries to find the library in common
    locations. It searches for files that start with one of the names
    given in lib_names (case insensitive). The search is performed in
    the given lib_dirs and a set of common library dirs.

    Returns ``(ctypes_library, library_path)``
    Nc                     g | ]}||S r   r   r   ns     r   r   zload_lib.<locals>.<listcomp>h   s    777QQ7q777r   c                     g | ]}||S r   r   r>   s     r   r   zload_lib.<locals>.<listcomp>i   s    +++q++++r   r   zNo library name given.r   c                 <    g | ]\  }}|d t          |          S )z:
)str)r   r   es      r   r   zload_lib.<locals>.<listcomp>   s-    FFFVS!CCCQ0FFFr   z\One or more %s libraries were found, but could not be loaded due to the following errors:
%sz

z)Could not find a %s library in any of:
%s
)
isinstancelist
ValueErrorSYSTEM_LIBS_ONLYr;   r   r   r	   ctypeswindllcdllLoadLibrary	Exceptionr*   OSErrorr   )exact_lib_namesr/   r0   the_lib_namer7   loaderthe_liberrorsr   errerr_txtmsgs               r   load_librW   U   s    ot,,,,,i&&&&&(D)))))77/777O++I+++I  3 |	 3&q)1222
  K ")5iJJ))+I |u%%  GF 	, 	,	,((//GE 	, 	, 	, O++ucl+++	,  	E GFvFFFGI  #v{{7/C/C DDEEE ?C#tyy/B/B CCDDD E>s   *D
D0D++D0)N)__doc__r   r   rI   r   abspathdirname__file__LOCALDIRrH   r   r;   rW   r   r   r   <module>r]      s   
  
			 



  7??27??84455  
8 
8 
82 2 2 2jL L L L L Lr   