o ?Ogk @sDdZddlZddlZddlmZmZgdZdhZdddd d d d d dddddddd d ddddddddd ddZddZ e duZ e reeddddddddd d d!d!d"d#ddd$d$d%d%d"d#ddd&OZdZ ej dZejdd'ejd(Zejdejd(ZejejZejejZejejZejejZdadZd)Zd*Zd+Z d,d-Z!ej"rej#e!ej"Z$ne!e%Z$ej&d.kre$'(d/re!ej)e$eeZ$d0ej*vre!ej*d0Z$d1d2Z+e,ed3dZ-ej&d.krd4d5Z.e.e$Z$e.e-Z-dsd7d8Z/e/d9Z0e0r&d:D]Z1ee1Z1e1d;e1d<<d=e1d;<d>e1d?<qd@dAZ2dBdCZ3dDdEZ4dFdGZ5dHdIZ6dJdKZ7dtdLdMZ8dNdOZ9dPdQZ:dRdSZ;dTdUZdZd[Z?d\d]Z@d^d_ZAe7dd9fd`daZBe7dd9fdbdcZCdddeZDdfdgZEdhdiZFdjdkZGdldmZHdndoZIdpdqZJeKdrkreJdSdS)vz-Access to Python's configuration information.N)pardirrealpath) get_config_h_filenameget_config_varget_config_varsget_makefile_filenameget_pathget_path_names get_paths get_platformget_python_versionget_scheme_namesparse_config_hZMACOSX_DEPLOYMENT_TARGETz6{installed_base}/{platlibdir}/python{py_version_short}z0{platbase}/{platlibdir}/python{py_version_short}z1{base}/lib/python{py_version_short}/site-packagesz>{platbase}/{platlibdir}/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}/Scripts) posix_prefix posix_homentcCstjdd}|r |StjdkrdSdd}tjdkr(tjdp"d}||dStjd krCtjrC|dd tjtjd d tjd S|ddS)NPYTHONUSERBASEvxworkscWstjtjj|SN)ospath expanduserjoin)argsr"0/opt/alt/python310/lib64/python3.10/sysconfig.pyjoinuserIsz_getuserbase..joinuserrAPPDATA~PythondarwinLibraryr.z.local)renvirongetsysplatformname _framework version_info)env_baser$baser"r"r# _getuserbase@s     r5z({userbase}/Python{py_version_nodot_plat}z6{userbase}/Python{py_version_nodot_plat}/site-packagesz0{userbase}/Python{py_version_nodot_plat}/Includez0{userbase}/Python{py_version_nodot_plat}/Scriptsz {userbase})rrrrrrrz0{userbase}/{platlibdir}/python{py_version_short}z5{userbase}/lib/python{py_version_short}/site-packagesz+{userbase}/include/python{py_version_short}z{userbase}/binz{userbase}/lib/pythonz#{userbase}/lib/python/site-packages)nt_user posix_userosx_framework_userr*r+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_]*)}cCs"zt|WSty|YSwr)rOSError)rr"r"r#_safe_realpaths   r:r)z\pcbuild\win32z\pcbuild\amd64Z_PYTHON_PROJECT_BASEcCs,dD]}tjtj|d|rdSqdS)N)ZSetupz Setup.localZModulesTF)rrisfiler )dfnr"r"r#_is_python_source_dirs r>_homecCs0|rtj|tjtjtdrtS|S)NZPCbuild)rrnormcase startswithr _PREFIX)r<r"r"r# _fix_pcbuilds rCFcCs|rtrttSttSr) _sys_homer> _PROJECT_BASE)Z check_homer"r"r#is_python_buildsrFT)rrrZheadersz{srcdir}/Includez{projectbase}/.rc Cshz |jdi|WSty3}zz|jditjWWYd}~Sty.t|dwd}~ww)Nr")formatKeyErrorrr,AttributeError)sZ local_varsvarr"r"r# _subst_varss   rLcCs0|}|D] \}}||vrq|||<qdSr)keysitems)Z target_dictZ other_dictZ target_keyskeyvaluer"r"r# _extend_dicts  rQcCsbi}|duri}t|tt|D]\}}tjdvr#tj|}tjt ||||<q|S)N)posixr) rQr_INSTALL_SCHEMESrNrr0rrnormpathrL)schemevarsresrOrPr"r"r# _expand_varss   rXcCs>tjdkr ddddStjdkrtjrddddSddddS) Nrrr6)prefixhomeuserr(rr8r7)rr0r.r/r1r"r"r"r#_get_preferred_schemess r\cCs*t|}|tvrt|d|d|S)Nz returned z., which is not a valid scheme on this platform)r\rS ValueError)rOrUr"r"r#get_preferred_schemes r^cCstdS)NrY)r^r"r"r"r#get_default_schemesr_c CsVddl}|dur i}i}i}t|tdd }|}Wdn1s&wY|D]S}|ds:|dkr;q-|t|} | r| dd\} } | } | d d} d | vr^| || <q-z | t vret t | } Wnt y{| d d || <Yq-w| || <q-t|} d }t| dkrt| D]}||}|t|}|t|}|r|r||kr|n|} n|r|n|} | dur{| d} d }| |vrt|| }n@| |vrd }n9| tjvrtj| }n.| |vr|dr|dd|vrd}nd| |vrd }nt|d| }nd|| <}|rz|| d}|d| ||}d |vr5|||<qz |t vr=t t |}Wnt yR|||<Ynw|||<| ||drz|dd|vrz|dd}||vrz|||<q|r|||<| |qt| dks|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. rNsurrogateescape)encodingerrors#r+z$$$)ZCFLAGSZLDFLAGSZCPPFLAGSTFZPY_)reopenr.getfilesystemencoding readlinesrAstripmatch _variable_rxgroupreplace _ALWAYS_STRr]intlistrMlentuplesearch _findvar1_rx _findvar2_rxstartstrrr,endremoverN isinstanceupdate)filenamerVZkeep_unresolvedrhZdoneZnotdoneflineslinemnvZtmpvZ variablesZrenamed_variablesr0rPZm1Zm2founditemZafterkr"r"r#_parse_makefiles                             D   rcCshtr tjtptdSttdrdttj }nd}ttj dr*|dtj j 7}tjt d|dS)z Return the path of the Makefile.ZMakefileabiflagszconfig-Zconfig _multiarch-r) _PYTHON_BUILDrrr rDrEhasattrr._PY_VERSION_SHORTrimplementationrr)Zconfig_dir_namer"r"r#rs  rc Cs2ttjdd}tjddtjdtjd|S)NrrdZ_PYTHON_SYSCONFIGDATA_NAMEZ_sysconfigdata__)getattrr.rrr,r-rr/)Z multiarchr"r"r#_get_sysconfigdata_names rc Csddl}i}t}zt||Wn#ty3}zd|}t|dr+|d|jd}t|d}~wwt}zt|dd }t||Wdn1sNwYWn#tyw}zd|}t|dro|d|jd}t|d}~wwt r|d |d <t }d t j vrddl }||} || _| t j|<d td t} tt dr| d7} tj| ddtj| |d} t| ddd}|d|d|j||dWdn1swYtdddd}|| WddS1swYdS)z;Generate the Python module containing build-time variables.rNz,invalid Python installation: unable to open strerrorz ()zutf-8)raZLDSHAREDZ BLDSHAREDr(z build/lib.rZgettotalrefcountz-pydebugT)exist_okz.pywutf8zB# system configuration generated and used by the sysconfig module zbuild_time_vars = )streamzpybuilddir.txt)pprintrrr9rrrrirrrr.r/types ModuleTypebuild_time_varsmodulesr rrmakedirsrr write) rrVZmakefileemsgZconfig_hrr0rmoduleZ pybuilddirZdestfiler"r"r#_generate_posix_varss\             "rcCs0t}t|ttdgd}|j}||dS)z7Initialize the module as appropriate for POSIX systems.rrN)r __import__globalslocalsrr~)rVr0Z_temprr"r"r# _init_posixsrcCsnddl}td|d<td|d<td|d<|d|d <d |d <t|d <tjttj |d <d|d<dS)z+Initialize the module as appropriate for NTrNrZLIBDESTrZ BINLIBDESTrZ INCLUDEPY EXT_SUFFIXz.exeZEXEZVERSIONZBINDIRrdZTZPATH) _imprextension_suffixes_PY_VERSION_SHORT_NO_DOTrrdirnamer:r. executable)rVrr"r"r#_init_non_posixs    rc Cs|duri}ddl}|d}|d} |}|s |S||}|rH|dd\}}z |tvr4tt|}Wn tyBYnw|||<n||}|rVd||d<q)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_]+) [*]/ Tr+re)rhcompilereadlinermrorqr]rr) fprVrhZ define_rxZundef_rxrrrrr"r"r#rs2       rcCsBtrtjdkrtjtp td}n tpt}ntd}tj|dS)zReturn the path of pyconfig.h.rZPCrz pyconfig.h)rrr0rr rDrEr)Zinc_dirr"r"r#rs   rcCs tttS)z,Return a tuple containing the schemes names.)rusortedrSr"r"r"r#r !s r cCtS)z*Return a tuple containing the paths names.) _SCHEME_KEYSr"r"r"r#r &sr cCs|rt||St|S)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. )rXrS)rUrVexpandr"r"r#r +s r cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r0rUrVrr"r"r#r7srcGstduriattd<ttd<ttd<ttd<ttd<ttd<ttd<ttd <ttd <ttd <t j td <zt j td <Wn t yGdtd <Ynwz t j ddtd<Wn t y`dtd<Ynwtjdkrjtttjdkrstttd}|dur|td<trttd<tdt}tjdkrtrtjt}tj||}ntjt}t|td<t jdkrddl}|t|rg}|D] }|t|q|StS)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. NrY exec_prefixZ py_versionZpy_version_shortZpy_version_nodotZinstalled_baser4Zinstalled_platbaseZplatbaseZ projectbase platlibdirrrdr*Zpy_version_nodot_platrrRrSOuserbasesrcdirr(r) _CONFIG_VARSrB _EXEC_PREFIX _PY_VERSIONrr _BASE_PREFIX_BASE_EXEC_PREFIXrEr.rrrIwinverrprr0rrr-_HAS_USER_BASEr5rrrrr r:r/ _osx_supportZcustomize_config_varsappend)r!rrr4rZvalsr0r"r"r#r?s`               rcCs*|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_SUFFIXre)warningswarnDeprecationWarningrr-)r0rr"r"r#rs rc Cstjdkr#dtjvrdSdtjvrdSdtjvr dStjStjdks-ttd s0tjSd tjvr:tjd St\}}}}}| d d }| d d}| d d}|dddkrf|d|S|dddkr|ddkrd}t |ddd|dd}ddd}|d|tj 7}nH|dddkrddl m }|S|ddd krd }ddl}|d!}||} | r| }n|ddd"krddl} | t|||\}}}|d|d|S)#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-arm64rRunameZ_PYTHON_HOST_PLATFORM/rd rrNZlinuxZsunosr5Zsolarisrgr*reZ32bitZ64bit)ilZaix) aix_platformcygwinz[\d.]+r()rr0r.versionlowerr/rr,rrprrmaxsizeZ _aix_supportrrhrrmrorZget_platform_osxr) ZosnameZhostreleasermachineZbitnessrrhZrel_rerrr"r"r#r sV      "     r cCrr)rr"r"r"r#r sr cCsdddl} |t|p|t|}|r.|\}}|d|||d||d}n |Sq)aExpand Makefile-style variables -- "${foo}" or "$(foo)" -- in 'string' according to 'vars' (a dictionary mapping variable names to values). Variables not present in 'vars' are silently expanded to the empty string. The variable values in 'vars' should not contain further variable expansions; if 'vars' is the output of 'parse_makefile()', you're fine. Returns a variable-expanded version of 's'. rNTr+)rhrvrwrxspanr-ro)rJrVrhrZbegr{r"r"r#expand_makefile_varss *rcCsNtt|D]\}\}}|dkrt|dtd|d|dqdS)Nrz:  z = "") enumeraterrNprint)titlerindexrOrPr"r"r# _print_dict s rcCsrdtjvr tdStdtdtdtdtdtdttdtttdt dS) z*Display all information sysconfig detains.z--generate-posix-varsNz Platform: "rzPython version: "zCurrent installation scheme: "ZPathsZ Variables) r.argvrrr r r_rr rr"r"r"r#_mains  r__main__)F)NTr)L__doc__rr.Zos.pathrr__all__rqrSr5rrrsplitrr2rrrrTrYrB base_prefixrrrbase_exec_prefixrrZ _USER_BASErnrwrxr:rrrEgetcwdr0rendswithr r,r>rrDrCrFrrUrLrQrXr\r^r_rrrrrrrrr r r rrrr r rrr__name__r"r"r"r#s  &                ? "  S Q