a „oeðIã@sdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z dej vZ ej ej¡Zej ej¡Zej ej¡Zej ej¡Zdejvr°ej ejd¡Zn&ejrÎej ej ej¡¡Zne ¡Zd d „Zeed dƒZ d d „Z!ej"dk�re dd„ƒZ#e#eƒZe#e ƒZ dd„Z$e$ƒZ%dZ&ze%�s:ej'Z&Wne(�yPYn0dd„Z)d;dd„Z*e dd„ƒZ+dd„Z,dd„Z-dd„Z.d d!„Z/d"d#„Z0d$d%„Z1dd3d4„Z;d5d6„Zd9d:„Z?dS)?a�Provide 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é)ÚDistutilsPlatformError)Ú py39compat)Ú pass_noneZ__pypy__Z_PYTHON_PROJECT_BASEcs&t |¡ d¡‰t‡fdd„dDƒƒS)z] Return True if the target directory appears to point to an un-installed Python. ZModulesc3s|]}ˆ |¡ ¡VqdS©N)ÚjoinpathÚis_file)Ú.0Úfn©Úmodules©ú@C:\Program Files\Certbot\pkgs\setuptools\_distutils\sysconfig.pyÚ 2óz(_is_python_source_dir..)ZSetupz Setup.local)ÚpathlibÚPathrÚany©Údr r rÚ_is_python_source_dir,srÚ_homecCstj |¡ tj |¡¡S)z, Return True if a is a parent of b. )ÚosÚpathÚnormcaseÚ startswith)Zdir_aZdir_br r rÚ _is_parent8srÚntcs$ttf}‡fdd„|Dƒ}t|ˆƒS)Nc3s&|]}tˆtj |d¡ƒr|VqdS)ZPCbuildN)rrrÚjoin)r Úprefixrr rrEsþz_fix_pcbuild..)ÚPREFIXÚ BASE_PREFIXÚnext)rÚprefixesZmatchedr rrÚ _fix_pcbuildAs  þr$cCstr ttƒSttƒSr)Ú _sys_homerÚ project_baser r r rÚ _python_buildPsr'Ú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_versionfsr,cCs`|rtnt}|dur|n|}ztƒdtj›�}Wn tyRtdtjƒ‚Yn0||||ƒS)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'. NZ_get_python_inc_zFI don't know where Python installs its C header files on platform '%s')ÚBASE_EXEC_PREFIXr!ÚglobalsrÚnameÚKeyErrorr)Ú plat_specificrÚdefault_prefixZresolved_prefixÚgetterr r rÚget_python_incns  ÿÿ r4cCstj |¡r|SdS)z5 Replace path with None if it doesn't exist. N)rrÚexists)rr r rÚ_extant…sr6cCs:trtjdkrtj |d¡St|ƒp8tt||ƒƒp8t |ƒS)N©ééÚinclude) ÚIS_PYPYr*r+rrrÚ_get_python_inc_posix_pythonr6Ú_get_python_inc_from_configÚ_get_python_inc_posix_prefix©rÚ spec_prefixr1r r rÚ_get_python_inc_posix�s ÿýrAcCs2tsdS|rtptStj tdƒd¡}tj |¡S)zú Assume the executable is in the build directory. The pyconfig.h file should be in the same directory. Since the build directory may not be the source directory, use "srcdir" from the makefile to find the "Include" directory. NZsrcdirZInclude)Ú python_buildr%r&rrrÚget_config_varÚnormpath)r1Zincdirr r rr<—s r<cCs|durtd|dƒSdS)aj If no prefix was explicitly specified, provide the include directory from the config vars. Useful when cross-compiling, since the config vars may come from the host platform Python installation, while the current Python executable is from the build platform installation. >>> monkeypatch = getfixture('monkeypatch') >>> gpifc = _get_python_inc_from_config >>> monkeypatch.setitem(gpifc.__globals__, 'get_config_var', str.lower) >>> gpifc(False, '/usr/bin/') >>> gpifc(False, '') >>> gpifc(False, None) 'includepy' >>> gpifc(True, None) 'confincludepy' NZCONFZ INCLUDEPY)rC)r1r@r r rr=§sr=cCs*trdnd}|tƒt}tj |d|¡S)NÚpypyÚpythonr:)r;r,Ú build_flagsrrr)rÚimplementationZ python_dirr r rr>¾s r>cCs6tr(tj |d¡tjjtj |d¡Stj |d¡S)Nr:ÚPC)rBrrrÚpathsepr?r r rÚ_get_python_inc_ntÄs ÿ þÿrKcCs|r|Stj |d¡SdS)Nú site-packages)rrr)Ú standard_libÚ libpythonÚ early_prefixrr r rÚ _posix_libÑsrPcCstrBtjdkrB|durt}|r4tj |dtjd¡Stj |d¡S|}|durl|r`|rZtp\t }n |rht pjt}tj dkrÀ|s~|rŒt tddƒ}nd}tr˜d nd }tj |||t ƒ¡}t||||ƒStj d krî|rÜtj |d ¡Stj |d d¡Sntd tj ƒ‚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'. r7Nz lib-pythonrrLÚposixÚ platlibdirÚlibrErFrZLibz?I don't know where Python installs its library on platform '%s')r;r*r+r rrrÚversionr-r!Ú EXEC_PREFIXr/Úgetattrr,rPr)r1rMrrOÚlibdirrHrNr r rÚget_python_libØs6    ÿÿrXc Cs|jdk�rtjdkr8tdƒs8ddl}| t¡dtd<tddd d d d d dƒ\}}}}}}}} dtj vržtj d} d tj vrš|  |¡rš| |t |ƒd…}| }dtj vr²tj d}d tj vrÆtj d }dtj vrÜtj d} n|d} dtj v�r|dtj d}d tj v�r2|dtj d }|dtj d }dtj v�rt| dtj d} |dtj d}|dtj d}d tj v�rŠtj d }dtj v�rª|dtj d} n |d| } |d|} |j | | | d||||| d�dtj v�r|j  dd¡�r|j tj dd�||_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ÚTrueZCCZCXXÚCFLAGSZCCSHAREDZLDSHAREDZ SHLIB_SUFFIXZARZARFLAGSZCPPz -EÚLDFLAGSú ÚCPPFLAGS)Z preprocessorÚcompilerZ compiler_soZ compiler_cxxZ linker_soZ linker_exeÚarchiverZRANLIBÚranlib)ra)Z compiler_typer*ÚplatformrCÚ _osx_supportÚcustomize_compilerÚ _config_varsÚget_config_varsrÚenvironrÚlenZset_executablesZ executablesÚgetZshared_lib_extension)r_rcZccZcxxZcflagsZccsharedZldsharedZ shlib_suffixÚarZar_flagsZnewccZcppr`Zcc_cmdr r rrds€    ø÷                 ù rdcCsDtr8tjdkr"tj tptd¡}ntp(t}tj |d¡St ¡SdS)z2Return full pathname of installed pyconfig.h file.rrIz pyconfig.hN) rBrr/rrr%r&Ú sysconfigÚget_config_h_filename)Zinc_dirr r rrljs  rlcCst ¡S)zAReturn full pathname of installed Makefile from the Python build.)rkÚget_makefile_filenamer r r rrmvsrmcCstj||d�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. )Úvars)rkÚparse_config_h)ÚfpÚgr r rro{sroz"([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�}|dur*i}i}i}| ¡}|durDqÂt |¡}|r2| dd¡\}} |  ¡} |  dd ¡} d | vrˆ| ||<q2z t| ƒ} Wn"t y¶|  dd ¡||<Yq20| ||<q2d } |�rpt |ƒD�]–} || } t   | ¡pôt   | ¡}|�rf| d¡}d }||v�r"t||ƒ}nˆ||v�r2d }nx|tjv�rJtj|}n`|| v�rž|  d¡�rx| dd…| v�rxd }n$d||v�rŒd }nt|d|ƒ}n d ||<}|�rl| | ¡d…}| d| ¡…||} d |v�rì| || <nxz t| ƒ} Wn t �y|  ¡|| <Yn 0| || <|| =|  d¡�rl| dd…| v�rl| dd…} | |v�rl| || <qÔ|| =qÔqÆ| ¡| ¡D]"\}} t| tƒ�r€|  ¡||<�q€| |¡|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ÚerrorsNr)z$$r(ú$)r[r\r^TFZPY_r8)Zdistutils.text_filerrÚreadlineÚ _variable_rxÚmatchÚgroupÚstripÚreplaceÚintÚ ValueErrorÚlistÚ _findvar1_rxÚsearchÚ _findvar2_rxÚstrrrgrÚendÚstartÚcloseÚitemsÚ isinstanceÚupdate)r rqrrrpZdoneZnotdoneÚlineÚmÚnÚvZtmpvZrenamed_variablesr/ÚvalueÚfoundÚitemZafterÚkr r rÚparse_makefileŒs„  ÿ                      r‘cCsVt |¡pt |¡}|rR| ¡\}}|d|…| | d¡¡||d…}qqRq|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)rr€r�Úspanriry)ÚsrnrŠZbegrƒr r rÚexpand_makefile_varsøs  *r”cGs4tdurt ¡ ¡at t¡|r0dd„|DƒStS)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. NcSsg|]}t |¡‘qSr )reri)r r/r r rÚ #rz#get_config_vars..)rerkrfÚcopyrZadd_ext_suffix)Úargsr r rrfs   rfcCs*|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) ZSOrNz SO is deprecated, use EXT_SUFFIXr))ÚwarningsÚwarnÚDeprecationWarningrfri)r/r˜r r rrC&srC)rN)rrN)N)N)@Ú__doc__rÚrer*rkrrtrr(rÚ _functoolsrÚbuiltin_module_namesr;rrDrr Ú exec_prefixrUÚ base_prefixr!Úbase_exec_prefixr-rgÚabspathr&Ú executableÚdirnameÚgetcwdrrVr%rr/r$r'rBrGZabiflagsÚAttributeErrorr,r4r6rAr<r=r>rKrPrXrdrlrmroÚcompilerwrr�r‘r”rerfrCr r r rÚsr               6\     l