a 6fc @sdZddlZddlZddlmZmZgdZdhZdddd d d d d dddddddd d ddddddddd dddddddddddddd d!ddd"d"d#d#d$d!ddd%Zd&Z e ed'sej ej ksd(ej vrd)ZdZejdZd*ejdd+Zd,ejdd+Zejej Zejej ZejejZejejZdadZd-d.Z ej!rlej"e ej!Z#n e e$Z#ej%d/kre#&'d0re ej(e#eeZ#d1ej vre ej d1Z#d2d3Z)e*ed4dZ+ej%d/krd5d6Z,e,e#Z#e,e+Z+dnd7d8Z-e-d9Z.e.r6d:D]Z/d;ee/d<<d=ee/d><qd?d@Z0dAdBZ1dCdDZ2dEdFZ3dGdHZ4dodIdJZ5dKdLZ6dMdNZ7dOdPZ8dQdRZ9dSdTZ:dpdUdVZ;dWdXZe3dd9fd]d^Z?e3dd9fd_d`Z@dadbZAdcddZBdedfZCdgdhZDdidjZEdkdlZFeGdmkreFdS)qz-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}/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})rrrrrrrz0{userbase}/{platlibdir}/python{py_version_short}z5{userbase}/lib/python{py_version_short}/site-packagesz>{userbase}/{platlibdir}/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_homentnt_user posix_userosx_framework_userF real_prefixRPM_BUILD_ROOTz/local%d.%dz%d%dcCs&z t|WSty |YS0dSN)rOSError)pathr%!/usr/lib64/python3.9/sysconfig.py_safe_realpathxs  r'r)z\pcbuild\win32z\pcbuild\amd64_PYTHON_PROJECT_BASEcCs,dD]"}tjtj|d|rdSqdS)N)Setupz Setup.localModulesTF)osr$isfilejoin)dfnr%r%r&_is_python_source_dirsr0_homecCs0|r,tj|tjtjtdr,tS|S)NPCbuild)r+r$normcase startswithr-_PREFIX)r.r%r%r& _fix_pcbuilds r6cCs|rtrttSttSr") _sys_homer0 _PROJECT_BASE) check_homer%r%r&is_python_buildsr:T)rrz{srcdir}/Includerz{projectbase}/.rc Csvz|jfi|WStypz|jfitjWYStyj}ztd|dWYd}~n d}~00Yn0dS)Nz{%s})formatKeyErrorr+environAttributeError)s local_varsvarr%r%r& _subst_varss rBcCs0|}|D]\}}||vr"q|||<qdSr")keysitems) target_dict other_dict target_keyskeyvaluer%r%r& _extend_dicts rJcCsbi}|duri}t|tt|D]4\}}tjdvrFtj|}tjt ||||<q(|S)N)posixr) rJr_INSTALL_SCHEMESrDr+namer$ expandusernormpathrB)schemevarsresrHrIr%r%r& _expand_varss   rScCstjdkrdStjS)NrKr)r+rMr%r%r%r&_get_default_schemes rTcCsztjdd}|r|Sdd}tjdkrBtjdp6d}||dStjdkrptjrp|dd tjd tjdd S|dd S) NPYTHONUSERBASEcWstjtjj|Sr")r+r$rNr-)argsr%r%r&joinusersz_getuserbase..joinuserrAPPDATA~PythondarwinLibraryr r!z.local)r+r=getrMsysplatform _framework version_info)env_baserWbaser%r%r& _getuserbases   rdc Csrddl}|d}|d}|d}|dur2i}i}i}t|dd}|} Wdn1sd0Y| D]} | dsr| d krqr|| } | rr| d d \} } | } | d d }d |vr| || <qrz| t vrt t | } Wn$t y| d d || <Yqr0| || <qrt | }d}t|dkr8t|D]}||}||}||}|r|r||kr|n|} n|r|n|} | dur| d } d}| |vrt|| }n| |vrd}nx| tjvrtj| }n`| |vrD|dr|dd|vrd }n$d| |vr2d}nt|d| }n d || <}|r0|| d}|d| ||}d |vr|||<nz|t vrt t |}Wn t y|||<Yn 0|||<|||dr0|dd|vr0|dd}||vr0|||<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#r!z$$$)CFLAGSLDFLAGSCPPFLAGSTFPY_)recompileopen readlinesr4stripmatchgroupreplace _ALWAYS_STR ValueErrorintlistrClentuplesearchstartstrr+r=endremoverD isinstanceupdate)filenamerQrp _variable_rx _findvar1_rx _findvar2_rxdonenotdoneflineslinemnvtmpv variablesrenamed_variablesrMrIm1m2founditemafterkr%r%r&_parse_makefiles    &                             rcCsdtrtjtptdSttdr0dttj f}nd}ttj drP|dtj j 7}tjt d|dS)z Return the path of the Makefile.Makefileabiflagsz config-%s%sconfig _multiarchz-%sr) _PYTHON_BUILDr+r$r-r7r8hasattrr^_PY_VERSION_SHORTrimplementationrr)config_dir_namer%r%r&rfs  rc Cs(tjddjtjtjttjdddS)N_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}rrh)abir_ multiarch) r+r=r]r;r^rr_getattrrr%r%r%r&_get_sysconfigdata_namess rc Csddl}i}t}zt||WnLtyl}z4d|}t|drP|d|j}t|WYd}~n d}~00t}z6t|}t||Wdn1s0YWnLty}z4d|}t|dr|d|j}t|WYd}~n d}~00t r |d|d<t }dt j vr>ddl }||} || _| t j|<d ttf} tt d r`| d 7} tj| d d tj| |d} t| ddd2}|d|d|j||dWdn1s0Ytdddd}|| Wdn1s0YdS)z;Generate the Python module containing build-time variables.rNz.invalid Python installation: unable to open %sstrerrorz (%s)LDSHARED BLDSHAREDr[zbuild/lib.%s-%sgettotalrefcountz-pydebugT)exist_okz.pywutf8)encodingzB# system configuration generated and used by the sysconfig module zbuild_time_vars = )streamzpybuilddir.txt)pprintrrr#rrrrrrrrr^r_types ModuleTypebuild_time_varsmodulesr rr+makedirsr$r-write) rrQmakefileemsgconfig_hrrMrmodule pybuilddirdestfiler%r%r&_generate_posix_vars|sL  ,        .rcCs0t}t|ttdgd}|j}||dS)z7Initialize the module as appropriate for POSIX systems.rrN)r __import__globalslocalsrr)rQrM_temprr%r%r& _init_posixsrcCsfddl}td|d<td|d<td|d<|d|d <d |d <t|d <tjttj |d <dS)z+Initialize the module as appropriate for NTrNrLIBDESTr BINLIBDESTr INCLUDEPY EXT_SUFFIXz.exeEXEVERSIONBINDIR) _imprextension_suffixes_PY_VERSION_SHORT_NO_DOTr+r$dirnamer'r^ executable)rQrr%r%r&_init_non_posixs   rc Cs|dur i}ddl}|d}|d}|}|s6q||}|r|dd\}}z|tvrbtt|}Wnty~Yn0|||<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_]+) [*]/ rir!)rprqreadlinerurvrxryrz) fprQrp define_rxundef_rxrrrrr%r%r&rs,       rcCsBtr,tjdkr"tjtptd}q4tp(t}ntd}tj|dS)zReturn the path of pyconfig.h.rPCrz pyconfig-64.h)rr+rMr$r-r7r8r)inc_dirr%r%r&rs   rcCs tttS)z,Return a tuple containing the schemes names.)r}sortedrLr%r%r%r&r sr cCstS)z*Return a tuple containing the paths names.) _SCHEME_KEYSr%r%r%r&r sr cCs|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)rSrL)rPrQexpandr%r%r&r s r cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )rMrPrQrr%r%r&rsrcGstdurViattd<ttd<ttd<ttd<ttd<ttd<ttd<ttd <ttd <ttd <t j td <zt j td <Wnt ydtd <Yn0t jdkrttdtd<t jdkrtttd}|dur|td<ttd<tdt}t jdkr,trt jt}t j||}nt jt}t|td<t jdkrVddl}|t|rg}|D]}|t|qd|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_prefix py_versionpy_version_shortpy_version_nodotinstalled_basercinstalled_platbaseplatbase projectbase platlibdirrrhrTZPATHrKrSOuserbasesrcdirr[r) _CONFIG_VARSr5 _EXEC_PREFIX _PY_VERSIONrr _BASE_PREFIX_BASE_EXEC_PREFIXr8r^rrr>r+rMrrr]rdrr$rrr-r'r_ _osx_supportcustomize_config_varsappend)rVrrrcrvalsrMr%r%r&r sT            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_SUFFIXr!)warningswarnDeprecationWarningrr])rMrr%r%r&rosrc CstjdkrFdtjvrdSdtjvr.dSdtjvr@dStjStjdksZttd s`tjSd tjvrttjd St\}}}}}| d d }| d d}| d d}|dddkrd||fS|dddkr,|ddkrd}dt |dd|ddf}ddd}|d|tj 7}n|dddkrPdd l m }|S|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'. ramd64z win-amd64z(arm)z win-arm32z(arm64)z win-arm64rKuname_PYTHON_HOST_PLATFORM/rh _-Nlinuxz%s-%ssunosr5solarisz%d.%sror!32bit64bit)ilz.%saix) aix_platformcygwinz[\d.]+r[z%s-%s-%s)r+rMr^versionlowerr_rr=rrwrzmaxsize _aix_supportrrprqrurvrget_platform_osxr) osnamehostreleasermachinebitnessrrprel_rerrr%r%r&r {sR             r cCstSr")rr%r%r%r&r sr cCsFtt|D]0\}\}}|dkr0td|td||fqdS)Nrz%s: z %s = "%s") enumeraterrDprint)titlerindexrHrIr%r%r& _print_dicts rcCsfdtjvrtdStdttdttdtttdtttdt dS)z*Display all information sysconfig detains.z--generate-posix-varsNzPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"Paths Variables) r^argvrrr r rTrr rr%r%r%r&_mains  r__main__)F)N)N)H__doc__r+r^os.pathrr__all__rxrL_PIP_USE_SYSCONFIGrr base_prefixr=_prefix_additionrrsplitrrarrr$rOr5rrrbase_exec_prefixrr _USER_BASEr'rrr8getcwdrMr endswithr-r0rr7r6r:rrPrBrJrSrTrdrrrrrrrrr r r rrrr r rr__name__r%r%r%r&s     A                ? "  O Q