o Ƌ|c)l @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_hMACOSX_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#&/opt/conda/lib/python3.10/sysconfig.pyjoinuserIsz_getuserbase..joinuserrAPPDATA~PythondarwinLibraryr.z.local)renvirongetsysplatformname _framework version_info)env_baser%baser#r#r$ _getuserbase@s     r6z({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 rDFcCs|rtrttSttSr) _sys_homer? _PROJECT_BASE)Z check_homer#r#r$is_python_buildsrGT)rrrheadersz{srcdir}/Includez{projectbase}/.rc Cshz |jdi|WSty3}zz|jditjWWYd}~Sty.t|dwd}~ww)Nr#)formatKeyErrorrr-AttributeError)s local_varsvarr#r#r$ _subst_varss   rOcCs0|}|D] \}}||vrq|||<qdSr)keysitems)Z target_dictZ other_dictZ target_keyskeyvaluer#r#r$ _extend_dicts  rTcCsbi}|duri}t|tt|D]\}}tjdvr#tj|}tjt ||||<q|S)N)posixr) rTr_INSTALL_SCHEMESrQrr1rr normpathrO)schemevarsresrRrSr#r#r$ _expand_varss   r[cCs>tjdkr ddddStjdkrtjrddddSddddS) Nrrr7)prefixhomeuserr)rr9r8)rr1r/r0r2r#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_rV ValueError)rRrXr#r#r$get_preferred_schemes racCstdS)Nr\)rar#r#r#r$get_default_schemesrbc 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 readlinesrBstripmatch _variable_rxgroupreplace _ALWAYS_STRr`intlistrPlentuplesearch _findvar1_rx _findvar2_rxstartstrrr-endremoverQ isinstanceupdate)filenamerYZkeep_unresolvedrkZdoneZnotdoneflineslinemnvZtmpvZ variablesZrenamed_variablesr1rSZm1m2founditemZafterkr#r#r$_parse_makefiles                             D   rcCshtr tjtptdSttdrdttj }nd}ttj dr*|dtj j 7}tjt d|dS)z Return the path of the Makefile.ZMakefileabiflagszconfig-config _multiarch-r) _PYTHON_BUILDrrr!rErFhasattrr/_PY_VERSION_SHORTrimplementationrr)Zconfig_dir_namer#r#r$rs  rc Cs2ttjdd}tjddtjdtjd|S)NrrgZ_PYTHON_SYSCONFIGDATA_NAMEZ_sysconfigdata__)getattrr/rrr-r.rr0)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)rdZLDSHAREDZ BLDSHAREDr)z build/lib.rZgettotalrefcountz-pydebugT)exist_okz.pywutf8zB# system configuration generated and used by the sysconfig module zbuild_time_vars = )streamzpybuilddir.txt)pprintrrr:rrrrlrrrr/r0types ModuleTypebuild_time_varsmodulesr rrmakedirsrr!write) rrYZmakefileemsgZconfig_hrr1rmoduleZ pybuilddirZdestfiler#r#r$_generate_posix_varss\             "rcCs0t}t|ttdgd}|j}||dS)z7Initialize the module as appropriate for POSIX systems.rrN)r __import__globalslocalsrr)rYr1Z_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.exeZEXEVERSIONZBINDIRrgTZPATH) _imprextension_suffixes_PY_VERSION_SHORT_NO_DOTrrdirnamer;r/ executable)rYrr#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,rh)rkcompilereadlinerprrrtr`ru) fprYrkZ define_rxZundef_rxrrrrr#r#r$rs2       rcCsBtrtjdkrtjtp td}n tpt}ntd}tj|dS)zReturn the path of pyconfig.h.rZPCrz pyconfig.h)rrr1rr!rErFr)Zinc_dirr#r#r$rs   rcCs tttS)z,Return a tuple containing the schemes names.)rxsortedrVr#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. )r[rV)rXrYexpandr#r#r$r +s r cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r1rXrYrr#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<Ynwtjdkrttttjtddtd<tjdkr}tttd}|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. Nr\ exec_prefixZ py_versionZpy_version_shortZpy_version_nodotZinstalled_baser5Zinstalled_platbaseZplatbaseZ projectbase platlibdirrrgr+Zpy_version_nodot_platrZshareZzoneinforrUrSOuserbasesrcdirr)r) _CONFIG_VARSrC _EXEC_PREFIX _PY_VERSIONrr _BASE_PREFIX_BASE_EXEC_PREFIXrFr/rrrKwinverrsrr1rrr!rr._HAS_USER_BASEr6rrrr;r0 _osx_supportZcustomize_config_varsappend)r"rrr5rvalsr1r#r#r$r?sb               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_SUFFIXrh)warningswarnDeprecationWarningrr.)r1rr#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-arm64rUunameZ_PYTHON_HOST_PLATFORM/rg rrNlinuxZsunosr5Zsolarisrjr+rh32bit64bit)ilaix) aix_platformcygwinz[\d.]+r))rr1r/versionlowerr0rr-rrsrumaxsizeZ _aix_supportrrkrrprrrZget_platform_osxr) osnamehostreleasermachineZbitnessrrkZrel_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,)rkryrzr{spanr.rr)rLrYrkrbegr~r#r#r$expand_makefile_varss *rcCsNtt|D]\}\}}|dkrt|dtd|d|dqdS)Nrz:  z = "") enumeraterrQprint)titlerindexrRrSr#r#r$ _print_dicts rcCsrdtjvr tdStdtdtdtdtdtdttdtttdt dS) z*Display all information sysconfig detains.z--generate-posix-varsNz Platform: "rzPython version: "zCurrent installation scheme: "ZPathsZ Variables) r/argvrrr r rbrr rr#r#r#r$_mains  r__main__)F)NTr)L__doc__rr/os.pathrr__all__rtrVr6rrrsplitrr3rrrrWr\rC base_prefixrrrbase_exec_prefixrrZ _USER_BASErqrzr{r;rrrFgetcwdr1rendswithr!r-r?rrErDrGrrXrOrTr[r_rarbrrrrrrrrr r r rrrr r rrr__name__r#r#r#r$s  &                ? "  T Q