U .eTi @sdZddlZddlZddlZddlZddlmZmZz ddlZWne k r\ddl ZYnXdddddd d d d d dg Z ddZ ej reje ej Zn e eZejdkrdeddkre ejeeZejdkr deddkr e ejeeeZejdkrBdeddkrBe ejeeeZddZeZdaddZeZedZddZejdZ ejdd Z!e de d!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,d-Z/dEd.d/Z0d0dZ1d1d2Z2d3d4Z3dFd5dZ4d6dZ5d7d Z6d8d Z7e.dd9fd:d Z8e.dd9fd;dZ9dd ZdBdCZ?e@dDkre?dS)Gz-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)pathrK/usr/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.localZModulesTF)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_prefixZ posix_homeincludez{srcdir}/Include platincludez{projectbase}/.T) _cfg_readZ resourcesr__name__rsplitfindAssertionErrorZ as_stream_SCHEMESZreadfp _PYTHON_BUILDset)rZbackport_packageZ_finderZ_cfgfilesschemerrr_ensure_cfg_readDs    r-z \{([^{]*?)\}c st|dr|d}nt}|}|D]8}|dkr._replacer) r-Z has_sectionitemstuplesectionsZ has_optionr*Zremove_sectiondict _VAR_REPLsub)configr.r9ZsectionZoptionvaluer6rr4r_expand_globalsYs$       r?rcsfdd}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|dSr/)r1renvironr2 local_varsrrr6s    z_subst_vars.._replacerr;r<)rrCr6rrBr _subst_varss rEcCs0|}|D]\}}||kr"q|||<qdSr)keysr7)Z target_dictZ other_dictZ target_keyskeyr>rrr _extend_dicts rHcCs`i}|dkri}t|tt|D]4\}}tjdkrDtj|}tjt ||||<q&|S)N)posixr) rHrr(r7rr3r expandusernormpathrE)r,varsresrGr>rrr _expand_varss   rNcsfdd}t||S)Ncs$|d}|kr|S|dSr/r0r2rLrrr6s zformat_value.._replacerrD)r>rLr6rrOr format_values rPcCstjdkrdStjS)NrIr )rr3rrrr_get_default_schemes rQcCstjdd}dd}tjdkrBtjdp.d}|r8|S||dStjdkr|td }|r||r`|S|dd |d tjdd S|r|S|dd SdS)NPYTHONUSERBASEcWstjtjj|Sr)rrrJr)argsrrrjoinusersz_getuserbase..joinuserrAPPDATA~PythondarwinZPYTHONFRAMEWORKLibraryz%d.%drz.local)rrAgetr3sysplatformr version_info)env_baserTbaseZ frameworkrrr _getuserbases$     r`c 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#rrz$$$)CFLAGSLDFLAGSZCPPFLAGSrTFZPY_r@)recompilecodecsopen readlines startswithstripmatchr1replaceint ValueErrorlistrFlenr8searchstrrrAendstartremover7 isinstanceupdate)filenamerLZ _variable_rxZ _findvar1_rxZ _findvar2_rxZdoneZnotdoneflineslinemnvZtmpvr5Zrenamed_variablesr3r>founditemZafterkrrr_parse_makefiles                            rcCsDtrtjtdSttdr,dttjf}nd}tjt d|dS)z Return the path of the Makefile.ZMakefileabiflagsz config-%s%sr=stdlib) r)rrrrhasattrr[_PY_VERSION_SHORTrr)Zconfig_dir_namerrrrMs  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 BLDSHAREDZLDSHARED) rrIOErrorrrrrlrr))rLZmakefileemsgZconfig_hr~rrr _init_posixXs&   rcCsVtd|d<td|d<td|d<d|d<d |d <t|d <tjttj|d <d S)z+Initialize the module as appropriate for NTrZLIBDESTZ platstdlibZ BINLIBDESTr!Z INCLUDEPYz.pydZSOz.exeZEXEZVERSIONZBINDIRN)r_PY_VERSION_SHORT_NO_DOTrrdirnamerr[ executablerOrrr_init_non_posixts   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_]+) [*]/ rrr)rirjreadlinerpr1rrrs)fprLZ define_rxZundef_rxrrrrrrrrs&      cCs:tr$tjdkrtjtd}q,t}ntd}tj|dS)zReturn the path of pyconfig.h.rZPCr"z pyconfig.h)r)rr3rrrr)Zinc_dirrrrrs  cCstttS)z,Return a tuple containing the schemes names.)r8sortedr(r9rrrrr scCs tdS)z*Return a tuple containing the paths names.r )r(Zoptionsrrrrr 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)r-rNr:r(r7)r,rLexpandrrrr s cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r3r,rLrrrrrscGstdkrziattd<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_prefixZ py_versionZpy_version_shortrrZpy_version_nodotr_ZplatbaseZ projectbaserre)rZos2rIz2.6userbasesrcdirrXr)rhZ BASECFLAGSrgZ PY_CFLAGSrz -arch\s+\w+\s z-isysroot [^ ]*Z ARCHFLAGSrgz-isysroot\s+(\S+)rz-isysroot\s+\S+(\s|$))# _CONFIG_VARS_PREFIX _EXEC_PREFIX _PY_VERSIONrrr[rAttributeErrorrr3rrversionr`rr)getcwdrrisabsrrKr\unamerrsplitrir<rArZrvr1existsappend)rSr_cwdrZkernel_versionZ major_versionrGflagsZarchrgrZsdkZvalsr3rrrrs                   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) )rrZ)r3rrrrRscCs^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 ()Zamd64z win-amd64Zitaniumzwin-ia64rIr/rer_-NZlinuxz%s-%sZsunosr5Zsolarisz%d.%sr@rZirixZaixz%s-%s.%scygwinz[\d.]+rXZMACOSX_DEPLOYMENT_TARGETz0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)rrZmacosxz10.4.z-archrgZfatz -arch\s+(\S+))i386ppc)rx86_64Zintel)rrrZfat3)ppc64rZfat64)rrrrZ universalz%Don't know machine value for archs=%rrlr)ZPowerPCZPower_Macintoshrrz%s-%s-%s) rr3r[rr&r\rulowerrrrqrrrirjrpr1rrZrlrcloservreadrrrofindallr8rr*rsmaxsize)rijZlookZosnameZhostreleasermachineZrel_rerZcfgvarsZmacverZ macreleaser~ZcflagsZarchsrrrr [s     $                    cCstSr)rrrrrr scCsFtt|D]0\}\}}|dkr0td|td||fqdS)Nrz%s: z %s = "%s") enumeraterr7print)titledataindexrGr>rrr _print_dicts rcCsRtdttdttdtttdtttdtdS)z*Display all information sysconfig detains.zPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"ZPathsZ VariablesN)rr r rQrr rrrrr_mains r__main__)N)N)A__doc__rkrrir[Zos.pathrrZ configparser ImportErrorZ ConfigParser__all__rrrrrrr3rrrr)r#r-ZRawConfigParserr(rjr;r?rrrrrrKrrrrrZ _USER_BASErErHrNrPrQr`rrrrrrr r r rrrr r rrr$rrrrs  "" #   v     #