B šDŔ@sdZddlZddlZddlZddlZddlmZejej Z ejej Z ejej ZejejZdejkrejejdZn&ejrejejejZneZddZeeddZejd krd d ZeeZeeZd d ZeZdZyesejZWne k rYnXddZ!d,ddZ"d-ddZ#ddZ$ddZ%ddZ&d.ddZ'e(dZ)e(dZ*e(dZ+d/d d!Z,d"d#Z-da.d$d%Z/d&d'Z0d(d)Z1d*d+Z2dS)0aProvide access to Python's configuration information. The specific configuration variables available depend heavily on the platform and configuration. The values may be retrieved using get_config_var(name), and the list of variables is available via get_config_vars().keys(). Additional convenience functions are also available. Written by: Fred L. Drake, Jr. Email: N)DistutilsPlatformErrorZ_PYTHON_PROJECT_BASEcCs.x(dD] }tjtj|d|rdSqWdS)N)z Setup.distz Setup.localZModulesTF)ospathisfilejoin)dfnr 8/opt/alt/python37/lib64/python3.7/distutils/sysconfig.py_is_python_source_dir,s r _homentcCs0|r,tj|tjtjtdr,tS|S)NZPCbuild)rrnormcase startswithrPREFIX)rr r r _fix_pcbuild5srcCstr ttSttS)N) _sys_homer project_baser r r r _python_build=srcCsdtjddS)zReturn a string containing the major and minor Python version, leaving off the patchlevel. Sample return values could be '1.5' or '2.2'. z%d.%dN)sys version_infor r r r get_python_versionQsrcCs|dkr|rtpt}tjdkrjtrL|r.tp,tStjt dd}tj |Sdt t }tj|d|Stjdkrtrtj|dtjj tj|dStj|dStd tjdS) aReturn the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pyconfig.h). If 'prefix' is supplied, use it instead of sys.base_prefix or sys.base_exec_prefix -- i.e., ignore 'plat_specific'. NposixsrcdirZIncludepythonZincluderPCzFI don't know where Python installs its C header files on platform '%s')BASE_EXEC_PREFIX BASE_PREFIXrname python_buildrrrrget_config_varnormpathr build_flagspathsepr) plat_specificprefixZincdirZ python_dirr r r get_python_incYs$     r)cCs|dkr&|r|rtpt}n |r"tp$t}tjdkrp|s8|r>d}nd}tj||dt}|r`|Stj|dSncCs\trtjtptdStddd}dtt }t t j drL|dt j j 7}tj||dS)zAReturn full pathname of installed Makefile from the Python build.ZMakefilerr)r'r-z config-{}{} _multiarchz-%s)r"rrrrrr.formatrr%hasattrrimplementationr?)Zlib_dirZ config_filer r r get_makefile_filenames  rCcCs|dkr i}td}td}xx|}|s0P||}|rz|dd\}}y t|}Wntk rnYnX|||<q"||}|r"d||d<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_]+) [*]/ rrr)recompilereadlinematchgroupint ValueError)fpgZ define_rxZundef_rxlinemnvr r r parse_config_h s(      rQz"([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_]*)}c Csddlm}||ddddd}|dkr*i}i}i}x|}|dkrFPt|}|r4|dd\}} | } | dd } d | kr| ||<q4y t| } Wn$t k r| dd ||<Yq4X| ||<q4Wd } x|rxt |D]} || } t | pt | }|r|d}d }||kr2t||}n||krBd }nx|tjkrZtj|}n`|| kr| dr| dd| krd }n$d||krd }nt|d|}n d ||<}|r| |d}| d|} || kr| |7} | |7} d |kr| || <nzy t| } Wn"t k r@| || <Yn X| || <|| =| dr| dd| kr| dd} | |kr| || <q|| =qWqW|x.|D]"\}} t| tr| ||<qW|||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. r)TextFilersurrogateescape)Zstrip_commentsZ skip_blanksZ join_lineserrorsNrz$$r$)r1r2r4TFZPY_)Zdistutils.text_filerRrF _variable_rxrGrHstripreplacerIrJlist _findvar1_rxsearch _findvar2_rxstrrr<rendstartcloseitems isinstanceupdate)r rLrRrKZdoneZnotdonerMrNrOrPZtmpvZrenamed_variablesr!valuefounditemZafterkr r r parse_makefile0s                       ricCsZxTt|pt|}|rP|\}}|d|||d||d}qPqW|S)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'. rrN)r[r\r]spangetrH)svarsrNZbegr_r r r expand_makefile_varss *rnc CsVtjddjtjtjttjddd}t |t t dgd}|j }ia t |dS) z7Initialize the module as appropriate for POSIX systems.Z_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}r?r)Zabir7Z multiarchbuild_time_varsrN)rr<rkr@rabiflagsr7getattrrB __import__globalslocalsror:rd)r!Z_tempror r r _init_posixsrucCs~i}tddd|d<tddd|d<tdd|d<td|d<d |d <td d |d <tjtj t j |d<|a dS)z+Initialize the module as appropriate for NTrr)r'r-ZLIBDESTZ BINLIBDEST)r'Z INCLUDEPY EXT_SUFFIXz.exeZEXE.rZVERSIONZBINDIRN) r.r)_impextension_suffixesrrYrrdirnameabspathr executabler:)rLr r r _init_ntsr}cGs`tdkr*tdtj}|r(|niattd<ttd<td}|dk rV|td<tdt}tjdkrtrtj t }tj ||}ntj t }tj tj |td<tr tjdkr t}tj tds |tkr tj |td}tj |td<tjd kr*d dl}|t|rXg}x|D]}|t|q:W|StSdS) aWith no arguments, return a dictionary of all configuration variables relevant for the current platform. Generally this includes everything needed to build extensions and install both pure modules and extensions. 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. NZ_init_r( exec_prefixrvSOrrr/r)r:rsrkrr!rr,rr"rrzrCrr{r$isabsgetcwdrr7r8Zcustomize_config_varsappend)argsfuncrrbaser8Zvalsr!r r r r;s@       r;cCs*|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)warningswarnDeprecationWarningr;rk)r!rr r r r#%sr#)rN)rrN)N)N)3__doc__rxrrDrrTrrr$r(rr~r, base_prefixr base_exec_prefixrr<r{rr|rzrr rqrr!rrr"r%rpAttributeErrorrr)r.r9r>rCrQrErWr[r]rirnr:rur}r;r#r r r r  sZ      ( +I      mJ