o w[er @sldZddlZddlZddlmZmZgdZdhZdddd d d d d dddddd d d d dddddd d dddddddddd d ddddddddd ddZd d!Z e duZ e ryed"d"d#d#d$d%d&d'd(d(d)d)d*d+d&d'd,d,d-d-d*d+d&d'd.OZd'Z ej dZejdd/ejd0Zejdejd0ZejejZejejZejejZejejZdadZd1Zd2Zd3Z d4d5Z!ej"rej#e!ej"Z$ne!e%Z$ej&d6kre$'(d7re!ej)e$eeZ$d8ej*vre!ej*d8Z$d9d:Z+e,ed;dZ-ej&d6krddbdcZ?dddeZ@dfdgZAe7ddAfdhdiZBe7ddAfdjdkZCdldmZDdndoZEdpdqZFdrdsZGdtduZHdvdwZIdxdyZJeKdzkreJdSdS)~z-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/python{py_version_short}z'{platbase}/lib/python{py_version_short}z {base}/lib/python3/dist-packagesz${platbase}/lib/python3/dist-packagesz7{base}/local/lib/python{py_version_short}/dist-packagesz;{platbase}/local/lib/python{py_version_short}/dist-packagesz{base}/local/binz {base}/localz{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 deb_system posix_local posix_homentcCstjdd}|r |StjdkrdSdd}tjdkr(tjdp"d}||dStjd krCtjrC|dd tjtjd d tjd S|ddS)NPYTHONUSERBASEvxworkscWstjtjj|SN)ospath expanduserjoin)argsr% /usr/lib/python3.10/sysconfig.pyjoinuserasz_getuserbase..joinuserrAPPDATA~PythondarwinLibraryr.z.local)r environgetsysplatformname _framework version_info)env_baser'baser%r%r& _getuserbaseXs     r8z({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)r!r%r%r&_safe_realpaths   r=r)z\pcbuild\win32z\pcbuild\amd64_PYTHON_PROJECT_BASEcCs,dD]}tjtj|d|rdSqdS)N)Setupz Setup.localModulesTF)r r!isfiler#)dfnr%r%r&_is_python_source_dirs rD_homecCs0|rtj|tjtjtdrtS|S)NPCbuild)r r!normcase startswithr#_PREFIX)rBr%r%r& _fix_pcbuilds rJFcCs|rtrttSttSr) _sys_homerD _PROJECT_BASE) check_homer%r%r&is_python_buildsrNT)rrrrrheadersz{srcdir}/Includez{projectbase}/.rc Cshz |jdi|WSty3}zz|jditjWWYd}~Sty.t|dwd}~ww)Nr%)formatKeyErrorr r/AttributeError)s local_varsvarr%r%r& _subst_varss   rVcCs0|}|D] \}}||vrq|||<qdSr)keysitems) target_dict other_dict target_keyskeyvaluer%r%r& _extend_dicts  r^cCsbi}|duri}t|tt|D]\}}tjdvr#tj|}tjt ||||<q|S)N)posixr) r^r_INSTALL_SCHEMESrXr r3r!r"normpathrV)schemevarsresr\r]r%r%r& _expand_varss   recCsztjdkr ddddStjdkrtjrddddStjtjks$ttdr'd}ntj d d }|d vr5d }nd }|dd dS)Nrrr9)prefixhomeuserr+rr; real_prefixDEB_PYTHON_INSTALL_LAYOUTr)debrrr:) r r3r1r2r4 base_prefixrfhasattrr/r0) prefix_scheme deb_buildr%r%r&_get_preferred_schemess( rpcCs*t|}|tvrt|d|d|S)Nz returned z., which is not a valid scheme on this platform)rpr` ValueError)r\rbr%r%r&get_preferred_schemes rrcCstdS)Nrf)rrr%r%r%r&get_default_scheme%srsc 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$$$)CFLAGSLDFLAGSCPPFLAGSTFPY_)reopenr1getfilesystemencoding readlinesrHstripmatch _variable_rxgroupreplace _ALWAYS_STRrqintlistrWlentuplesearch _findvar1_rx _findvar2_rxstartstrr r/endremoverX isinstanceupdate)filenamerckeep_unresolvedrdonenotdoneflineslinemnvtmpv variablesrenamed_variablesr3r]m1m2founditemafterkr%r%r&_parse_makefile)s                             D   rcCshtr tjtptdSttdrdttj }nd}ttj dr*|dtj j 7}tjt d|dS)z Return the path of the Makefile.Makefileabiflagszconfig-config _multiarch-r) _PYTHON_BUILDr r!r#rKrLrmr1_PY_VERSION_SHORTrimplementationrr)config_dir_namer%r%r&rs  rcCs*ttjdd}tjddtjd|S)Nrrx_PYTHON_SYSCONFIGDATA_NAME_sysconfigdata__)getattrr1rr r/r0r) 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)ruLDSHARED BLDSHAREDr+z build/lib.rgettotalrefcountz-pydebugT)exist_okz.pywutf8zB# system configuration generated and used by the sysconfig module zbuild_time_vars = )streamzpybuilddir.txt)pprintrrr<rmrrrrrrr1r2types ModuleTypebuild_time_varsmodulesr rr makedirsr!r#write) rrcmakefileemsgconfig_hrr3rmodule pybuilddirdestfiler%r%r&_generate_posix_varss\             "rcCs0t}t|ttdgd}|j}||dS)z7Initialize the module as appropriate for POSIX systems.rrN)r __import__globalslocalsrr)rcr3_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 NTrNrLIBDESTr BINLIBDESTr INCLUDEPY EXT_SUFFIXz.exeEXEVERSIONBINDIRrxTZPATH) _imprextension_suffixes_PY_VERSION_SHORT_NO_DOTr r!dirnamer=r1 executable)rcrr%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.ry)rcompilereadlinerrrrqr) fprcr define_rxundef_rxrrrrr%r%r&rs2       rcCsDtrtjdkrtjtp td}n tpt}ntdd}tj|dS)zReturn the path of pyconfig.h.rPCrrz pyconfig.h)rr r3r!r#rKrLr)inc_dirr%r%r&r9s    rcCs tttS)z,Return a tuple containing the schemes names.)rsortedr`r%r%r%r&r Es r cCtS)z*Return a tuple containing the paths names.) _SCHEME_KEYSr%r%r%r&r Jsr 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. )rer`)rbrcexpandr%r%r&r Os r cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r3rbrcrr%r%r&r[srcGstduriattd<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<td}|rd|td<ndtd<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. Nrf exec_prefix py_versionpy_version_shortpy_version_nodotinstalled_baser7installed_platbaseplatbase projectbase platlibdirrrxr-py_version_nodot_platrr_rSOuserbase MULTIARCH/multiarchsubdirsrcdirr+r)! _CONFIG_VARSrI _EXEC_PREFIX _PY_VERSIONrr _BASE_PREFIX_BASE_EXEC_PREFIXrLr1rrrRwinverrr r3rrr0_HAS_USER_BASEr8rrr!rrr#r=r2 _osx_supportcustomize_config_varsappend)r$rrrr7rvalsr3r%r%r&rcsh               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_SUFFIXry)warningswarnDeprecationWarningrr0)r3r r%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'. ramd64z win-amd64z(arm)z win-arm32z(arm64)z win-arm64r_uname_PYTHON_HOST_PLATFORMrrx rrNlinuxsunosr5solarisrr-ry32bit64bit)ilaix) aix_platformcygwinz[\d.]+r+)r r3r1versionlowerr2rmr/rrrmaxsize _aix_supportrrrrrrget_platform_osxr) osnamehostreleasermachinebitnessrrrel_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.)rrrrspanr0r)rSrcrrbegrr%r%r&expand_makefile_varss *r*cCsNtt|D]\}\}}|dkrt|dtd|d|dqdS)Nrz:  z = "") enumeraterrXprint)titlerindexr\r]r%r%r& _print_dict7s r1cCsrdtjvr tdStdtdtdtdtdtdttdtttdt dS) z*Display all information sysconfig detains.z--generate-posix-varsNz Platform: "r,zPython version: "zCurrent installation scheme: "Paths Variables) r1argvrr.r r rsr1r rr%r%r%r&_main>s  r5__main__)F)NTr)L__doc__r r1os.pathrr__all__rr`r8rrrsplitrr5rrr!rarfrIrlrrrbase_exec_prefixrr _USER_BASErrrr=rrrLgetcwdr3rendswithr#r/rDrrKrJrNrrbrVr^rerprrrsrrrrrrrrr r r rrrr r r*r1r5__name__r%r%r%r&s(    >                 ? "  Y Q