B ŒÛ™\ÓTã@s¨dZddlZddlZddlZddlZddlZddlmZej  ej ¡Z ej  ej ¡Z ej  ej¡Zej  ej¡ZdejkrŽej ejd¡Znej ej ej¡¡Zdd„ZeeddƒZejd krÚd d „ZeeƒZeeƒZd d „ZeƒZdZyesøejZWne k rYnXdd„Z!d,dd„Z"d-dd„Z#dd„Z$dd„Z%dd„Z&d.dd„Z'e (d¡Z)e (d¡Z*e (d¡Z+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] }tj tj |d|¡¡rdSqWdS)N)z Setup.distz Setup.localZModulesTF)ÚosÚpathÚisfileÚjoin)ÚdÚfn©r ú)/usr/lib/python3.7/distutils/sysconfig.pyÚ_is_python_source_dir(s r Z_homeÚntcCs0|r,tj |¡ tj tj td¡¡¡r,tS|S)NZPCbuild)rrÚnormcaseÚ startswithrÚPREFIX)rr r r Ú _fix_pcbuild1srcCstr ttƒSttƒS)N)Ú _sys_homer Ú project_baser r r r Ú _python_build9srÚcCsdtjdd…S)z–Return 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_versionMsrcCsÖ|dkr|rtpt}tjdkr„trL|r.tp,tStj t dƒd¡}tj  |¡Sdt ƒt }tst|rtddl }| d¡Stj |d|¡Stjd krÄtr¶tj |d¡tjjtj |d ¡Stj |d¡Std tjƒ‚dS) a¤Return 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'. NÚposixÚsrcdirZIncludeÚpythonrZ platincludeZincluder ÚPCzFI don't know where Python installs its C header files on platform '%s')ÚBASE_EXEC_PREFIXÚ BASE_PREFIXrÚnameÚ python_buildrrrrÚget_config_varÚnormpathrÚ build_flagsÚ sysconfigZget_pathÚpathsepr)Ú plat_specificÚprefixZincdirZ python_dirr%r r r Úget_python_incUs*      r)cCsô| ptj |¡dk}|dkr<|r0|r*tp,t}n |r8tp:t}tjdkr´tj |ddt ƒ¡}|rd|S|r¤dtj kr¤dtj kr¤dt j kr¤t j t jkr¤tj |dd d ¡Stj |d ¡Sntj d} dtj kr^| dtj d}n | d| }|d|}|j|||d|||||d||_dS)zÄDo any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. ZunixÚdarwinZCUSTOMIZED_OSX_COMPILERrNÚTrueZCCZCXXZOPTÚCFLAGSZCCSHAREDZLDSHAREDZ SHLIB_SUFFIXZARZARFLAGSZCONFIGURE_CPPFLAGSZCONFIGURE_CFLAGSZCONFIGURE_LDFLAGSz *-4.[0-8]z-fstack-protector-strongz-fstack-protectorZCPPz -EÚLDFLAGSú ÚCPPFLAGS)Z preprocessorÚcompilerZ compiler_soZ compiler_cxxZ linker_soZ linker_exeÚarchiver)Z compiler_typerÚplatformr"Ú _osx_supportÚcustomize_compilerÚ _config_varsÚget_config_varsrr+rÚlenÚfnmatchÚfilterÚreplaceZset_executablesZshared_lib_extension)r6r9ZccZcxxZoptZcflagsZccsharedZldsharedZ shlib_suffixZarZar_flagsZconfigure_cppflagsZconfigure_cflagsZconfigure_ldflagsZnewccZcppr7Zcc_cmdr r r r:®sx     "                             r:cCsDtr,tjdkr"tj tptd¡}q6tp(t}n tdd}tj |d¡S)z2Return full pathname of installed pyconfig.h file.r rr)r'z pyconfig.h)r!rr rrrrr))Zinc_dirr r r Úget_config_h_filenames    rAcCs\trtj tptd¡Stddd}d tƒt ¡}t t j dƒrL|dt j j 7}tj ||d¡S)zAReturn full pathname of installed Makefile from the Python build.ZMakefilerr)r'r.z config-{}{}Ú _multiarchz-%s)r!rrrrrr/Úformatrr$ÚhasattrrÚimplementationrB)Zlib_dirZ config_filer r r Úget_makefile_filenames  rFcCsž|dkr i}t d¡}t d¡}xx| ¡}|s0P| |¡}|rz| dd¡\}}y t|ƒ}Wntk rnYnX|||<q"| |¡}|r"d|| d¡<q"W|S)zÌParse 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)ÚreÚcompileÚreadlineÚmatchÚgroupÚintÚ ValueError)ÚfpÚgZ define_rxZundef_rxÚlineÚmÚnÚvr r r Úparse_config_hs(      rTz"([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 CsÌddlm}||ddddd}|dkr*i}i}i}x”| ¡}|dkrFPt |¡}|r4| dd¡\}} |  ¡} |  dd ¡} d | krŠ| ||<q4y t| ƒ} Wn$t k rº|  dd ¡||<Yq4X| ||<q4Wd } x¶|r„x¨t |ƒD]š} || } t   | ¡pt   | ¡}|rx| d¡}d }||kr2t||ƒ}nˆ||krBd }nx|tjkrZtj|}n`|| kr®|  d¡rˆ| dd…| krˆd }n$d||krœd }nt|d|ƒ}n d ||<}|r~| | ¡d…}| d| ¡…||} d |krü| || <nzy t| ƒ} Wn"t k r*|  ¡|| <Yn X| || <|| =|  d¡r~| dd…| kr~| dd…} | |kr~| || <qâ|| =qâWqÐW| ¡x.| ¡D]"\}} t| tƒr˜|  ¡||<q˜W| |¡|S)zÌParse 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)ÚTextFilerÚsurrogateescape)Zstrip_commentsZ skip_blanksZ join_linesÚerrorsNrz$$rú$)r2r3r5TFZPY_é)Zdistutils.text_filerUrIÚ _variable_rxrJrKÚstripr@rLrMÚlistÚ _findvar1_rxÚsearchÚ _findvar2_rxÚstrrr+rÚendÚstartÚcloseÚitemsÚ isinstanceÚupdate)r rOrUrNZdoneZnotdonerPrQrRrSZtmpvZrenamed_variablesr ÚvalueÚfoundÚitemZafterÚkr r r Úparse_makefileAs„                       rkcCsZxTt |¡pt |¡}|rP| ¡\}}|d|…| | d¡¡||d…}qPqW|S)a¨Expand 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_ÚspanÚgetrK)ÚsÚvarsrQZbegrar r r Úexpand_makefile_vars«s *rpc CsVtj ddjtjtjttjddƒd¡}t |t ƒt ƒdgdƒ}|j }ia t  |¡dS) z7Initialize the module as appropriate for POSIX systems.Z_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}rBr)Zabir8Z multiarchÚbuild_time_varsrN)rr+rmrCrÚabiflagsr8ÚgetattrrEÚ __import__ÚglobalsÚlocalsrqr;rf)r Z_temprqr r r Ú _init_posixÆsrwcCs~i}tddd|d<tddd|d<tdd|d<t ¡d|d<d |d <tƒ d d ¡|d <tj tj  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)Ú_impÚextension_suffixesrr@rrÚdirnameÚabspathrÚ executabler;)rOr r r Ú_init_ntÖsrcGs`tdkr*tƒ dtj¡}|r(|ƒniattd<ttd<t d¡}|dk rV|td<t dt¡}tjdkrœtrŽtj   t ƒ¡}tj   ||¡}ntj   t ƒ¡}tj   tj  |¡¡td<tr tjdkr t}tj  td¡s |t ¡kr tj   |td¡}tj  |¡td<tjd kr*d dl}| t¡|rXg}x|D]}| t |¡¡q:W|StSdS) aßWith 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_prefixrxÚSOrrr0r)r;rurmrr rr*rr!rr|rFrr}r#ÚisabsÚgetcwdrr8r9Zcustomize_config_varsÚappend)ÚargsÚfuncrrÚbaser9Zvalsr r r r r<és@       r<cCs*|dkrddl}| dtd¡tƒ |¡S)z“Return 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)ÚwarningsÚwarnÚDeprecationWarningr<rm)r rˆr r r r"3sr")rN)rrN)N)N)3Ú__doc__rzrrGrr>rWrrr#r(rr€r*r-rÚbase_exec_prefixrr+r}rr|r~r rsrr rrr!r$rrÚAttributeErrorrr)r/r:rArFrTrHrZr]r_rkrpr;rwrr<r"r r r r Ú sX      + .X      jJ