3 Bu_h@sdZddlZddlZddlZddlZddlmZmZy ddlZWne k r\ddl ZYnXdddddd d d d d dg Z ddZ ej rejje ej Zn e ejZejdkrdedHdjkre ejjeeZejdkodedIdjkr e ejjeeeZejdkr@dedJdjkr@e ejjeeeZddZeZdaddZejZejdZddZd ejdd!Zd"ejdd#Z d$ejdd#Z!ejj"ej#Z$ejj"ej%Z&da'dZ(d%d&Z)d'd(Z*d)d*Z+d+d,Z,d-d.Z-d/d0Z.dKd1d2Z/d3dZ0d4d5Z1d6d7Z2dLd8dZ3d9dZ4d:d Z5d;d Z6e-dddZ8d?dZ9d@dZ:dAd Z;dBd Ze?dGkre>dS)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_hc Cs"yt|Stk r|SXdS)N)rOSError)pathr/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-1.el7.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/distlib/_backport/sysconfig.py_safe_realpath"srntZpcbuildz\pc\v z\pcbuild\amd64cCs.x(dD] }tjjtjjtd|rdSqWdS)N Setup.dist Setup.localModulesTF)rr)osrisfilejoin _PROJECT_BASE)fnrrris_python_build:s r Fc Cstsddlm}tjddd}||}|jd}|s>td|j}tj |WdQRXt rx(dD] }tj |d d tj |d d qfWdadS)N)finder.rz sysconfig.cfgzsysconfig.cfg exists posix_prefix posix_homeincludez{srcdir}/Include platincludez{projectbase}/.T)r%r&) _cfg_read resourcesr"__name__rsplitfindAssertionError as_stream_SCHEMESreadfp _PYTHON_BUILDset)r"Zbackport_packageZ_finderZ_cfgfilesschemerrr_ensure_cfg_readDs     r6z \{([^{]*?)\}cst|jdr|jd}nt}|j}xD|D]<}|dkr>q0x,|D]$\}}|j||rZqD|j|||qDWq0W|jdxX|jD]L}t|j|fdd}x,|j|D]\}}|j||t j ||qWqWdS)Nglobalscs$|jd}|kr|S|jdS)Nr$r)group)matchobjname) variablesrr _replaceros z"_expand_globals.._replacer) r6 has_sectionitemstuplesections has_optionr3remove_sectiondict _VAR_REPLsub)configr7r@sectionoptionvaluer<r)r;r_expand_globalsYs$      rJz%s.%s.%sz%s.%sr!z%s%scsfdd}tj||S)zIn the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`. If there is no corresponding value, leave the token unchanged. cs8|jd}|kr|S|tjkr.tj|S|jdS)Nr$r)r8renviron)r9r:) local_varsrrr<s    z_subst_vars.._replacer)rDrE)rrMr<r)rMr _subst_varss rNcCs4|j}x&|jD]\}}||kr$q|||<qWdS)N)keysr>) target_dict other_dict target_keyskeyrIrrr _extend_dicts rTcCsdi}|dkri}t|txBtj|D]4\}}tjdkrFtjj|}tjjt ||||<q(W|S)Nposixr)rUr) rTrr0r>rr:r expandusernormpathrN)r5varsresrSrIrrr _expand_varss   rZcsfdd}tj||S)Ncs$|jd}|kr|S|jdS)Nr$r)r8)r9r:)rXrrr<s zformat_value.._replacer)rDrE)rIrXr<r)rXr format_values r[cCstjdkrdStjS)NrUr%)rr:rrrr_get_default_schemes r\cCstjjdd}dd}tjdkrBtjjdp.d}|r8|S||dStjdkr|td }|r||r`|S|dd |d tjdd S|r|S|dd SdS)NPYTHONUSERBASEcWstjjtjj|S)N)rrrVr)argsrrrjoinusersz_getuserbase..joinuserrAPPDATA~PythondarwinPYTHONFRAMEWORKLibraryz%d.%dr!z.local)rrLgetr:sysplatformr version_info)env_baser_base frameworkrrr _getuserbases"    rmcCs"tjd}tjd}tjd}|dkr*i}i}i}tj|ddd}|j}WdQRXx|D]} | jds\| jd krxq\|j| } | r\| jd d \} } | j} | j d d } d | kr| || <q\y t | } Wn$t k r| j d d || <Yq\X| || <q\Wt |j }d}xt|dkrxt|D]}||}|j|pJ|j|} | dk r| jd } d}| |kr|t|| }n| |krd}nx| tjkrtj| }n`| |kr|jdr|dd|krd }n$d| |krd}nt|d| }n d || <}|r|| jd}|d| j||}d |krF|||<n~y t |}Wn"t k rt|j||<Yn X|||<|j||jdr|dd|kr|dd}||kr|||<n|||<|j|q(WqWx.|jD]"\}} t| tr| j||<qW|j||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. 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_]*)}Nzutf-8surrogateescape)encodingerrors#r$r!z$$$CFLAGSLDFLAGSCPPFLAGSrTFPY_rK)rtrurv)recompilecodecsopen readlines startswithstripmatchr8replaceint ValueErrorlistrOlenr?searchstrrrLendstartremover> isinstanceupdate)filenamerX _variable_rx _findvar1_rx _findvar2_rxdonenotdoneflineslinemnvtmpvr;renamed_variablesr:rIfounditemafterkrrr_parse_makefiles                             rcCsDtrtjjtdSttdr,dttjf}nd}tjjt d|dS)z Return the path of the Makefile.Makefileabiflagsz config-%s%srFstdlib) r2rrrrhasattrrg_PY_VERSION_SHORTrr)config_dir_namerrrrKs  cCst}yt||WnJtk r^}z.d|}t|drF|d|j}t|WYdd}~XnXt}y"t|}t||WdQRXWnJtk r}z.d|}t|dr|d|j}t|WYdd}~XnXtr|d|d<dS)z7Initialize the module as appropriate for POSIX systems.z.invalid Python installation: unable to open %sstrerrorz (%s)N BLDSHAREDLDSHARED) rrIOErrorrrrr{rr2)rXmakefileemsgconfig_hrrrr _init_posixVs&   rcCsVtd|d<td|d<td|d<d|d<d |d <t|d <tjjttj|d <d S)z+Initialize the module as appropriate for NTrLIBDEST platstdlib BINLIBDESTr' INCLUDEPYz.pydSOz.exeEXEVERSIONBINDIRN)r_PY_VERSION_SHORT_NO_DOTrrdirnamerrg executable)rXrrr_init_non_posixrs   rc Cs|dkr i}tjd}tjd}xx|j}|s0P|j|}|rz|jdd\}}y t|}Wntk rnYnX|||<q"|j|}|r"d||jd<q"W|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. Nz"#define ([A-Z][A-Za-z0-9_]+) (.*) z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/ r$r!r)rxryreadlinerr8rr)fprX define_rxundef_rxrrrrrrrrs(      cCs:tr$tjdkrtjjtd}q,t}ntd}tjj|dS)zReturn the path of pyconfig.h.rPCr(z pyconfig.h)r2rr:rrrr)inc_dirrrrrs  cCstttjS)z,Return a tuple containing the schemes names.)r?sortedr0r@rrrrr scCs tjdS)z*Return a tuple containing the paths names.r%)r0optionsrrrrr sTcCs&t|rt||Sttj|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)r6rZrCr0r>)r5rXexpandrrrr s cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )r:r5rXrrrrrscGstdkriattd<ttd<ttd<ttd<tdtdtd<ttd <ttd <ttd <ytjtd <Wntk rd td <YnXt j d#krt tt j dkrt ttj dkrttd<dtkrttd<nttdtd<tot j dkr\t}y t j}Wntk rd}YnXt jjtd r\||kr\t jj|td}t jj|td<tjdkrt jd}t|jdd}|dkrx:d$D]2}t|}tjdd|}tjdd|}|t|<qWndt jkrt jd}x8d%D]0}t|}tjdd|}|d|}|t|<qWtjdd } tjd | } | dk r| j d!} t jj!| sx,d&D]$}t|}tjd"d|}|t|<q^W|rg} x|D]} | j"tj| qW| StSdS)'ayWith 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 and Mac OS 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_shortrr!py_version_nodotrkplatbase projectbaserrrros2rUz2.6userbasesrcdirrcr#rru BASECFLAGSrt PY_CFLAGSrz -arch\s+\w+\s z-isysroot [^ ]*Z ARCHFLAGSz-isysroot\s+(\S+)r$z-isysroot\s+\S+(\s|$))rr)rurrtrr)rurrtrr)rurrtrr)# _CONFIG_VARS_PREFIX _EXEC_PREFIX _PY_VERSIONrrrgrAttributeErrorrr:rrversionrmrr2getcwdrrisabsrrWrhunamersplitrxrErLrfrr8existsappend)r^rkcwdrZkernel_version major_versionrSflagsarchrtrZsdkvalsr:rrrrs                    cCs tj|S)zReturn the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) )rrf)r:rrrrPscCs`tjdkrnd}tjj|}|d:kr(tjStjjd|}tj|t||j}|dkr\dS|dkrhdStjStjd ksttd  rtjStj \}}}}}|jj d d }|j d d}|j d d}|dddkrd||fS|dddkr(|ddkrRd}dt |dd|ddf}n*|dddkrFd||fS|dddkrfd|||fS|ddd krd }t j d!} | j|} | rR| j}n|ddd"krRt} | jd#} | } y td$}Wntk rYnJXzt jd%|j} Wd|jX| dk r4d&j| jdjd&dd} | s>| } | rR| }d'}| d&d(krd)tjd*d jkrd+}tjd*}t jd,|}ttt|}t|dkr|d}n^|d;krd+}nN|d|d=krd1}n.|d>krd3}n|d?krd4}ntd5|fn<|d-kr2tjd@krRd/}n |dAkrRtjdBkrNd2}nd.}d9|||fS)CaReturn 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; eg. for IRIX the architecture isn't particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u irix-5.3 irix64-6.2 Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win-ia64 (64bit Windows on Itanium) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. rz bit (r$)amd64z win-amd64itaniumzwin-ia64rUr/rrr_-Nlinuxz%s-%ssunosr5solarisz%d.%srKr!irixaixz%s-%s.%scygwinz[\d.]+rcMACOSX_DEPLOYMENT_TARGETz0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)r#macosxz10.4.z-archrtfatz -arch\s+(\S+)i386ppcx86_64intelZfat3ppc64fat64 universalz%Don't know machine value for archs=%r PowerPCPower_Macintoshz%s-%s-%s)rr)rr)rrr)rr)rrrrl)rrl) rr:rgrr-rhrlowerrrrrrxryrr8rrfr{rrreadcloserrr~findallr?rr3rmaxsize)rijlookosnamehostreleasermachinerel_rerZcfgvarsZmacverZ macreleasercflagsZarchsrrrr Ys     $                    cCstS)N)rrrrrr scCsJxDtt|jD]0\}\}}|dkr2td|td||fqWdS)Nrz%s: z %s = "%s") enumeraterr>print)titledataindexrSrIrrr _print_dicts rcCsRtdttdttdtttdtttdtdS)z*Display all information sysconfig detains.zPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"Paths VariablesN)rr r r\rr rrrrr_mains r__main__iii)N)N)@__doc__rzrrxrgos.pathrr configparser ImportError ConfigParser__all__rrrrrrr:rrr r2r)r6RawConfigParserr0ryrDrJrirrrrWrrrrr _USER_BASErNrTrZr[r\rmrrrrrrr r r rrrr r rrr+rrrrs   " !   v     #