U .e@a @sdZddlZddlZddlmZmZdddddd d d d d dg ZdhZddddddddddddddddddddddddd ddd!d!d"d"d#d$d%d&d'd'd(d)d*d+d%d&d,d,d-d-d.d+d%d&d/Zd&Z ej dZ d0ej dd1Zd2ej dd1ZejejZejejZejejZejejZdadZd3d4ZejrVejeejZn ee Zej!d5kre"#d6reej$eeeZd7ej%kreej%d7Zd8d9Z&e'ed:dZ(ej!d5krd;d<Z)e)eZe)e(Z(djd>d?Z*e*d@Z+e+r dAD]Z,dBee,dC<dDee,dE<qdFdGZ-dHdIZ.dJdKZ/dLdMZ0dNdOZ1dkdPdQZ2dRdZ3dSdTZ4dUdVZ5dWdXZ6dYdZZ7dld[dZ8d\dZ9d]d Z:d^d Z;e0dd@fd_d ZdbdZ?dcd Z@ddd ZAdedfZBdgdhZCeDdikreCdS)mz-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_hZMACOSX_DEPLOYMENT_TARGETz/{installed_base}/lib64/python{py_version_short}z){platbase}/lib64/python{py_version_short}z1{base}/lib/python{py_version_short}/site-packagesz7{platbase}/lib64/python{py_version_short}/site-packagesz;{installed_base}/include/python{py_version_short}{abiflags}z?{installed_platbase}/include/python{py_version_short}{abiflags}z {base}/binz{base})stdlib platstdlibpurelibplatlibinclude platincludescriptsdataz{installed_base}/lib/pythonz{base}/lib/pythonz{installed_base}/include/pythonz{installed_base}/Libz {base}/Libz{base}/Lib/site-packagesz{installed_base}/Includez{base}/Scriptsz#{userbase}/Python{py_version_nodot}z1{userbase}/Python{py_version_nodot}/site-packagesz+{userbase}/Python{py_version_nodot}/Includez+{userbase}/Python{py_version_nodot}/Scriptsz {userbase})rrrrrrrz){userbase}/lib64/python{py_version_short}z5{userbase}/lib/python{py_version_short}/site-packagesz7{userbase}/lib64/python{py_version_short}/site-packagesz+{userbase}/include/python{py_version_short}z{userbase}/binz{userbase}/lib/pythonz#{userbase}/lib/python/site-packagesz{userbase}/include) posix_prefix posix_homentZnt_userZ posix_userZosx_framework_user%d.%dz%d%dcCs(z t|WStk r"|YSXdSN)rOSError)pathr!/usr/lib64/python3.8/sysconfig.py_safe_realpathis r!r)z\pcbuild\win32z\pcbuild\amd64Z_PYTHON_PROJECT_BASEcCs,dD]"}tjtj|d|rdSqdS)N)ZSetupz Setup.localZModulesTF)osrisfilejoin)dfnrrr _is_python_source_dir~sr'_homecCs0|r,tj|tjtjtdr,tS|S)NZPCbuild)r"rnormcase startswithr$_PREFIX)r%rrr _fix_pcbuilds r,FcCs|rtrttSttSr) _sys_homer' _PROJECT_BASE)Z check_homerrr is_python_buildsr/T)rrz{srcdir}/Includerz{projectbase}/.rc Csnz|jf|WStk rhz|jftjWYStk rb}ztd|dW5d}~XYnXYnXdS)Nz{%s})formatKeyErrorr"environAttributeError)sZ local_varsvarrrr _subst_varssr6cCs0|}|D]\}}||kr"q|||<qdSr)keysitems)Z target_dictZ other_dictZ target_keyskeyvaluerrr _extend_dicts r;cCsbi}|dkri}t|tt|D]4\}}tjdkrFtj|}tjt ||||<q(|S)N)posixr) r;r_INSTALL_SCHEMESr8r"namer expandusernormpathr6)schemevarsresr9r:rrr _expand_varss   rDcCstjdkrdStjS)Nr<r)r"r>rrrr _get_default_schemes rEcCsztjdd}|r|Sdd}tjdkrBtjdp6d}||dStjdkrptjrp|dd tjd tjdd S|dd S) NPYTHONUSERBASEcWstjtjj|Sr)r"rr?r$)argsrrr joinusersz_getuserbase..joinuserrAPPDATA~PythondarwinLibraryrrz.local)r"r2getr>sysplatform _framework version_info)env_baserHbaserrr _getuserbases   rUc Cs`ddl}|d}|d}|d}|dkr2i}i}i}t|dd}|} W5QRX| D]} | ds^| d krzq^|| } | r^| d d \} } | } | d d }d |kr| || <q^z| t krt t | } Wn$t k r| d d || <Yq^X| || <q^t | }d}t|dkr&t|D]}||}||}||}|rv|rv||krp|n|} n|r|n|} | dk r | d } d}| |krt|| }n| |krd}nx| tjkrtj| }n`| |kr0|dr |dd|kr d }n$d| |krd}nt|d| }n d || <}|r|| d}|d| ||}d |kr~|||<nz|t krt t |}Wn"t k r|||<Yn X|||<|||dr|dd|kr|dd}||kr|||<n|||<||q,q|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. rNz"([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_]*)}surrogateescape)errors#rz$$$)ZCFLAGSZLDFLAGSZCPPFLAGSTFZPY_)recompileopen readlinesr*stripmatchgroupreplace _ALWAYS_STR ValueErrorintlistr7lentuplesearchstartstrr"r2endremover8 isinstanceupdate)filenamerBr]Z _variable_rxZ _findvar1_rxZ _findvar2_rxZdoneZnotdoneflineslinemnvZtmpvZ variablesZrenamed_variablesr>r:Zm1Zm2founditemZafterkrrr _parse_makefiles                                 r|cCsdtrtjtptdSttdr0dttj f}nd}ttj drP|dtj j 7}tjt d|dS)z Return the path of the Makefile.ZMakefileabiflagsz config-%s%sZconfig _multiarchz-%sr) _PYTHON_BUILDr"rr$r-r.hasattrrO_PY_VERSION_SHORTr}implementationr~r)Zconfig_dir_namerrr rWs  c Cs(tjddjtjtjttjdddS)NZ_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}r~rY)ZabirPZ multiarch) r"r2rNr0rOr}rPgetattrrrrrr _get_sysconfigdata_nameds rc Csddl}i}t}zt||WnJtk rj}z,d|}t|drR|d|j}t|W5d}~XYnXt}z"t|}t||W5QRXWnJtk r}z,d|}t|dr|d|j}t|W5d}~XYnXt r|d|d<t }dt j kr$ddl }||} || _| t j|<d ttf} tt d rF| d 7} tj| d d tj| |d} t| ddd(}|d|d|j||dW5QRXtdddd}|| W5QRXdS)z;Generate the Python module containing build-time variables.rNz.invalid Python installation: unable to open %sstrerrorz (%s)ZLDSHAREDZ BLDSHAREDrLzbuild/lib.%s-%sZgettotalrefcountz-pydebugT)exist_okz.pywutf8)encodingzB# system configuration generated and used by the sysconfig module zbuild_time_vars = )streamzpybuilddir.txt)pprintrr|rrrrr_rrrrOrPtypes ModuleTypebuild_time_varsmodulesr rr"makedirsrr$write) rrBZmakefileemsgZconfig_hrsr>rmoduleZ pybuilddirZdestfilerrr _generate_posix_varsmsL          rcCs0t}t|ttdgd}|j}||dS)z7Initialize the module as appropriate for POSIX systems.rrN)r __import__globalslocalsrrq)rBr>Z_temprrrr _init_posixsrcCsfddl}td|d<td|d<td|d<|d|d <d |d <t|d <tjttj |d <dS)z+Initialize the module as appropriate for NTrNrZLIBDESTrZ BINLIBDESTrZ INCLUDEPY EXT_SUFFIXz.exeZEXEZVERSIONZBINDIR) _imprextension_suffixes_PY_VERSION_SHORT_NO_DOTr"rdirnamer!rO executable)rBrrrr _init_non_posixs   rc Cs|dkr i}ddl}|d}|d}|}|s6q||}|r|dd\}}z|tkrbtt|}Wntk rYnX|||<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. Nrz"#define ([A-Z][A-Za-z0-9_]+) (.*) z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/ rZr)r]r^readlinerbrcrerfrg) fprBr]Z define_rxZundef_rxrurvrwrxrrr rs,      cCsBtr,tjdkr"tjtptd}q4tp(t}ntd}tj|dS)zReturn the path of pyconfig.h.rZPCrz pyconfig-64.h)rr"r>rr$r-r.r)Zinc_dirrrr rs   cCs tttS)z,Return a tuple containing the schemes names.)rjsortedr=rrrr r scCstS)z*Return a tuple containing the paths names.) _SCHEME_KEYSrrrr r scCs|rt||St|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)rDr=)rArBexpandrrr r s cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r>rArBrrrr r scGsxtdkrFiattd<ttd<ttd<ttd<ttd<ttd<ttd<ttd <ttd <ttd <zt j td <Wnt k rd td <YnXt j dkrttt j dkrtttd}|dk r|td<ttd<tdt}t j dkrtrt jt}t j||}nt jt}t|td<t jdkrFddl}|t|rpg}|D]}|t|qT|StSdS)anWith 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 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_shortZpy_version_nodotZinstalled_baserTZinstalled_platbaseZplatbaseZ projectbaser}rYrr<rSOuserbasesrcdirrLr) _CONFIG_VARSr+ _EXEC_PREFIX _PY_VERSIONrr _BASE_PREFIX_BASE_EXEC_PREFIXr.rOr}r3r"r>rrrNrUrrrrr$r!rP _osx_supportZcustomize_config_varsappend)rGrrrTrZvalsr>rrr rsP          cCs*|dkrddl}|dtdt|S)zReturn the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) rrNz SO is deprecated, use EXT_SUFFIXr)warningswarnDeprecationWarningrrN)r>rrrr r^sc CstjdkrFdtjkrdSdtjkr.dSdtjkr@dStjStjdksZttd s`tjSd tjkrttjd St\}}}}}| d d }| d d}| d d}|dddkrd||fS|dddkr,|ddkrd}dt |dd|ddf}ddd}|d|tj 7}n|dddkrLd |||fS|dd!d"krd"}ddl }| d#}||}|r|}n2|dd!d$krddl} | t|||\}}}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; on Linux, the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. rZamd64z win-amd64z(arm)z win-arm32z(arm64)z win-arm64r<unameZ_PYTHON_HOST_PLATFORM/rY _-NZlinuxz%s-%sZsunosr5Zsolarisz%d.%sr\rZ32bitZ64bit)ilz.%sZaixz%s-%s.%scygwinz[\d.]+rLz%s-%s-%s)r"r>rOversionlowerrPrr2rrdrgmaxsizer]r^rbrcrZget_platform_osxr) ZosnameZhostreleasermachineZbitnessr]Zrel_rervrrrr r jsT            cCstSr)rrrrr r scCsFtt|D]0\}\}}|dkr0td|td||fqdS)Nrz%s: z %s = "%s") enumeraterr8print)titlerindexr9r:rrr _print_dicts rcCsfdtjkrtdStdttdttdtttdtttdt dS)z*Display all information sysconfig detains.z--generate-posix-varsNzPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"ZPathsZ Variables) rOargvrrr r rErr rrrrr _mains  r__main__)F)N)N)E__doc__r"rOZos.pathrr__all__rer=rrsplitrrRrrrr@rr+ base_prefixrrrbase_exec_prefixrrZ _USER_BASEr!rrr.getcwdr>rendswithr$r2r'rr-r,r/rrAr6r;rDrErUr|rrrrrrrr r r rrrr r rr__name__rrrr s     ?              ? "  M P