3 eV @sdZddlZddlZddlZddlZddlmZdejkZej j ej Z ej j ej Zej j ejZej j ejZdejkrej jejdZn&ejrej jej jejZnejZddZeed dZejd krd d ZeeZeeZd dZeZdZ yes ej!Z Wne"k r$YnXddZ#d1ddZ$ddZ%d2ddZ&ddZ'ddZ(dZ)ddZ*d3dd Z+ej,d!Z-ej,d"Z.ej,d#Z/d4d$d%Z0d&d'Z1da2d(Z3d)d*Z4d+d,Z5d-d.Z6d/d0Z7dS)5aProvide 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__pypy__Z_PYTHON_PROJECT_BASEcCs.x(dD] }tjjtjj|d|rdSqWdS)NSetup Setup.localModulesTF)rr)ospathisfilejoin)dfnr E/tmp/pip-build-vlmub77e/setuptools/setuptools/_distutils/sysconfig.py_is_python_source_dir,s r_homentcCs0|r,tjj|jtjjtjjtdr,tS|S)NZPCbuild)rrnormcase startswithr PREFIX)r r 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 rget_python_versionQsrcCs|dkr|rtpt}tjdkrtr:tjd kr:tjj|dSt rh|rJt pHt Stjjt dd}tjj |Strpdnd }|tt}tjj|d|Stjd krt rtjj|dtjjtjj|d Stjj|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'. NposixincludesrcdirIncludepypypythonrPCzFI don't know where Python installs its C header files on platform '%s')rr )BASE_EXEC_PREFIX BASE_PREFIXrnameIS_PYPYrrrr python_buildrrget_config_varnormpathr build_flagspathsepr) plat_specificprefixincdirimplementation python_dirr r rget_python_incYs*      r5cCs|r|Stjj|dSdS)Nz site-packages)rrr ) standard_lib libpython early_prefixr1r r r _posix_libsr9cCstrBtjdkrB|dkrt}|r4tjj|dtjdStjj|dS|}|dkrl|r`|rZtp\t }n |rht pjt}tj dkr|s~|rt tdd }nd }trd nd }tjj|||t }t||||Stj d kr|rtjj|d Stjj|d dSntdtj dS)aSReturn the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. If 'prefix' is supplied, use it instead of sys.base_prefix or sys.base_exec_prefix -- i.e., ignore 'plat_specific'. rr Nz lib-pythonrz site-packagesrZ platlibdirlibr$r%rLibz?I don't know where Python installs its library on platform '%s')rr )r*rrrrrr versionr'r( EXEC_PREFIXr)getattrrr9r)r0r6r1r8Zlibdirr3r7r r rget_python_libs4      r?c Cs|jdkrtjdkr8tds8ddl}|jtdtd<tddd d d d d d\}}}}}}}} dtj krtj d} d tj kr|j |r| |t |d}| }dtj krtj d}d tj krtj d }dtj krtj d} n|d} dtj kr|dtj d}d tj kr2|dtj d }|dtj d }dtj krt| dtj d} |dtj d}|dtj d}d tj krtj d }dtj kr|dtj d} n |d| } |d|} |j | | | d||||| ddtj kr|j jddr|j tj dd||_dS)zDo 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. unixdarwinCUSTOMIZED_OSX_COMPILERrNTrueCCCXXCFLAGSCCSHAREDLDSHARED SHLIB_SUFFIXARARFLAGSCPPz -ELDFLAGS CPPFLAGS) preprocessorcompiler compiler_so compiler_cxx linker_so linker_exearchiverZRANLIBranlib)rW) compiler_typerplatformr, _osx_supportcustomize_compiler _config_varsget_config_varsrenvironrlenset_executablesZ executablesgetshared_lib_extension)rQrZcccxxcflagsccsharedldshared shlib_suffixarar_flagsnewcccpprVcc_cmdr r rr[s^                      r[cCsDtr,tjdkr"tjjtptd}q6tp(t}n tdd}tjj|dS)z2Return full pathname of installed pyconfig.h file.rr&r)r0z pyconfig.h)r+rr)rr rrr5)inc_dirr r rget_config_h_filenames    roz+config-{python_ver}{build_flags}{multiarch}cCs`trtjjtptdStddd}ttj dr:dtj j nd}t j t t|d}tjj||dS) zAReturn full pathname of installed Makefile from the Python build.Makefilerr)r0r6 _multiarchz-%sr)Z python_verr. multiarch)r+rrr rrr?hasattrrr3rq_makefile_tmplformatrr.)lib_dirrr config_filer r rget_makefile_filenames rxc 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_]+) [*]/ rrr)recompilereadlinematchgroupint ValueError)fpg define_rxundef_rxlinemnvr r rparse_config_h0s(      rz"([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|j}|dkrFPtj|}|r4|jdd\}} | j} | jdd } d | kr| ||<q4y t| } Wn$t k r| jdd ||<Yq4X| ||<q4Wd} x|rxt |D]} || } t j | pt j | }|rx|jd}d}||kr2t||}n||krBd}nx|tjkrZtj|}n`|| kr| jdr| dd| krd }n$d||krd}nt|d|}n d ||<}|r~| |jd}| d|j||} d |kr| || <nzy t| } Wn"t k r*| j|| <Yn X| || <|| =| jdr~| dd| kr~| dd} | |kr~| || <q|| =qWqW|jx.|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. r)TextFilersurrogateescape)strip_comments skip_blanks join_lineserrorsNrz$$r$rFrMrOTFPY_r)rFrMrO)distutils.text_filerr{ _variable_rxr|r}stripreplacer~rlist _findvar1_rxsearch _findvar2_rxstrrr^rendstartcloseitems isinstanceupdate)r rrrdonenotdonerrrrtmpvrenamed_variablesr)valuefounditemafterkr r rparse_makefileSs                       rcCsZxTtj|ptj|}|rP|j\}}|d||j|jd||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)rrrspanrar})svarsrbegrr r rexpand_makefile_varss *rz+_sysconfigdata_{abi}_{platform}_{multiarch}c Cstjjdtjtjtjttj ddd}yt |t t dgd}Wn*t k rlt dt t dgd}YnX|j}iatj|dS) z7Initialize the module as appropriate for POSIX systems._PYTHON_SYSCONFIGDATA_NAMErqr)abirYrrbuild_time_varsrZ_sysconfigdataN)rr^ra_sysconfig_name_tmplrurabiflagsrYr>r3 __import__globalslocals ImportErrorrr\r)r)_temprr r r _init_posixsrcCs~i}tddd|d<tddd|d<tdd|d<tjd|d<d |d <tjd d |d <tjjtjj t j |d<|a dS)z+Initialize the module as appropriate for NTrr)r0r6LIBDEST BINLIBDEST)r0 INCLUDEPY EXT_SUFFIXz.exeEXE.rVERSIONBINDIRN) r?r5_impextension_suffixesrrrrdirnameabspathr executabler\)rr r r_init_ntsrcGsdtdkr.tjdtj}|r(|niattd<ttd<tstjd}|dk r\|td<tjdt}tjdkrt rtj j t }tj j ||}ntj j t }tj jtj j|td<t otjdkrt}tj jtd o|tjkrtj j |td}tj j|td<tjd kr.d dl}|jt|r\g}x|D]}|jtj|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. N_init_r1 exec_prefixrSOr"rrAr)r\rrarr)rr=r*rr+rrrxr rr-isabsgetcwdrrYrZcustomize_config_varsappend)argsfuncrr"baserZvalsr)r r rr]sB       r]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)warningswarnDeprecationWarningr]ra)r)rr r rr,Qsr,)rN)rrN)N)N)8__doc__rrryrrrbuiltin_module_namesr*rr-r1rrr= base_prefixr(base_exec_prefixr'r^rrrrrrr>rr)rrr+r.rAttributeErrorrr5r9r?r[rortrxrrzrrrrrr\rrrr]r,r r r r sb       , 7K     jK