\d! dZdZdZddlZddlZddlZddlZddlZddlZddddddd d d d d Z ej d Z d Z ej dej Zd_dZd`dZej dZ dadZddddddddddd d! Zdd"d#d$d%d&d'Zd(Zd)Zdbd*Zd+Zdcd-Zd.Zddd/Zd0Zd1Zd`d2Zd3Zd`d4Z d5d6d7dZ!ej"ddfd8Z#d9Z$Gd:d;Z%d<Z&Gd=d>ej'd?d@Z(da)dAZ*dBZ+dCZ,dDZ-dEZ.dFZ/dGZ0ej dHej Z1ej dIej Z2ej dJZ3ej dKZ4iZ5dedLZ6dMZ7dNZ8dOZ9dPZ:dQZ;dRZdfdTZ?ej dUZ@ej dVZAdWZBdaCdXZDdYZEeFdZkrKd[ejGvpd\ejGvZHd]ejGvod^ejGvZIeJe?eIeHejKddSdS)ga7 This module tries to retrieve as much platform-identifying data as possible. It makes this information available via function APIs. If called from the command line, it prints the platform information concatenated as single string to stdout. The output format is usable as part of a filename. a Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com Copyright (c) 2000-2010, eGenix.com Software GmbH; mailto:info@egenix.com Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee or royalty is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation or portions thereof, including modifications, that you make. EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! z1.0.8N (2) devalphaabetabcRCrcplpz([0-9]+|[._+-])cg}t|D]\}|dvrV t|d}d}n+#t$rt|d}YnwxYw|||f]|S)Nz._+-rdr) _component_resplitint ValueError _ver_stagesgetextend)versionresultvts ..\python\lib\platform.py_comparable_versionr!s F   ) )"" F?? *2JJ * * *OOAq)) * MM1a& ! ! ! Ms7%AAsC(__libc_init)|(GLIBC_([0-9.]+))|(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)@c|s} tjd}|d}t|dkrt |Sn#t t tf$rYnwxYwtj }|s||fSt}tj |}t|d5}||}d} | t|kr\d|vsd|vrt|| } nd } | r%| t|krH||} | r.|t%| t|d z d | z}d} | snd | D\} } }}}}| r|sd }ns| r&|d krd }|}nf||||kr|}nK|rI|d krCd }|r|r||||kr|}|r!|t| d |kr||z}| } | t|k\d d d n #1swxYwY||fS)a Tries to determine the libc version that the file executable (which defaults to the Python interpreter) is linked against. Returns a tuple of strings (lib,version) which default to the given parameters in case the lookup fails. Note that the function has intimate knowledge of how different libc versions add symbols to the executable and thus is probably only usable for executables compiled using gcc. The file is read and scanned in chunks of chunksize bytes. CS_GNU_LIBC_VERSION)maxsplitrbrslibcsGLIBCNic@g|]}||dn|S)Nlatin1)decode).0ss r zlibc_ver..sCE%E%E%'(m"""E%E%E%libcglibc)osconfstrrlentupleAttributeErrorrOSErrorsys executabler!pathrealpathopenread _libc_searchsearchendmaxgroups)r:libr chunksizeverpartsVfbinaryposmchunklibcinitr2 glibcversionsothreads soversions r libc_verrSs   *233CIIqI))E5zzQU||# G4    D ^  < A!!*--J j$  "1 ""CKK&  H$6$6 ''44 3v;;..y))#CS[[4-?$@$@$A$ABUJFCE%E%E%E%E% AHe\2w  4 4 4'>>!C*GGQ|__qqzz11*G 4'>> C ,',QQy\\AAgJJ5N5N"+47CLL=>>#:g#E#E")G"3%%''C?CKK"""""""""""""""F <s%A AA+*A+6FI  IIc *|d}|r|| ttttt |}n#t $r|}YnwxYwd|dd}|S)z Normalize the version and build strings and return a single version string using the format major.minor.build (or patchlevel). .N)rappendlistmapstrrrjoin)rbuildlstringss r _norm_versionr_s  cA  s3C ,,-- hhwrr{##G Ns5A$$ A32A3z'(?:([\w ]+) ([\w.]+) .*\[.* ([\d.]+)\])win32win16dosc tj|vr|||fSddl}dD]G} |||j|jddd}n##t |jf$r }Yd}~@d}~wwxYw|||fS|}t |}|S| \}}}|ddkr |dd}|ddkr |dd}t|}|||fS) a+ Tries to figure out the OS version used and returns a tuple (system, release, version). It uses the "ver" shell command for this which is known to exists on Windows, DOS. XXX Others too ? In case this fails, the given parameters are used as defaults. rN)rFzcommand /c verz cmd /c verTlocale)stdinstderrtextencodingshellrU) r9platform subprocess check_outputDEVNULLr8CalledProcessErrorstrip _ver_outputmatchrCr_) systemreleasersupported_platformsrmcmdinfowhyrLs r _syscmd_verrzsK |...w''6(( **31;1C2<2D044<15 +77D E 67    HHHH  w'' ::<A))B  B 0D %D32D3F H FHFH!G3>G' G3'G++G3.G+/G33 H?H HHcJd}tj|sdS ddl}n#t$rYdSwxYwt |d5}||}dddn #1swxYwY|d}d}tjj}|dvrd}|||fS)Nz0/System/Library/CoreServices/SystemVersion.plistrr)ProductVersionr"r"r")ppczPower MacintoshPowerPC) r3r;existsplistlibrr=loadunamemachine)fnrrIrru versioninfors r _mac_ver_xmlrs ;B 7>>"  t tt b$1 ]]1  !"GKhjj G,,, K ((s* 88 A--A14A1rc0t}||S|||fS)a< Get macOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the parameter values which default to ''. All tuple entries are strings. )r)rurrrxs r mac_verrs' >>D   K ((r0cjddlm} ||}||S|S#t$r|cYSwxYw)Nr)System) java.langr getPropertyr7)namedefaultrvalues r _java_getproprs_      ""4(( =N s## 22cr ddl}n#t$r ||||fcYSwxYwtd|}td|}|\}}}td|}td|}td|}|||f}|\}} } td| } td |}td | } || | f}||||fS) a] Version interface for Jython. Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being a tuple (vm_name, vm_release, vm_vendor) and osinfo being a tuple (os_name, os_version, os_arch). Values which cannot be determined are set to the defaults given as parameters (which all default to ''). rNz java.vendorz java.versionz java.vm.namezjava.vm.vendorzjava.vm.versionz java.os.archz java.os.namezjava.os.version)rrr) ruvendorvminfoosinfojavavm_name vm_release vm_vendoros_name os_versionos_archs r java_verrs/ ///..../=& 1 1FNG44G%+"GZNG44G. ::I0*==J j) +F#) GZNG44GNG44G0*==J j' )F FFF **s c&|dkr|dkr|||fS|d}|rS t|d}|dz }t||d<d|}n#t$rYnwxYw|dkrd}n d}n|dvrd }|||fS) z Returns (system, release, version) aliased to common marketing names used for some systems. It also does some reordering of the information in some cases where it would otherwise cause confusion. SunOS5rUrrV6SolarisrarbWindows)rrrZr[r)rtrurr]rs r system_aliasrs S==7G+ + MM#    & &AaD  5zz!((1++      S==FFFF % % % 7G ##sA,, A98A9c|ddtt|D}|dd}|dd}|dd}|dd}|dd}|d d}|d d}|d d}|d d } |dd}||krn|} |ddkr|dd}|ddk|S)zq Helper to format the platform string in a filename compatible format e.g. "system-version-machine". -c3>K|]}|VdSN)rq)r-xs r z_platform..%s*==a ======r0 _/\:;"()unknownr"r&z--rkN)r[filterr5replace)argsrlcleaneds r _platformrsW xx==6#t+<+<=====HS))HS))Hc**HS))HS))HS))HS))HS))H 2..H""4-- h     2,#  CRC= 2,#   Or0c ddl}n#t$r|cYSwxYw |S#t$r|cYSwxYw)z8 Helper to determine the node name of this machine. rN)socketr gethostnamer8)rrs r _noder?sq !!### s . ==ctj|}tj|rtjtjtj|tj|}tj||S)zT In case filepath is a symlink, follow it until a real file is reached. )r3r;abspathislinknormpathr[dirnamereadlink)filepaths r _follow_symlinksrNs wx((H '.. " "L7## GLL22BK4I4I J JLL '.. " "L Or0cNtjdvr|S ddl}n#t$r|cYSwxYwt |}t t jd} |dd|g|j |}n#t|j f$r|cYSwxYw|s|S| d S) z Interface to the system's file command. The function uses the -b option of the file command to have it omit the filename in its output. Follow the symlinks. It returns default in case the command should fail. )rcrarbrNC)LC_ALLfilez-b)rgenvzlatin-1) r9rlrmrrdictr3environrnror8rpr,)targetrrmroutputs r _syscmd_filer Zs |000  f % %F rz# & & &C((&$)?0:0B-0)22 Z2 3  == # ##s && A55B  B )r" WindowsPE)r"r)r"MSDOSc|s.ddl}|d}t|dzdz}|rt|d}nd}|sI|tjkr9tjtvr"ttj\}}|r|}|r|}||fSd|vrd|vr||fSd |vrd }nd |vrd }d |vrd }nd|vr d|vrd}nd}nd|vrd}nd|vrd}n ||fS)a Queries the given executable (defaults to the Python interpreter binary) for various architecture information. Returns a tuple (bits, linkage) which contains information about the bit architecture and the linkage format used for the executable. Both values are returned as strings. Values that cannot be determined are returned as given by the parameter presets. If bits is given as '', the sizeof(pointer) (or sizeof(long) on Python version < 1.5.2) is used as indicator for the supported pointer size. The function relies on the system's "file" command to do the actual work. This is available on most if not all Unix platforms. On some non-Unix platforms where the "file" command does not exist and the executable is set to the Python interpreter binary defaults from _default_architecture are used. rNPbitr"r:z shared objectz32-bit32bitz64-bit64bitELFPErr COFFzMS-DOSr )structcalcsizerZr r9r:rl_default_architecture)r:bitslinkagersizefileoutr r]s r architecturers_. % s##4!8}}u$z2..  S^## <0 0 0(6DAq  W}7""g'E'EW}7 W       !GGGG 7   W   =r0ctjddptjddS)NPROCESSOR_ARCHITEW6432r"PROCESSOR_ARCHITECTURE)r3rrrr0r _get_machine_win32r"s6 /44 5 /44r0c6eZdZedZdZdZdZdS) _Processorc`t|dtj|j}|pdS)Nget_r")rr9rlfrom_subprocess)clsfuncs r rz_Processor.gets1s13<1133FGGtvv|r0cZtjdtS)NPROCESSOR_IDENTIFIER)r3rrr"rr0r get_win32z_Processor.get_win32s z~~46H6J6JKKKr0ct ddl}|dd\}}|dkrdndS#t$rYdSwxYw)NrzSYI$_CPUAlphaVAX)vms_libgetsyir)r1csid cpu_numbers r get_OpenVMSz_Processor.get_OpenVMSsb ; NNN '~~j!<< D*(C//77U :     DD s ) 77c ddl}n#t$rYdSwxYw |ddg|jddS#t |jf$rYdSwxYw)z) Fall back to `uname -p` rNrz-pTutf8)rgrhri)rmrrnrorqr8rp)rms r r'z_Processor.from_subprocesss         44  **$!) + egg   67    DD s 1A A A N)__name__ __module__ __qualname__ classmethodrr,r5r'rr0r r$r$s][LLL;;;r0r$c|dkrdn|S)Nrr"r)vals r _unknown_as_blankr>s !!22s*r0cneZdZdZdZejdZfdZe dZ dZ dZ dZ xZS) uname_resultz A uname_result that's largely compatible with a simple namedtuple except that 'processor' is resolved late and cached to avoid calling "uname" except when needed. )rtnoderurr processorcNttSr)r>r$rselfs r rBzuname_result.processors !1!1222r0cvtjt|jfSr) itertoolschainsuper__iter__rB)rE __class__s r rJzuname_result.__iter__s2 GG     ^    r0ct|jdz }|j|g|R}t||dzkr$d|dt|}t||S)Nr&z Expected z arguments, got )r5_fields__new__ TypeError)r(iterable num_fieldsrmsgs r _makezuname_result._make"sr%%) S,8,,, v;;*q. ( (GjGG#f++GGCC..  r0c,t||Sr)r6)rErs r __getitem__zuname_result.__getitem__,sT{{3r0cTttt|Sr)r5r6iterrDs r __len__zuname_result.__len__/s5d$$%%%r0chtt|dt|jdz fS)Nr&)r@r6r5rMrDs r __reduce__zuname_result.__reduce__2s-U4[[)?#dl*;*;a*?)?@@@r0)r8r9r:__doc__rM functoolscached_propertyrBrJr;rSrUrXrZ __classcell__)rKs@r r@r@ s OG333     [   &&&AAAAAAAr0r@uname_result_basez#system node release version machinecttS tjx\}}}}}}n2#t$r%tj}t }dx}x}}d}YnwxYwt|s|dkr#t\}}}}|p t}|r|s=t|\}}}|dkrd}n!|dkr|dkrd}d|dd krd }nd}|d vr|s |dkrd }nd }d}n<|dddkr.t\}}} } d}d | }|s|}|dkr |r|dkr|}d}|dkr |dkrd}d }|||||f} ttt| atS)an Fairly portable uname interface. Returns a tuple of strings (system, node, release, version, machine, processor) identifying the underlying platform. Note that unlike the os.uname function this also returns possible processor information as an additional tuple entry. Entries which cannot be determined are set to ''. Nr"rrazMicrosoft Windowsr Microsoftz6.0rVrrr16bitrJava, OpenVMS0) _uname_cacher3rr7r9rlranyrr"rzrr[r@rYr>) rtrArurrinfosrrrrrvalss r rr9s:<(**D/gw%% ww&((('G  u::*! W  +4;; (GWc55!3!5!5G !G !'26':': $FGW,,,";&&7i+?+? #GBQBK''%GG G ' ' ' &W$$%GG%GFF BQBZ6 ! !.6jj +GVVVFii''G !  'S..GGI!5!5 4'7 2D%6!=!=>L s,,AAc(tjS)z Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'. An empty string is returned if the value cannot be determined. )rrtrr0r rtrts 77>r0c(tjS)z Returns the computer's network name (which may not be fully qualified) An empty string is returned if the value cannot be determined. )rrArr0r rArAs 77<r0c(tjS)z Returns the system's release, e.g. '2.2.0' or 'NT' An empty string is returned if the value cannot be determined. )rrurr0r ruru 77?r0c(tjS)z Returns the system's release version, e.g. '#3 on degas' An empty string is returned if the value cannot be determined. )rrrr0r rrror0c(tjS)zt Returns the machine type, e.g. 'i386' An empty string is returned if the value cannot be determined. )rrrr0r rrror0c(tjS)a Returns the (true) processor name, e.g. 'amdk6' An empty string is returned if the value cannot be determined. Note that many platforms do not provide this information or simply return the same value as for machine(), e.g. NetBSD does this. )rrBrr0r rBrBs 77 r0zL([\w.+]+)\s*\(#?([^,]+)(?:,\s*([\w ]*)(?:,\s*([\w :]*))?)?\)\s*\[([^\]]+)\]?z;IronPython\s*([\d\.]+)(?: \(([\d\.]+)\))? on (.NET [\d\.]+)zU([\d.]+)\s*\(IronPython\s*[\d.]+\s*\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)zE([\w.+]+)\s*\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*\[PyPy [^\]]+\]?c|| tj}t|d}||Sd|vrd}|drt |}nt|}|tdt|z| \}}}d}d}nJtj drhd}t|}|tdt|z| \}}}} } |d}tj }nd|vrYd}t|}|td t|z| \}}}} d}nft|}|td t|z| \}}}} }d }|d}n | r|d z| z}ttd rtj\} } } n*ttdrtj\} } } nd} d} |d} t%| dkr*| dd| }||| | |||f}|t|<|S)a Returns a parsed version of Python's sys.version as tuple (name, version, branch, revision, buildno, builddate, compiler) referring to the Python implementation name, version, branch, revision, build number, build date/time as string and the compiler identification string. Note that unlike the Python sys.version, the returned value for the Python version will always include the patchlevel (it defaults to '.0'). The function returns empty strings for tuple entries that cannot be determined. sys_version may be given to parse an alternative version string, e.g. if the version was read from a different Python interpreter. N IronPythonz*failed to parse IronPython sys.version: %sr"rJythonz&failed to parse Jython sys.version: %sPyPyz$failed to parse PyPy sys.version: %sz'failed to parse CPython sys.version: %sCPythonr_git _mercurialrUr(rg)r9r_sys_version_cacher startswith_ironpython_sys_version_parserrs _ironpython26_sys_version_parserrreprrCrl_sys_version_parser_pypy_sys_version_parserhasattrrxryrr5rWr[) sys_versionrrrsr alt_versioncompilerbuildno builddate buildtimerbranchrevisionr]s r _sys_versionrs*k  # #K 6 6F  {""  ! !, / / H288EEEE4::;GGE =<[!!"## #*/&h   ( ($4#))+66 =8[!!"## #5:LLNN1)Y  I< ;  (..{;; =C!+../00 016.)Y$))+66 =9[!!"## #llnn 9)Y  II  4!C)3IsF!h688 l # #!n688  cA 1vv{{  ((1++GVXw 8 LF&,{# Mr0c*tdS)aR Returns a string identifying the Python implementation. Currently, the following implementations are identified: 'CPython' (C implementation of Python), 'IronPython' (.NET implementation of Python), 'Jython' (Java implementation of Python), 'PyPy' (Python implementation of Python). rrrr0r python_implementationrR >>! r0c*tdS)z Returns the Python version as string 'major.minor.patchlevel' Note that unlike the Python sys.version, the returned value will always include the patchlevel (it defaults to 0). r&rrr0r python_versionr_s >>! r0cjttddS)z Returns the Python version as tuple (major, minor, patchlevel) of strings. Note that unlike the Python sys.version, the returned value will always include the patchlevel (it defaults to 0). r&rU)r6rrrr0r python_version_tupleris) "((-- . ..r0c*tdS)z Returns a string identifying the Python implementation branch. For CPython this is the SCM branch from which the Python binary was built. If not available, an empty string is returned. r(rrr0r python_branchrts >>! r0c*tdS)z Returns a string identifying the Python implementation revision. For CPython this is the SCM revision from which the Python binary was built. If not available, an empty string is returned. rVrrr0r python_revisionrrr0c.tddS)zh Returns a tuple (buildno, builddate) stating the Python build number and date as strings. rcrrrr0r python_buildrs >>!A# r0c*tdS)zS Returns a string identifying the compiler used for compiling Python. rrrr0r python_compilerrs >>! r0c t||fd}||St\}}}}}}||krd}|rt|||\}}}|dkrt d} | rd}| }|dkr:t |\} } } } |rt ||}nt |||| }n|dvr)t\}}t ||||d||z}n|d krCt\}}}\}}}|s|st |||}nYt |||d |||}nC|rt ||}n0ttj \}}t ||||||}|t||f<|S) a Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. Nr"DarwinrmacOSr)Linuxwithrdon) _platform_cacherrrrrrrSrrr9r:)aliasedterserrtrArurrrB macos_releaserelversrrrllibcname libcversionrrrrrrrrs r rlrls& '5!14 8 8F  :?6FD'7GY) J#/#I#I   !  $F#G  )' 2 2T3  @ 11HH '3??HH :   ( +VWgy#%k133 6  7?zz41f4w G  ? ? '::HH '!%!(*g??HH  ; 11HH(88MD' '!*D';;H)1OWe$% Or0zA^(?P[a-zA-Z0-9_]+)=(?P["']?)(?P.*)(?P=quote)$z\\([\\\$\"\'`]))z/etc/os-releasez/usr/lib/os-releasecdddd}|D]b}t|}|Dtd|d||d<c|S)Nrlinux)NAMEID PRETTY_NAMEz\1rr)_os_release_liners_os_release_unescapesubgroup)linesrxlinemos r _parse_os_releasers  D   # #D ) ) >%9%=%=rxx((&&D&!! " Kr0c`td}tD]Z} t|d5}t|adddn #1swxYwYnI#t$r}|j}Yd}~Sd}~wwxYwt |ddttS)zKReturn operation system identification from freedesktop.org os-release Nzutf-8)rizUnable to read files re)_os_release_cache_os_release_candidatesr=rr8errnor[copy)r candidaterIes r freedesktop_os_releasers  /  I )g666=!(9!(<(<%===============    K 2H(I(IKK   ! ! # ##s9AA AA AA A A)A$$A)__main__rz--terse nonaliasedz --nonaliased)Nr"r"r#)r")r"r"r"r`)r"r"r"r")r"rr")r"r"rrr)rr)Lr[ __copyright__ __version__ collectionsr3rer9r\rGrcompilerr!ASCIIr?rSr_rrrzrrrrrrrrrrrrrr rr:rr"r$r> namedtupler@rhrrtrArurrrBrr|r}rrzrrrrrrrrrrlrrrrrrr8argvrrprintexitrr0r rsr *    b R B C    -..    rzBDF8 MM HHHHT    bj-.. 02#<0$0$0$0$f        (     ![[[$0(0(0(0(f))),))))&   ++++F&$&$&$T@        $ $ $ $N    NRIIIIX   """"""""J+++ )A)A)A)A)AK-//)A)A)AX UUUr   !bjh   ",8 "%"%$.2::$$ &2: ffffP    / / /      HHHH^2:I"rz"455C&$$$2 z  9I$9E38+NNch4NG E((7E " "### CHQKKKKK r0