3 _f,a @sdZddlZddlZddlmZmZdddddd d d d d dg Zdddddddddddddddddddddddddddd d d!d!d"d#d$d%d&d&d'd(d)d*d$d%d+d+d,d,d-d*d$d%d.ZdoZej j dZ d6ej dd7Z d8ej dd7ZejjejZejjejZejjejZejjejZdadZd9d:ZejrPejjeejZn eejZej d;krej!j"dpreejj#eeeZd>ej$kreej$d>Zd?d@Z%e&edAdZ'e'rej d;kre'j!j"dqrejjejje'Z'drdCdDZ(e(dEZ)e)r0x&dsD]Z*dHee*d3<dIee*dJ<qWdKdLZ+dMdNZ,dOdPZ-dQdRZ.dSdTZ/dtdUdVZ0dWdZ1dXdYZ2dZd[Z3d\d]Z4d^d_Z5dud`dZ6dadZ7dbd Z8dcd Z9e.ddEfddd Z:e.ddEfdedZ;dfdZdid Z?djdkZ@dldmZAeBdnkreAdS)vz-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_hz/{installed_base}/lib64/python{py_version_short}z){platbase}/lib64/python{py_version_short}z1{base}/lib/python{py_version_short}/site-packagesz7{platbase}/lib64/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})rrrrrrrz){userbase}/lib64/python{py_version_short}z5{userbase}/lib/python{py_version_short}/site-packagesz7{userbase}/lib64/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_userrrrrrrrz%d.%dz%d%dc Cs"yt|Stk r|SXdS)N)rOSError)pathr !/usr/lib64/python3.6/sysconfig.py_safe_realpathcsr"r\pcbuild\win32\pcbuild\amd64Z_PYTHON_PROJECT_BASEcCs.x(dD] }tjjtjj|d|rdSqWdS)N Setup.dist Setup.localModulesTF)r%r&)osrisfilejoin)dfnr r r!_is_python_source_dirxs r-_homeFcCs|rtrttSttS)N) _sys_homer- _PROJECT_BASE) check_homer r r!is_python_buildsr2Trrz{srcdir}/Includez{projectbase}/.rcCsdy |jf|Stk r^y|jftjStk rX}ztd|WYdd}~XnXYnXdS)Nz{%s})formatKeyErrorr(environAttributeError)s local_varsvarr r r! _subst_varss r:cCs4|j}x&|jD]\}}||kr$q|||<qWdS)N)keysitems) target_dict other_dict target_keyskeyvaluer r r! _extend_dicts rBcCsfi}|dkri}t|txDt|jD]4\}}tjdkrHtjj|}tjjt ||||<q*W|S)Nposixr)rCr) rBr_INSTALL_SCHEMESr<r(namer expandusernormpathr:)schemevarsresr@rAr r r! _expand_varss   rKcCstjdkrdStjS)NrCr)r(rEr r r r!_get_default_schemes rLcCstjjdd}dd}tjdkrBtjjdp.d}|r8|S||dStjdkr|td }|r||r`|S|dd |d tjdd S|r|S|dd SdS)NPYTHONUSERBASEcWstjjtjj|S)N)r(rrFr*)argsr r r!joinusersz_getuserbase..joinuserrAPPDATA~PythondarwinPYTHONFRAMEWORKLibraryz%d.%drz.local)r(r5getrEsysplatformr version_info)env_baserObase frameworkr r r! _getuserbases"    r]cCsZddl}|jd}|jd}|jd}|dkr2i}i}i}t|dd}|j} WdQRXx| D]} | jds`| jd kr|q`|j| } | r`| jd d \} } | j} | jd d }d |kr| || <q`y t | } Wn$t k r| jd d || <Yq`X| || <q`Wt |j }d}x t |dkrxt|D]}||}|j|}|j|}|rv|rv|j|jkrp|n|} n|r|n|} | dk r| jd } d}| |krt|| }n| |krd}nx| tjkrtj| }n`| |kr0|jdr |dd|kr d }n$d| |krd}nt|d| }n d || <}|r|| jd}|d| j||}d |kr~|||<n~y t |}Wn"t k r|j||<Yn X|||<|j||jdr|dd|kr|dd}||kr|||<n|||<|j|q,WqWx.|jD]"\}} t| tr&| j||<q&W|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. 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#rz$$$CFLAGSLDFLAGSCPPFLAGSTFPY_)rdrerf)recompileopen readlines startswithstripmatchgroupreplaceint ValueErrorlistr;lentuplesearchstartstrr(r5endremover< isinstanceupdate)filenamerIri _variable_rx _findvar1_rx _findvar2_rxdonenotdoneflineslinemnvtmpv variablesrenamed_variablesrErAm1m2founditemafterkr r r!_parse_makefiles                                 rcCsdtrtjjtptdSttdr0dttj f}nd}ttj drP|dtj j 7}tjjt d|dS)z Return the path of the Makefile.Makefileabiflagsz config-%s%sconfig _multiarchz-%sr) _PYTHON_BUILDr(rr*r/r0hasattrrW_PY_VERSION_SHORTrimplementationrr)config_dir_namer r r!rLs  c Cs(tjjddjtjtjttjdddS)N_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}rra)abirX multiarch) r(r5rVr3rWrrXgetattrrr r r r!_get_sysconfigdata_nameYs rc ,Csddl}i}t}yt||WnJtk rj}z.d|}t|drR|d|j}t|WYdd}~XnXt}y"t|}t||WdQRXWnJtk r}z.d|}t|dr|d|j}t|WYdd}~XnXt r|d|d<t }dt j kr$ddl }|j|} || _| t j|<d ttf} tt d rF| d 7} tj| d d tjj| |d} t| ddd(}|jd|jd|j||dWdQRXtdddd}|j| WdQRXdS)z;Generate the Python module containing build-time variables.rNz.invalid Python installation: unable to open %sstrerrorz (%s)LDSHARED BLDSHAREDrSzbuild/lib.%s-%sgettotalrefcountz-pydebugT)exist_okz.pywutf8)encodingzB# system configuration generated and used by the sysconfig module zbuild_time_vars = )streamzpybuilddir.txtascii)pprintrrrrrrrkrrrrWrXtypes ModuleTypebuild_time_varsmodulesr rr(makedirsrr*write) rrImakefileemsgconfig_hrrErmodule pybuilddirdestfiler r r!_generate_posix_varsbsL          rcCs0t}t|ttdgd}|j}|j|dS)z7Initialize the module as appropriate for POSIX systems.rrN)r __import__globalslocalsrr})rIrE_temprr r r! _init_posixsrcCsVtd|d<td|d<td|d<d|d<d |d <t|d <tjjttj|d <d S)z+Initialize the module as appropriate for NTrLIBDESTr BINLIBDESTr INCLUDEPYz.pyd EXT_SUFFIXz.exeEXEVERSIONBINDIRN)r_PY_VERSION_SHORT_NO_DOTr(rdirnamer"rW executable)rIr r r!_init_non_posixs   rc Cs|dkr i}ddl}|jd}|jd}xx|j}|s8P|j|}|r|jdd\}}y t|}Wntk rvYnX|||<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. Nrz"#define ([A-Z][A-Za-z0-9_]+) (.*) z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/ rbr)rirjreadlinerorprrrs) fprIri define_rxundef_rxrrrrr r r!rs*      cCsBtr,tjdkr"tjjtptd}q4tp(t}ntd}tjj|dS)zReturn the path of pyconfig.h.rPCrz pyconfig-64.h)rr(rErr*r/r0r)inc_dirr r r!rs   cCs tttS)z,Return a tuple containing the schemes names.)rvsortedrDr r r r!r scCstS)z*Return a tuple containing the paths names.) _SCHEME_KEYSr r r r!r scCs|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)rKrD)rHrIexpandr r r!r s cCst||||S)z[Return a path corresponding to the scheme. ``scheme`` is the install scheme name. )r )rErHrIrr r r!rsc Gs|tdkrFiattd<ttd<ttd<ttd<ttd<ttd<ttd<ttd <ttd <ttd <yt j td <Wnt k rd td <YnXt j dkrttt j dkrtttjd}|dk r|td<ttd<tjdt}t j dkrtrt jjt}t jj||}nt jjt}t|td<t jdkrFddl}|jt|rtg}x|D]}|jtj|qVW|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_baser[installed_platbaseplatbase projectbaserrarrCrSOuserbasesrcdirrSr) _CONFIG_VARS_PREFIX _EXEC_PREFIX _PY_VERSIONrr _BASE_PREFIX_BASE_EXEC_PREFIXr0rWrr6r(rErrrVr]rrrrr*r"rX _osx_supportcustomize_config_varsappend)rNrrr[rvalsrEr r r!rsP           cCs*|dkrddl}|jdtdtj|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)warningswarnDeprecationWarningrrV)rErr r r!rPscCstjdkrnd}tjj|}|d)kr(tjStjjd|}tj|t||j}|dkr\dS|dkrhdStjStjd ksttd  rtjSd tj krtj d Stj \}}}}}|jj d d }|j dd}|j d d}|dddkrd||fS|dddkrV|ddkrd}dt |dd|ddf}ddd} |d| tj 7}n|dd d!krtd||fS|ddd"krd#|||fS|dd$d%krd%}ddl} | jd&} | j|} | r| j}n2|dd$d'krddl} | jt|||\}}}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; 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 (rb)amd64z win-amd64itaniumzwin-ia64rCuname_PYTHON_HOST_PLATFORM/ra _-Nlinuxz%s-%ssunosr5solarisz%d.%srhr32bit64bit)ilz.%sirixaixz%s-%s.%scygwinz[\d.]+rSz%s-%s-%s)r(rErWversionfindrXrulowerrr5rrqrrmaxsizerirjrorprget_platform_osxr)rijlookosnamehostreleasermachinebitnessrirel_rerrr r r!r \sZ             cCstS)N)rr r r r!r scCsJxDtt|jD]0\}\}}|dkr2td|td||fqWdS)Nrz%s: z %s = "%s") enumeraterr<print)titlerindexr@rAr r r! _print_dicts rcCsfdtjkrtdStdttdttdtttdtttdt dS)z*Display all information sysconfig detains.z--generate-posix-varsNzPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"Paths Variables) rWargvrrr r rLrr rr r r r!_mains  r__main__)rrrrrrr)r#r$)r#r$)F)rr)N)N)C__doc__r(rWZos.pathrr__all__rDrrsplitrrYrrrrGrr base_prefixrrrbase_exec_prefixrr _USER_BASEr"rrr0getcwdrErendswithr*r5r-rr/r2rrHr:rBrKrLr]rrrrrrrrr r r rrrr r rr__name__r r r r!s           |  ?   M [