Qff dZdZdZddlZddlZddlZddlZddlZddlZddddddd d d d d Z d Z dGdZ dHdZ dIdZ ddlZdZgdZgdZdZdZdZdJdZdZdKdZdZdLdZdZdZdHd Zd!ZdHd"Zd#d$d%dZ ejBd d fd&Z"d'Z#Gd(d)Z$d*Z%Gd+d,ejLd-d.Z'da(d/Z)d0Z*d1Z+d2Z,d3Z-d4Z.d5Z/iZ0dMd6Z1d7Z2d8Z3d9Z4d:Z5d;Z6d<Z7d=Z8iZ9dNd>Z:d?Z;dae?dBk(r^dCejvxsdDejvZAdEejvxrdFejvZBeCe:eBeAejdyy#e$rdZY(wxYw)Oa7 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) devalphaabetabcRCrcplpctjd}g}|j|D])}|dvs t|d}d}|j||f+|S#t$rt j |d}Y8wxYw)Nz([0-9]+|[._+-])z._+-rdr)recompilesplitint ValueError _ver_stagesgetextend)version component_reresultvts //opt/alt/python312/lib64/python3.12/platform.py_comparable_versionr#s::01L F    ( F? *2J MM1a& !) M *OOAq) *sAA98A9cp|sX tjd}|jd}t|dk(r t |S tj}|s||fStjdtj}t}tjj|}t!|d5}|j#|} d} | t| kr*d| vsd | vr|j%| | } nd } | r| j't| k(r7|j#|} | r!| t)| t| d z d | z} d} ~| sn| j+D cgc]} | | j-d n| c} \}}}}}}|r|sd }nY|r|dk7rd}|}nM||||kDr<|}n9|r7|dk7r2d }|r|r||||kDr|}|r|t| d |k7r||z}| j'} | t| kr*d d d ||fS#t t tf$rYwxYwcc} w#1swY||fSxYw)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)maxsplitsC(__libc_init)|(GLIBC_([0-9.]+))|(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)rbrslibcsGLIBCNilatin1libcglibc)osconfstrrlentupleAttributeErrorrOSErrorsys executablerrASCIIr#pathrealpathopenreadsearchendmaxgroupsdecode)r5libr chunksizeverparts libc_searchVfbinaryposmchunkslibcinitr- glibcversionsothreads soversions r"libc_verrQsd  **23CIIqI)E5zQU|# ^^ < **BDF88 MK A!!*-J j$ 1 "CK& H$6&&vs33v;.y)#CS[4-?$@$ABUJFCE%#A'(m":#E% AHe\2w '>!C*G|_qz1*G'> C 'Qy\AgJ5N"+7CL=>#:g#E")G"3%%'C?CK F <q G4   JE%! F <s1?H 0B'H)H$3BH) H! H!$H))H5c |jd}|r|j| ttttt |}dj|dd}|S#t $r|}Y#wxYw)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]sm  cA  s3C ,-hhwr{#G N s'A## A10A1win32win16dosc tj|vr|||fSddl}dD]/} |j||j|jddd}n|||fStjd}|j}|j|} | 9| j\}}}|dd k(r|dd}|dd k(r|dd}t|}|||fS#t |j f$r }Yd}~d}~wwxYw) 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)rBzcommand /c verz cmd /c verTlocale)stdinstderrtextencodingshellz'(?:([\w ]+) ([\w.]+) .*\[.* ([\d.]+)\])rS) r4platform subprocess check_outputDEVNULLr3CalledProcessErrorrrstripmatchr>r]) systemreleasersupported_platformsrkcmdinfowhy ver_outputrIs r" _syscmd_verrxs& ||..w''6 **31;1C1C2<2D2D044<15 +7D 7w''-.J ::K|]}|jdyw)=N) partition).0is r" z_wmi_query..Ks51akk#&srr)c3(K|] }| ywN)rk dict_datas r"rz_wmi_query..Ms+d ! ds)_wmi exec_queryformatrYr)tablekeysdata split_datarrs @r" _wmi_queryrBs)$  299 HHTN    5; 65 )34AQqT1Q4Z4 +d++5sA8ctd)Nz not supported)r3)rs r"rr?s o&&) )rr'rpost11))rriU11)r10)rrTrz8.1)rr)r8)rr'r7)rrrVista))r)iXP64)rr)rXPMedia))rr'rXP)rrr2000) )rpost2022Server))rri|O 2022Server))rricE 2019Server)r 2016Server)r 2012ServerR2)r 2012Server)r 2008ServerR2)r 2008Server)r 2003Server)r 2000ServerctdvS)N)IoTUAP NanoServerWindowsCoreHeadless IoTEdgeOS) win32_editionrrr" win32_is_iotrks ?Z ZZrc ddl} d}|j|j|5}|j |ddcdddS#t$rddl}YMwxYw#1swYnxYw y#t $rYywxYw#t$rYywxYw)Nr,SOFTWARE\Microsoft\Windows NT\CurrentVersion EditionId)winreg ImportError_winreg OpenKeyExHKEY_LOCAL_MACHINE QueryValueExr3)rcvkeykeys r"rrns  %   CE!!&";";UCs**3 A A  A AA*)A*0B663C,+C,:DD21D27D<;F)< E  F) E  F)F.F  F FF F&%F&) F54F5cd}t|||\}}}}|rKttt|j d|rt nt }tfd|D|}||||fS)NFrSc34K|]\}}|ks |ywrr)rr r intversions r"rzwin32_ver..sBhda!z/hs )rr1rWrr_WIN32_CLIENT_RELEASES_WIN32_SERVER_RELEASESnext)rrrrrrreleasesrs @r" win32_verrshI%/e%D"GS%3sGMM#$678 -6)>"  b$1 ]]1  !"GKhhj  G,, K ((  sA>B > B  B  Bc(t}||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)rrrrrus r"mac_verrs% >D   K ((rc`ddlm} |j|}||S|S#t$r|cYSwxYw)Nr)System) java.langr getPropertyr2)namedefaultrvalues r" _java_getproprs= ""4( =N s --c. ddl}td|}td|}|\}}}td|}td|}td|}|||f}|\}} } td| } td |}td | } || | f}||||fS#t$r ||||fcYSwxYw) 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) rrvendorvminfoosinfojavavm_name vm_release vm_vendoros_name os_versionos_archs r"java_verr s/=& 1FNG4G%+"GZNG4G. :I0*=J j) +F#) GZNG4GNG4G0*=J j' )F FFF **! /../sBBBc|dk(r[|dkr|||fS|jd}|r3 t|d}|dz }t||d<dj|}|dkrd}n d}n|dvrd }|||fS#t$rY!wxYw) 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. SunOS5rSrrT6Solarisr_r`Windows)rrrXrYr)rqrrrr[rs r" system_aliasr"s S=7G+ + MM#   &AaD  5z!((1+ S=FF % % 7G ##'  sA,, A87A8cdjdtt|D}|jdd}|jdd}|jdd}|jdd}|jdd}|jd d}|jd d}|jd d}|jd d } |jdd}||k(rn|}|ddk(r|dd}|ddk(r|S)zq Helper to format the platform string in a filename compatible format e.g. "system-version-machine". -c3<K|]}|jywr)ro)rxs r"rz_platform..Rs=+>"8:L:NO O Ps1A  A cf ddl}|jdd\}}|dk\rdSdS#t$rYywxYw)NrzSYI$_CPUrRVAX)vms_libgetsyir)rncsid cpu_numbers r" get_OpenVMSz_Processor.get_OpenVMS)sG ;  '~~j!< D*(C/7 :U :    s $ 00c ddl} |jddg|jddj S#t$rYywxYw#t |j f$rYywxYw)z) Fall back to `uname -p` rNrz-pTutf8)rerfrg)rkrrlrmror3rn)rks r"r`z_Processor.from_subprocess2sx   **$!)) + eg    667   s 6.A AAAAN)__name__ __module__ __qualname__ classmethodrrjrrr`rrr"r]r]s#0;rr]c|dk(rdS|S)Nrr$r)vals r"_unknown_as_blankr{Es !2*s*rcleZdZdZdZej dZfdZe 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. )rqnoderrrr processorc<ttjSr)r{r]rselfs r"rzuname_result.processorYs !122rc^tjt| |jfSr) itertoolschainsuper__iter__r)r __class__s r"rzuname_result.__iter__]s) G   ^^   rct|jdz }|j|g|}t||dzk7rd|dt|}t||S)Nr'z Expected z arguments, got )r0_fields__new__ TypeError)raiterable num_fieldsrmsgs r"_makezuname_result._makecsb%) S,8, v;*q. (j\)9#f+GCC.  rct||Sr)r1)rrs r" __getitem__zuname_result.__getitem__msT{3rc<ttt|Sr)r0r1iterrs r"__len__zuname_result.__len__ps5d$%%rcVtt|dt|jdz fS)Nr')r}r1r0rrs r" __reduce__zuname_result.__reduce__ss'U4[)?#dll*;a*?@@@r)rurvrw__doc__r functoolscached_propertyrrrxrrrr __classcell__)rs@r"r}r}KsQ OG33  &Arr}uname_result_basez#system node release version machinec~ttS tjx\}}}}}}t|s|dk(rt\}}}}|xs t}|r|s0t|\}}}|dk(rd}n|dk(r|dk(rd}d|dd k(rd }nd}|d vr|s |dk(rd }nd }d}n.|dddk(r&t\}}} } d}dj| }|s|}|dk(r |r|dk(r|}d}|dk(r |dk(rd}d }|||||f} ttt| atS#t$r&tj }t }dx}x}}d}YwxYw)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$rr_zMicrosoft Windowsr Microsoftz6.0rTrrrA16bitrrJavarfOpenVMSr) _uname_cacher.rr2r4rjr(anyrr[rxr rYr}rWr{) rqr~rrrrinfosrrrrrvalss r"rrzs:<((*D/gw% u: W +4; (GWc55!3!5GG'26': $FGW,,";&7i+? #GBQK'%G G ' 'W$%G%GF BQZ6 !.6j +GVVVFii'G 'S.GGI!5 4'7 2D%6!=>L C w&((('G sD +D<;D<c*tjS)z Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'. An empty string is returned if the value cannot be determined. )rrqrrr"rqrqs 7>>rc*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. )rr~rrr"r~r~s 7<<rc*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. )rrrrrr"rrrr 7??rc*tjS)z Returns the system's release version, e.g. '#3 on degas' An empty string is returned if the value cannot be determined. )rrrrr"rrrrc*tjS)zt Returns the machine type, e.g. 'i386' An empty string is returned if the value cannot be determined. )rrrrr"rrrrc*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. )rrrrr"rrs 7  rc0|tj}tj|d}||St j dtj }tjjdrWd}|j|}|tdt|z|j\}}}}} |d}tj} nd|vrYt j d} d}| j|}|td t|z|j\}}}}d} nQ|j|}|td t|z|j\}}}}} d }|d}n |r|d z|z}ttd rtj\} } } n)ttdrtj\} } } nd} d} |j!d}t#|dk(r"|j%ddj'|}||| | ||| 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. NzL([\w.+]+)\s*\(#?([^,]+)(?:,\s*([\w ]*)(?:,\s*([\w :]*))?)?\)\s*\[([^\]]+)\]?rJythonz&failed to parse Jython sys.version: %sr$PyPyzE([\w.+]+)\s*\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*\[PyPy [^\]]+\]?z$failed to parse PyPy sys.version: %sz'failed to parse CPython sys.version: %sCPythonr_git _mercurialrSr)r)r4r_sys_version_cacherrrr6rj startswithrprreprr>hasattrrrrr0rUrY) sys_versionrsys_version_parserrrprbuildno builddate buildtimercompilerpypy_sys_version_parserbranchrevisionr[s r" _sys_versionrs:*kk  # #K 6F   (( $ ||v&"((5 =8[!"# #5:LLN1)Y  I<< ; "$** #! '--k: =C!+./0 016.)Y#((5 =9[!"# #lln 9)Y  I !C)3IsF!hh68 l #!nn68  cA 1v{  ((1+GVXw 8 LF&,{# MrctdS)a Returns a string identifying the Python implementation. Currently, the following implementations are identified: 'CPython' (C implementation of Python), 'Jython' (Java implementation of Python), 'PyPy' (Python implementation of Python). rrrrr"python_implementationrss >! rctdS)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'rrrr"python_versionrs >! rcLttdjdS)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'rS)r1rrrrr"python_version_tuplers! "((- ..rctdS)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)rrrr" python_branchrs >! rctdS)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. rTrrrr"python_revisionrs >! rctddS)zh Returns a tuple (buildno, builddate) stating the Python build number and date as strings. rrrrrr" python_buildrs >!A rctdS)zS Returns a string identifying the compiler used for compiling Python. rrrrr"python_compilerrs >! rc ztj||fd}||St\}}}}}}||k(rd}|rt|||\}}}|dk(rt d} | rd}| }|dk(r.t |\} } } } |r t ||}nt |||| }n|dk(r!t\}}t ||||d||z}nw|d k(r7t\}}}\}}}|s|st |||}nMt |||d |||}n;|r t ||}n,ttj\}}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$DarwinrmacOSrLinuxwithron) _platform_cacherrrrrr$rQr rMr4r5)aliasedterserrqr~rrrrr macos_releaserelversrrrjlibcname libcversionrr rrrrrIrJs r"rjrjs& '5!14 8F  :?6FD'7GY) #/#I   ! F#G  )' 2T3  1H '3?H 7  ( +VWgy#%k13 6 7?z41f4w G  ':H '!%!(*g?H  1H(8MD' '!*D';H)1OWe$% Or)z/etc/os-releasez/usr/lib/os-releasecdddd}tjd}tjd}|D]I}|j|}||jd|j d||j d<K|S) Nrlinux)NAMEID PRETTY_NAMEzA^(?P[a-zA-Z0-9_]+)=(?P["']?)(?P.*)(?P=quote)$z\\([\\\$\"\'`])z\1rr)rrrpsubgroup)linesruos_release_lineos_release_unescapelinemos r"_parse_os_releasers DjjMO**%78  " "4 ( >%8%<%<rxx(&D&! " Krc\ted}tD]8} t|d5}t|adddtjSt |ddj ttjS#1swYUxYw#t$r}|j }Yd}~d}~wwxYw)zKReturn operation system identification from freedesktop.org os-release Nzutf-8)rgzUnable to read files rf)_os_release_cache_os_release_candidatesr9rr3errnorYcopy)r candidaterFes r"freedesktop_os_releaser0s  /I )g6!(9!(<%7  ! ! ##0' 2H(I'JK   ! ! ##76  s- B  BB B B  B+ B&&B+__main__rz--terse nonaliasedz --nonaliased)Nr$r$i@)r$)r$r$r$r^)r$r$r$r$)r$rr$)r$r$rrr)FF)Er __copyright__ __version__ collectionsr.rr4rrrr#rQr]rxrrrrrrrrrrrrr rr$r(r0r:rHr5rMr[r]r{ namedtupler}rrrqr~rrrrrrrrrrrrrrrrjrrrrruargvrrprintexitrrr"rs/t *    b R B C    N` 202#<4$l, ,  [$<*| (),)& +F&$T@   $N    NNRIX8''T+ )AK-/)AX Ur `D  /  H\D6$2 z  9I$9E388+NNchh4NG (7E "# CHHQK W '''sE""E.-E.