7ec@sddlZddlZddlZejdkrQdZdZdZnejdkrldZnejdkrejd krdd lm Z d Znejdkrddl Z ddl Z ddl Z d Zejd krdZn dZejjds<ejjds<ejjdrQdZdZqejd krxdZedZqdZdZndZedkrendS(iNtntcCsd}tjj|}|dkr(dS|t|}tj|jdd\}}t|d d}t|dd!d }|dkrd }n|dkr||Sd S( sReturn 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.iit iiiig$@iN(tsystversiontfindtlentsplittinttNone(tprefixtitstrestt majorVersiont minorVersion((s#/usr/lib64/python2.7/ctypes/util.pyt_get_build_versions    cCswt}|dkrdS|dkr.d}nd|d}ddl}|jdddkro|d 7}n|d S( s%Return the name of the VC runtime dllitmsvcrtsmsvcr%di iNis_d.pydtds.dll(RRtimpt get_suffixes(RtclibnameR((s#/usr/lib64/python2.7/ctypes/util.pyt find_msvcrts      cCs|dkrtSxtjdjtjD]l}tjj||}tjj|r^|S|jj dryq-n|d}tjj|r-|Sq-WdS(NtctmtPATHs.dll(RR( RtostenvironRtpathseptpathtjointisfiletlowertendswithR(tnamet directorytfname((s#/usr/lib64/python2.7/ctypes/util.pyt find_library0s   tcecCs|S(N((R!((s#/usr/lib64/python2.7/ctypes/util.pyR$Fstposixtdarwin(t dyld_findcCs[d|d|d||fg}x3|D]+}yt|SWq(tk rRq(q(Xq(WdS(Ns lib%s.dylibs%s.dylibs%s.framework/%s(t _dyld_findt ValueErrorR(R!tpossible((s#/usr/lib64/python2.7/ctypes/util.pyR$Ks   c Csdtj|}d}tj}zCtj|d||jfdtdtj}|j \}}Wdy|j Wn+t k r}|j t j krqnXXtj||}|sdS|jdS(Ns[^\(\)\s]*lib%s\.[^\(\)\s]*sif type gcc >/dev/null 2>&1; then CC=gcc; elif type cc >/dev/null 2>&1; then CC=cc;else exit; fi;LANG=C LC_ALL=C $CC -Wl,-t -o "$2" 2>&1 -l"$1"t _findLib_gcctshelltstdouti(tretescapettempfiletNamedTemporaryFilet subprocesstPopenR!tTruetPIPEt communicatetclosetOSErrorterrnotENOENTtsearchRtgroup( R!texprtcmdttemptprocttracet_tetres((s#/usr/lib64/python2.7/ctypes/util.pyR,Zs"   tsunos5c Cs|s dSttjd}y8|,tjdd|fdtjd|}WdQXWntk rhdSX|j\}}t j d|}|sdS|j dS(Ntwbs/usr/ccs/bin/dumps-LpvR.tstderrs\[.*\]\sSONAME\s+([^\s]+)i( RtopenRtdevnullR3R4R6R9R7R/R<R=(tftnullRAtdataRCRE((s#/usr/lib64/python2.7/ctypes/util.pyt _get_sonameys  cCs|s dSd}tj|d|fdtdtj}|j\}}|jdkrhtjj |St j d|}|sdS|j dS(Ns[if ! type objdump >/dev/null 2>&1; then exit 10; fi;objdump -p -j .dynamic 2>/dev/null "$1"RNR-R.i s\sSONAME\s+([^\s]+)i( RR3R4R5R6R7t returncodeRRtbasenameR/R<R=(RKR?RAtdumpRCRE((s#/usr/lib64/python2.7/ctypes/util.pyRNs tfreebsdtopenbsdt dragonflycCsf|jd}g}y-x&|r@|jdt|jqWWntk rUnX|petjgS(Nt.i(RtinsertRtpopR*Rtmaxint(tlibnametpartstnums((s#/usr/lib64/python2.7/ctypes/util.pyt _num_versions $ c Cstj|}d||f}ttjd}y/|#tjd dtjd|}WdQXWntk ryd}nX|j \}}tj ||}|st t |S|j dt|d S( Ns:-l%s\.\S+ => \S*/(lib%s\.\S+)RGs/sbin/ldconfigs-rR.RHttkeyi(s/sbin/ldconfigs-r(R/R0RIRRJR3R4R6R9R7tfindallRNR,tsortR\(R!tenameR>RLRARMRCRE((s#/usr/lib64/python2.7/ctypes/util.pyR$s     c Cs^tjjdsdSttj}d|d<|r>d }nd}d}ttjd}y5|)tj |dtj d|d|}WdQXWnt k rdSXzFx?|j D]4}|j }|jd r|jd }qqWWd|j j|jX|sdSxF|jd D]5}tjj|d |} tjj| r!| Sq!WdS(Ns /usr/bin/crletCtLC_ALLs-64RGR.RHtenvsDefault Library Path (ELF):it:slib%s.so(s /usr/bin/crles-64(s /usr/bin/crle(RRtexistsRtdictRRIRJR3R4R6R9R.tstript startswithRR8twaitR( R!tis64RdtargstpathsRLRAtlinetdirtlibfile((s#/usr/lib64/python2.7/ctypes/util.pyt _findLib_crles>        cCstt||pt|S(N(RNRqR,(R!Rk((s#/usr/lib64/python2.7/ctypes/util.pyR$sc Cs`ddl}|jddkr8tjdd}ntjdd}idd6dd 6dd 6dd 6d d 6}|j|d}dtj||f}ttj}d|dRdRLtpRMRCRE((s#/usr/lib64/python2.7/ctypes/util.pyt_findSoname_ldconfigs:      cCst|ptt|S(N(R}RNR,(R!((s#/usr/lib64/python2.7/ctypes/util.pyR$scCsddlm}tjdkrC|jGH|jdGHtdGHntjdkrtdGHtdGHtdGHtjd kr|j d GH|j d GH|j d GH|j d GHq|j dGH|j dGHtdGHndS(Ni(tcdllRRR&RRtbz2R's libm.dylibslibcrypto.dylibslibSystem.dylibsSystem.framework/Systemslibm.sos libcrypt.sotcrypt( tctypesR~RR!RtloadR$Rtplatformt LoadLibrary(R~((s#/usr/lib64/python2.7/ctypes/util.pyttests"   t__main__(RR3RR!RRR$Rtctypes.macholib.dyldR(R)R/R1R:R,RNRiR\RqtFalseR}Rt__name__(((s#/usr/lib64/python2.7/ctypes/util.pyts<        $     ) $