
    q&i1                         S SK r S SKr/ SQrS SKJrJr   " S S\5      r " S S\5      rS\	4S	 jr
\
r " S
 S5      r " S S\5      r " S S\5      r\R                  4S jr " S S\5      rg)    N)getDefaultJVMPathget_default_jvm_pathJVMNotFoundExceptionJVMNotSupportedException)SequenceTuplec                       \ rS rSrSrSrg)r      a4  Exception raised when no JVM was found in the search path.

This exception is raised when the all of the places searched did not
contain a JVM. The locations searched depend on the machine architecture.
To avoid this exception specify the JAVA_HOME environment variable as a
valid jre or jdk root directory.
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r       P/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/jpype/_jvmfinder.pyr   r      s    r   r   c                       \ rS rSrSrSrg)r   )   aP  Exception raised when the JVM is not supported.

This exception is raised after a search found a valid Java home directory
was found, but the JVM shared library found is not supported. Typically
this occurs when the JVM does not match the architecture of Python
32 vs 64 bit, or the JVM is older than the version used to compile
JPype.
r   Nr   r   r   r   r   r   )   s    r   r   returnc                      [         R                  S:X  a  [        5       n U R                  5       $ [         R                  S:X  a  [        5       n U R                  5       $ [	        5       n U R                  5       $ )a/  Retrieves the path to the default or first found JVM library.

Returns:
  The path to the JVM shared library file

Raises:
  JVMNotFoundException: If there was no JVM found in the search path.
  JVMNotSupportedException: If the JVM was found was not compatible with
    Python due to cpu architecture.

win32darwin)sysplatformWindowsJVMFinderDarwinJVMFinderLinuxJVMFinderget_jvm_path)finders    r   r   r   4   si     ||w!#
   	 
	! "     !  r   c                   t    \ rS rSr% SrSr\\S'   Sr\	\S4   \S'   S r
S	 r\S
 5       rS rS rS rS rSrg)	JVMFinderL   zJVM library finder base class.	libjvm.so_libfile)/usr/lib/jvm	/usr/java.
_locationsc                 >    U R                   U R                  4U l        g N)_get_from_java_home_get_from_known_locations_methods)selfs    r   __init__JVMFinder.__init__T   s    11779r   c                    SnSn[        [        R                  " U5      S S9 Hl  u  pEnU R                  U;   d  M  [        R                  R                  U5      S   nXr;   a  SnMC  [        R                  R                  X@R                  5      s  $    U(       a  [        SR                  W5      5      e[        S5      e)	zRecursively looks for the given file.

Parameters:
    java_home(str): A Java home folder

Returns:
    The first found file path, or None
)cacaojamvmFc                 X    [        U S   R                  [        R                  5      5      $ )Nr   )lensplitossep)ts    r   <lambda>'JVMFinder.find_libjvm.<locals>.<lambda>f   s    s1Q4::VXV\V\K]G^r   )key   TzySorry '{0}' is known to be broken. Please ensure your JAVA_HOME contains at least another JVM implementation (eg. server)zsSorry no JVM could be found. Please ensure your JAVA_HOME environment variable is pointing to correct installation.)
sortedr8   walkr&   pathr7   joinr   formatr   )r/   	java_homenon_supported_jvmfound_non_supported_jvmroot_names	candidates           r   find_libjvmJVMFinder.find_libjvmY   s     /"' %RWWY%7=^_NDU}}%GGMM$/2	1.2+ww||D--88 ` #* ,:
 -3F9,=? ? # $> ? 	?r   c              #   6  #    / nSnU  GH
  n[         R                  R                  U5      (       d  M*  [        [         R                  " U5      5       H  n[         R                  R                  [         R                  R                  X45      5      nXQ;   d$  [         R                  R                  U5      (       d  Mj  [         R                  R                  U5      R                  5       nU H   nXv;   d  M
  UR                  U5        Uv     M     M     GM     g7f)z
Generator that looks for the first-level children folders that could be
Java installations, according to their name

Parameters:
    parents (str[]): A list of parent directories

Returns:
    A list of the possible JVM installation folders
)jrejdkjavaN)r8   rA   existsr?   listdirrealpathrB   isdirbasenamelowerappend)parentshomes
java_namesparent	childnamerA   	real_name	java_names           r   find_possible_homesJVMFinder.find_possible_homes|   s      +
F77>>&))#BJJv$67	ww''V(GH=d(;(; GG,,T288:	!+I -T*"
 ", 8 s   C/D5$Dc                     g)z
