�`^c@s�ddlZddlZejdkrEd�Zd�Zd�Znejdkr`d�Znejdkr�ejd kr�dd
lmZ d�Zn�jdkr�ddl
Z
ddlZddlZd�Z
ejd
kr��Zn d�Zejjd�s0ejjd�s0ejjd�rEd�Zd�Zq�ejd
krld�Zed�Zq�d�Zd�Znd�Zedkr�e�ndS(i�NtntcCs�d}tjj|�}|dkr(dS|t|�}tj|jdd�\}}t|d �d}t|dd!�d }|dkr�d
}n|dkr�||SdS(s�Return the version of MSVC that was used to build Python.
For Python 2.3 and up, the version number is included in
sys.version. For earlier versions, assume the compiler is MSVC 6.
sMSC v.i�it ii�iig$@iN(tsystversiontfindtlentsplittinttNone(tprefixtitstresttmajorVersiontminorVersion((s!/sys/lib/python2.7/ctypes/util.pyt_get_build_version s cCswt�}|dkrdS|dkr.d}nd|d}ddl}|j�dddkro|d 7}n|d
S(s%Return the name of the VC runtime dllitmsvcrtsmsvcr%di
i�Nis_d.pydtds.dll(RRtimptget_suffixes(RtclibnameR((s!/sys/lib/python2.7/ctypes/util.pytfind_msvcrt s
cCs�|dkrt�Sx�tjdjtj�D]l}tjj||�}tjj|�r^|S|j�j d�ryq-n|d}tjj|�r-|Sq-WdS(NtctmtPATHs.dll(RR(RtostenvironRtpathseptpathtjointisfiletlowertendswithR(tnamet directorytfname((s!/sys/lib/python2.7/ctypes/util.pytfind_library1s
tcecCs|S(N((R!((s!/sys/lib/python2.7/ctypes/util.pyR$Gstposixtdarwin(t dyld_findcCs[d|d|d||fg}x3|D]+}yt|�SWq(tk
rRq(q(Xq(WdS(Nslib%s.dylibs%s.dylibs%s.framework/%s(t
_dyld_findt
ValueErrorR(R!tpossible((s!/sys/lib/python2.7/ctypes/util.pyR$Ls
c
Cs�dtj|�}tj�\}}tj|�d|d|}z3tj|�}z|j�}Wd|j�}XWdytj|�Wn+t k
r�}|j
t
jkr��q�nXX|dkr�t d�ntj||�} | s�S| jd�S(Ns[^\(\)\s]*lib%s\.[^\(\)\s]*s�if type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit 10; fi;LANG=C LC_ALL=C $CC -Wl,-t -o s 2>&1 -li
sgcc or cc command not foundi(tretescapettempfiletmkstempRtclosetpopentreadtunlinktOSErrorterrnotENOENTtsearchRtgroup(
R!texprtfdouttccouttcmdtfttracetrvtetres((s!/sys/lib/python2.7/ctypes/util.pyt_findLib_gcc[s(
tsunos5cCsj|s
dSd|}tj|�}z|j�}Wd|j�Xtjd|�}|s]dS|jd�S(Ns#/usr/ccs/bin/dump -Lpv 2>/dev/null s\[.*\]\sSONAME\s+([^\s]+)i(RRR1R2R0R,R7R8(R=R<tdataRA((s!/sys/lib/python2.7/ctypes/util.pyt_get_sonamews
cCs�|s
dSd|}tj|�}|j�}|j�}|dkrStd�ntj|�}z|j�}Wd|j�Xtjd|�}|s�dS|jd�S(NsWif ! type objdump >/dev/null 2>&1; then exit 10; fi;objdump -p -j .dynamic 2>/dev/null i
sobjdump command not founds\sSONAME\s+([^\s]+)i( RRR1R2R0R4R,R7R8(R=R<tdumpR?RDRA((s!/sys/lib/python2.7/ctypes/util.pyRE�s"tfreebsdtopenbsdt dragonflycCsf|jd�}g}y-x&|r@|jdt|j���qWWntk
rUnX|petjgS(Nt.i(RtinsertRtpopR*Rtmaxint(tlibnametpartstnums((s!/sys/lib/python2.7/ctypes/util.pyt_num_version�s $
cCs�tj|�}d||f}tjd�}z|j�}Wd|j�Xtj||�}|sttt|��S|j dd��|dS(Ns:-l%s\.\S+ => \S*/(lib%s\.\S+)s/sbin/ldconfig -r 2>/dev/nulltcmpcSstt|�t|��S(N(RRRQ(txty((s!/sys/lib/python2.7/ctypes/util.pyt<lambda>�si�(
R,R-RR1R2R0tfindallRERBtsort(R!tenameR9R=RDRA((s!/sys/lib/python2.7/ctypes/util.pyR$�scCs�tjjd�sdS|r%d}nd}xKtj|�j�D]4}|j�}|jd�rA|j�d}qAqAW|s�dSxF|jd�D]5}tjj |d|�}tjj|�r�|Sq�WdS(Ns
/usr/bin/crles*env LC_ALL=C /usr/bin/crle -64 2>/dev/nulls&env LC_ALL=C /usr/bin/crle 2>/dev/nullsDefault Library Path (ELF):it:slib%s.so(
RRtexistsRR1t readlineststript
startswithRR(R!tis64R<tlinetpathstdirtlibfile((s!/sys/lib/python2.7/ctypes/util.pyt
_findLib_crle�s cCstt||�pt|��S(N(RERcRB(R!R^((s!/sys/lib/python2.7/ctypes/util.pyR$�sc Cs�ddl}|jd�dkr8tj�dd}ntj�dd}idd6dd 6dd
6dd6dd
6}|j|d�}dtj|�|f}tjd�}z|j�}Wd|j �Xtj
||�}|s�S|jd�S(Ni�tlis-32s-64slibc6,x86-64s x86_64-64slibc6,64bitsppc64-64s
sparc64-64ss390x-64slibc6,IA-64sia64-64tlibc6s\s+(lib%s\.[^\s]+)\s+\(%ss/sbin/ldconfig -p 2>/dev/nulli(
tstructtcalcsizeRtunametgetR,R-R1R2R0R7RR8( R!Rftmachinetmach_maptabi_typeR9R=RDRA((s!/sys/lib/python2.7/ctypes/util.pyt_findSoname_ldconfig�s(
cCst|�ptt|��S(N(RmRERB(R!((s!/sys/lib/python2.7/ctypes/util.pyR$�scCs�ddlm}tjdkrC|jGH|jd�GHtd�GHntjdkr�d�GHtd�GHtd�GHtjd kr�|j d
�GH|j d�GH|j d�GH|j d
�GHq�j d�GH|j d�GHtd�GHndS(Ni�(tcdllRRR&RRtbz2R's
libm.dylibslibcrypto.dylibslibSystem.dylibsSystem.framework/Systemslibm.soslibcrypt.sotcrypt(
tctypesRnRR!RtloadR$RtplatformtLoadLibrary(Rn((s!/sys/lib/python2.7/ctypes/util.pyttest�s"t__main__(RRR!RRR$Rstctypes.macholib.dyldR(R)R,R.R5RBRER]RQRctFalseRmRut__name__(((s!/sys/lib/python2.7/ctypes/util.pyt<module>s8 $
|