U v_h @sdZddlZddlZddlZddlZddlmZmZz ddlZWne k r\ddl ZYnXdddddd d d d d dg Z ddZ ej reje ej Zn e eZejdkrdeddkre ejeeZejdkr deddkr e ejeeeZejdkrBdeddkrBe ejeeeZddZeZdaddZeZedZddZd ejdd!Zd"ejdd#Z d$ejdd#Z!ej"ej#Z$ej"ej%Z&da'dZ(d%d&Z)d'd(Z*d)d*Z+d+d,Z,d-d.Z-d/d0Z.dHd1d2Z/d3dZ0d4d5Z1d6d7Z2dId8dZ3d9dZ4d:d Z5d;d Z6e-dddZ8d?dZ9d@dZ:dAd Z;dBd Ze?dGkre>dS)Jz-Access to Python's configuration information.N)pardirrealpathget_config_h_filenameget_config_varget_config_varsget_makefile_filenameget_pathget_path_names get_paths get_platformget_python_versionget_scheme_namesparse_config_hcCs(z t|WStk r"|YSXdSN)rOSError)pathr/builddir/build/BUILDROOT/alt-python38-pip-20.2.4-1.el7.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/distlib/_backport/sysconfig.py_safe_realpath"s rntZpcbuildiz\pc\viz\pcbuild\amd64icCs,dD]"}tjtjtd|rdSqdS)N)z Setup.distz Setup.localModulesTF)osrisfilejoin _PROJECT_BASE)fnrrris_python_build:srFc Cstsddlm}tddd}||}|d}|s>td|}t |W5QRXt rdD] }t |d d t |d d qdd adS)N)finder.rz sysconfig.cfgzsysconfig.cfg exists) posix_prefix posix_homeincludez{srcdir}/Include platincludez{projectbase}/.T) _cfg_read resourcesr__name__rsplitfindAssertionError as_stream_SCHEMESreadfp _PYTHON_BUILDset)rZbackport_packageZ_finderZ_cfgfilesschemerrr_ensure_cfg_readDs    r2z \{([^{]*?)\}c st|dr|d}nt}|}|D]8}|dkr._replacer) r2 has_sectionitemstuplesections has_optionr/remove_sectiondict _VAR_REPLsub)configr3r?sectionoptionvaluer;rr9r_expand_globalsYs$       rIz%s.%s.%sz%s.%srz%s%scsfdd}t||S)zIn the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`. If there is no corresponding value, leave the token unchanged. cs8|d}|kr|S|tjkr.tj|S|dSr4)r6renvironr7 local_varsrrr;s    z_subst_vars.._replacerrCrD)rrMr;rrLr _subst_varss rOcCs0|}|D]\}}||kr"q|||<qdSr)keysr=) target_dict other_dict target_keyskeyrHrrr _extend_dicts rUcCs`i}|dkri}t|tt|D]4\}}tjdkrDtj|}tjt ||||<q&|S)N)posixr) rUrr,r=rr8r expandusernormpathrO)r1varsresrTrHrrr _expand_varss   r[csfdd}t||S)Ncs$|d}|kr|S|dSr4r5r7rYrrr;s zformat_value.._replacerrN)rHrYr;rr\r format_values r]cCstjdkrdStjS)NrVr!)rr8rrrr_get_default_schemes r^cCstjdd}dd}tjdkrBtjdp.d}|r8|S||dStjdkr|td }|r||r`|S|dd |d tjdd S|r|S|dd SdS)NPYTHONUSERBASEcWstjtjj|Sr)rrrWr)argsrrrjoinusersz_getuserbase..joinuserrAPPDATA~PythondarwinPYTHONFRAMEWORKLibraryz%d.%drz.local)rrKgetr8sysplatformr version_info)env_baserabaseZ frameworkrrr _getuserbases$     rnc Cstd}td}td}|dkr*i}i}i}tj|ddd}|}W5QRX|D]} | dsZ| d krvqZ|| } | rZ| d d \} } | } | d d } d | kr| || <qZz t | } Wn$t k r| d d || <YqZX| || <qZt | }d}t|dkrt|D]}||}||p>||} | dk r| d } d}| |krpt|| }n| |krd}nx| tjkrtj| }n`| |kr|dr|dd|krd }n$d| |krd}nt|d| }n d || <}|r|| d}|d| ||}d |kr:|||<n~z t |}Wn"t k rh|||<Yn X|||<|||dr|dd|kr|dd}||kr|||<n|||<||qq|D]"\}} t| tr| ||<q|||S)zParse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. z"([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)z\$\(([A-Za-z][A-Za-z0-9_]*)\)z\${([A-Za-z][A-Za-z0-9_]*)}Nzutf-8surrogateescape)encodingerrors#r rz$$$)CFLAGSLDFLAGSCPPFLAGSrTFPY_rJ)recompilecodecsopen readlines startswithstripmatchr6replaceint ValueErrorlistrPlenr>searchstrrrKendstartremover= isinstanceupdate)filenamerY _variable_rx _findvar1_rx _findvar2_rxdonenotdoneflineslinemnvtmpvr:renamed_variablesr8rHfounditemafterkrrr_parse_makefiles                            rcCsDtrtjtdSttdr,dttjf}nd}tjt d|dS)z Return the path of the Makefile.Makefileabiflagsz config-%s%srEstdlib) r.rrrrhasattrri_PY_VERSION_SHORTrr)config_dir_namerrrrKs  c Cst}zt||WnJtk r^}z,d|}t|drF|d|j}t|W5d}~XYnXt}z"t|}t||W5QRXWnJtk r}z,d|}t|dr|d|j}t|W5d}~XYnXtr|d|d<dS)z7Initialize the module as appropriate for POSIX systems.z.invalid Python installation: unable to open %sstrerrorz (%s)N BLDSHAREDLDSHARED) rrIOErrorrrrr|rr.)rYmakefileemsgconfig_hrrrr _init_posixVs&   rcCsVtd|d<td|d<td|d<d|d<d |d <t|d <tjttj|d <d S)z+Initialize the module as appropriate for NTrLIBDEST platstdlib BINLIBDESTr# INCLUDEPYz.pydSOz.exeEXEVERSIONBINDIRN)r_PY_VERSION_SHORT_NO_DOTrrdirnamerri executabler\rrr_init_non_posixrs   rcCs|dkr i}td}td}|}|s.q||}|rx|dd\}}z t|}Wntk rlYnX|||<q ||}|r d||d<q |S)zParse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. Nz"#define ([A-Z][A-Za-z0-9_]+) (.*) z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/ r rr)ryrzreadlinerr6rr)fprY define_rxundef_rxrrrrrrrrs&      cCs:tr$tjdkrtjtd}q,t}ntd}tj|dS)zReturn the path of pyconfig.h.rPCr$z pyconfig.h)r.rr8rrrr)inc_dirrrrrs  cCstttS)z,Return a tuple containing the schemes names.)r>sortedr,r?rrrrr scCs tdS)z*Return a tuple containing the paths names.r!)r,optionsrrrrr sTcCs&t|rt||Stt|SdS)zReturn a mapping containing an install scheme. ``scheme`` is the install scheme name. If not provided, it will return the default scheme for the current platform. N)r2r[rBr,r=)r1rYexpandrrrr s cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r8r1rYrrrrrscGstdkrziattd<ttd<ttd<ttd<tdtdtd<ttd <ttd <ttd <ztjtd <Wntk rd td <YnXt j dkrt tt j dkrt ttj dkrttd<dtkrttd<nttdtd<tr\t j dkr\t}z t }Wntk rd}YnXt jtds\||kr\t j|td}t j|td<tjdkrzt d}t|dd}|dkrdD]2}t|}tdd|}tdd|}|t|<qndt jkrt jd}dD]0}t|}tdd|}|d|}|t|<qtdd } td| } | dk rz| d} t j!| szdD]$}t|}tdd|}|t|<qT|rg} |D]} | "t| q| StSdS)ayWith no arguments, return a dictionary of all configuration variables relevant for the current platform. On Unix, this means every variable defined in Python's installed Makefile; On Windows and Mac OS it's a much smaller set. With arguments, return a list of values that result from looking up each argument in the configuration variable dictionary. Nprefix exec_prefix py_versionpy_version_shortrrpy_version_nodotrmplatbase projectbaserrs)rZos2rVz2.6userbasesrcdirrer)rv BASECFLAGSru PY_CFLAGSrz -arch\s+\w+\s z-isysroot [^ ]*Z ARCHFLAGSruz-isysroot\s+(\S+)r z-isysroot\s+\S+(\s|$))# _CONFIG_VARS_PREFIX _EXEC_PREFIX _PY_VERSIONrrrirAttributeErrorrr8rrversionrnrr.getcwdrrisabsrrXrjunamersplitryrDrKrhrr6existsappend)r`rmcwdrZkernel_version major_versionrTflagsarchrurZsdkvalsr8rrrrs                   cCs t|S)zReturn the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) )rrh)r8rrrrPscCs^tjdkrnd}tj|}|dkr(tjStjd|}tj|t||}|dkr\dS|dkrhdStjStjd ksttd stjSt \}}}}}| d d }| d d}| d d}|dddkrd||fS|dddkr&|ddkrPd}dt |dd|ddf}n*|dddkrDd||fS|dddkrdd|||fS|ddd krd }t d!} | |} | rP| }n|ddd"krPt} | d#} | } z td$}Wntk rYnJXzt d%|} W5|X| dk r2d&| d'd&dd} | s<| } | rP| }d(}| d&d)krd*td+d krd,}td+}t d-|}ttt|}t|d'kr|d}n^|d.krd,}nN|d/krd0}n>|d1krd2}n.|d3krd4}n|d5krd6}ntd7|fn<|d8kr0tjd9krPd:}n |d;krPtjd9krLd<}nd=}d>|||fS)?aReturn a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. for IRIX the architecture isn't particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u irix-5.3 irix64-6.2 Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win-ia64 (64bit Windows on Itanium) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. rz bit ()amd64z win-amd64Zitaniumzwin-ia64rVr/rsr_-Nlinuxz%s-%ssunosr5solarisz%d.%srJrZirixaixz%s-%s.%scygwinz[\d.]+reMACOSX_DEPLOYMENT_TARGETz0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)rr macosxz10.4.z-archrufatz -arch\s+(\S+))i386ppc)rx86_64intel)rrrZfat3)ppc64rfat64)rrrr universalz%Don't know machine value for archs=%rrlr)PowerPCPower_Macintoshrrz%s-%s-%s) rr8rirr)rjrlowerrrrrryrzrr6rrhr|rcloserreadrrrfindallr>rr/rmaxsize)rijZlookosnamehostreleasermachinerel_rerZcfgvarsZmacverZ macreleasercflagsZarchsrrrr Ys     $                    cCstSr)rrrrrr scCsFtt|D]0\}\}}|dkr0td|td||fqdS)Nrz%s: z %s = "%s") enumeraterr=print)titledataindexrTrHrrr _print_dicts rcCsRtdttdttdtttdtttdtdS)z*Display all information sysconfig detains.zPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"Paths VariablesN)r r r r^rr rrrrr_mains r__main__)N)N)@__doc__r{rryrios.pathrr configparser ImportError ConfigParser__all__rrrrrrr8rrrr.r%r2RawConfigParserr,rzrCrIrkrrrrXrrrrr _USER_BASErOrUr[r]r^rnrrrrrrr r r rrrr r rrr'rrrrs  "" !   v     #