Check if the jvm is valid for this architecture.

This method should be overriden for each architecture.

Raises:
    JVMNotSupportedException: If the jvm is not supported.
Nr   r/   jvms     r   checkJVMFinder.check   s     	r   c                 0   SnU R                    H*  n U" 5       nU(       a  U R                  U5        Ub  Us  $ M,     Ub  Ue[        SR                  U R                  5      5      e! [         a     Md  [         a     Mp  [         a  nUn SnAM  SnAff = f)z
Retrieves the path to the default or first found JVM library

Returns:
    The path to the JVM shared library file

Raises:
    ValueError: No JVM library found or No Support JVM found
NzcNo JVM shared library file ({0}) found. Try setting up the JAVA_HOME environment variable properly.)r.   rd   NotImplementedErrorr   r   rC   r&   )r/   jvm_notsupport_extmethodrc   es        r   r    JVMFinder.get_jvm_path   s     "mmFh JJsO ?J ## $( )$$" $D %+F4==$9; 	; ' ' + '%&"'s#   A&&
B3	B?	BBBc                 \   [         R                  " S5      nU(       a  [         R                  R                  U5      (       aj  [         R                  R	                  U5      n[         R                  R                  U5      (       d  [         R                  " S5      nU R                  U5      $ gg)z
Retrieves the Java library path according to the JAVA_HOME environment
variable

Returns:
    The path to the JVM library, or None
	JAVA_HOMEN)r8   getenvrA   rQ   rS   rK   )r/   rD   s     r   r,   JVMFinder._get_from_java_home   sv     IIk*		22((3I77>>),,IIk2	 ##I.. 39r   c                 x    U R                  U R                  5       H  nU R                  U5      nUc  M  Us  $    g)z
Retrieves the first existing Java library path in the predefined known
locations

Returns:
    The path to the JVM library, or None
N)r_   r)   rK   )r/   homerc   s      r   r-   #JVMFinder._get_from_known_locations   s7     ,,T__=D""4(C
 >r   r.   N)r   r   r   r   r   r&   str__annotations__r)   r   r0   rK   staticmethodr_   rd   r    r,   r-   r   r   r   r   r#   r#   L   sY    (Hc #@Jc3h?9
!?F ! !F	$;L/(r   r#   c                   >   ^  \ rS rSrSrSrSrSrU 4S jrS r	Sr
U =r$ )	r      zLinux JVM library finder class.z/usr/bin/javar%   )r'   r(   z/opt/sunc                 r   > [         TU ]  5         U R                  U R                  U R                  4U l        g r+   )superr0   r,   _get_from_binr-   r.   r/   	__class__s    r   r0   LinuxJVMFinder.__init__   s4     11++779r   c                 t   [         R                  R                  U R                  5      n[         R                  R	                  U5      (       ak  [         R                  R                  [         R                  R                  [         R                  R                  U5      S5      5      nU R                  U5      $ g)z
Retrieves the Java library path according to the real installation of
the java executable

:return: The path to the JVM library, or None
z..N)	r8   rA   rS   _javarQ   abspathrB   dirnamerK   )r/   java_binrD   s      r   r{   LinuxJVMFinder._get_from_bin  sz     77##DJJ/77>>(##RWW__X5N59); <I ##I.. $r   rs   )r   r   r   r   r   r   r&   r)   r0   r{   r   __classcell__r}   s   @r   r   r      s*    ) E H ;J9/ /r   r   c                   :   ^  \ rS rSrSrSrSrU 4S jrS rSr	U =r
$ )r   i  z#
Mac OS X JVM library finder class
zlibjli.dylib)z!/Library/Java/JavaVirtualMachinesc                    > [         TU ]  5         [        U R                  5      U l        U R                  R	                  U R
                  5        g)z
Sets up members
N)rz   r0   listr.   rW   _javahome_binaryr|   s    r   r0   DarwinJVMFinder.__init__"  s8     	T]]+T223r   c                     SSK nSSKnSSKJn  U" UR	                  5       S   SS 5      nU" S5      U::  a   UR                  S/5      R                  5       $ g)z
for osx > 10.5 we have the nice util /usr/libexec/java_home available. Invoke it and
return its output. It seems this tool has been removed in osx 10.9.
r   N)Version   z10.6z/usr/libexec/java_home)r   
subprocesspackaging.versionr   mac_vercheck_outputstrip)r/   r   r   r   currents        r   r    DarwinJVMFinder._javahome_binary+  s]    
 	-(**,Q/346?g%**)*,,1EG4 &r   rs   )r   r   r   r   r   r&   r)   r0   r   r   r   r   s   @r   r   r     s#     H7J44 4r   r   c                    SS K nSnSnSnUS:  n[        U S5       nUR                  S5      nUS:w  a  [        S	5      eUR	                  S
5        UR                  S5      nUR                  SU5      S   n	UR	                  U	S-   5        UR                  S5      nUR                  SU5      S   n
S S S 5        W
U:X  a  U(       a  [        S5      eg X:X  d  X:X  a  U(       d  [        S5      eg [        S5      e! , (       d  f       NO= f)Nr   iL  i   id  l        rb   s   MZzJVM not valid<   r   z<Lz<Hz1JVM mismatch, python is 64 bit and JVM is 32 bit.z1JVM mismatch, python is 32 bit and JVM is 64 bit.zUnable to determine JVM Type)structopenreadr   seekunpack)jvmPathmaxsizer   IMAGE_FILE_MACHINE_I386IMAGE_FILE_MACHINE_IA64IMAGE_FILE_MACHINE_AMD64is64fsheader_offsetmachines              r   _checkJVMArchr   ;  s   !!$U?D	gt	FF1I:*?;;	r
FF1IdA.q1	}q !FF1I--a(+ 
 ))*CE E  
	+w/R*CE E  ''EFF) 
	s   BC99
Dc                   N   ^  \ rS rSrSrSS/rSrU 4S jrS r\	S 5       r
S	rU =r$ )
r   iY  z"
Windows JVM library finder class
z*SOFTWARE\JavaSoft\Java Runtime EnvironmentzSOFTWARE\JavaSoft\JREzjvm.dllc                 \   > [         TU ]  5         U R                  U R                  4U l        g r+   )rz   r0   r,   _get_from_registryr.   r|   s    r   r0   WindowsJVMFinder.__init__c  s(     1143J3JKr   c                     [        U5        g r+   )r   rb   s     r   rd   WindowsJVMFinder.checki  s
    cr   c                  v    SSK n [        R                   H  n U R	                  U R
                  U5      nU R                  US5      nU R	                  X#S   5      nU R                  U5        U R                  US5      nU R                  U5        US   s  $    g! [         a     gf = f! [         a     M  f = f)z
Retrieves the path to the default Java installation stored in the
Windows registry

:return: The path found in the registry, or None
r   NCurrentVersion
RuntimeLib)	winregImportErrorr   reg_keysOpenKeyHKEY_LOCAL_MACHINEQueryValueExCloseKeyOSError)r   locationjreKeycv
versionKeys        r   r   #WindowsJVMFinder._get_from_registryl  s    	 )11H(A(A8L((1AB#^^FqE:
'((\B
+!u 2 !  		  s#   B A:B*
B'&B'*
B87B8rs   )r   r   r   r   r   r   r&   r0   rd   rv   r   r   r   r   s   @r   r   r   Y  s=     >(H HL  r   r   )r8   r   __all__typingr   r   
ValueErrorr   r   rt   r   r   r#   r   r   r   r   r   r   r   r   <module>r      s   ( 
 
'
 #: z !3 !* ) d dN#/Y #/L4n 4D $';; G<-y -r   