_d. >dZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZmZmZddlmZmZdd lmZej.d gd gd gd gdgdgdgdgej0d ZdZdZGdde ZGddeZdZdZdZ dZ!dZ"dZ#y)adistutils.cygwinccompiler Provides the CygwinCCompiler class, a subclass of UnixCCompiler that handles the Cygwin port of the GNU C compiler to Windows. It also contains the Mingw32CCompiler class which handles the mingw32 port of GCC (same as cygwin in no-cygwin mode). N) check_output) UnixCCompiler) write_file)DistutilsExecErrorDistutilsPlatformErrorCCompilerError CompileError) LooseVersionsuppress_known_deprecation)RangeMapmsvcr70msvcr71msvcr80msvcr90msvcr100msvcr110msvcr120 vcruntime140) iiixii@iiilictjdtj} t |j d} t|S#t $rYywxYw#t$rtd|zwxYw)zaInclude the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. zMSC v\.(\d{4})rNzUnknown MS Compiler version %s ) researchsysversionintgroupAttributeError _msvcr_lookupKeyError ValueError)matchmsc_vers G/usr/lib/python3/dist-packages/setuptools/_distutils/cygwinccompiler.py get_msvcrr$4sx II' 5Eekk!n%FW%%  F:WDEEFsA A AAA1zxUnable to set runtime library search path on Windows, usually indicated by `runtime_library_dirs` parameter to ExtensionceZdZdZdZdZdZdZdZdZ dZ dZ d Z dfd Z ed Zd Z dd ZdZfdZefdZxZS)CygwinCCompilerz9Handles the Cygwin port of the GNU C compiler to Windows.cygwinz.oz.az.dll.az.dllzlib%s%szcyg%s%sz.exec \t||||t\}}|jdj |||t ur|j d|ztjjdd|_ tjjdd|_ |j|_ d}|jd|jzd |jzd|jzd |jzd j |j| t|_y) Nz%Python's GCC status: {} (details: {})zPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.CCgccCXXzg++-sharedz%s -mcygwin -O -Wallz%s -mcygwin -mdll -O -Wallz %s -mcygwinz{} -mcygwin {}compiler compiler_so compiler_cxx linker_exe linker_so)super__init__check_config_h debug_printformat CONFIG_H_OKwarnosenvirongetcccxx linker_dllset_executablesr$ dll_libraries)selfverbosedry_runforcestatusdetails shared_option __class__s r#r4zCygwinCCompiler.__init__Vs '51(*  3 : :67 K   $ IIOQXY  **..u-::>>%/''!  +dgg54tww>/$((:$tww.'..t N  '[ctjdtdt5t dcdddS#1swYyxYw)Nzgcc_version attribute of CygwinCCompiler is deprecated. Instead of returning actual gcc version a fixed value 11.2.0 is returned.) stacklevelz11.2.0)warningsr9DeprecationWarningr r )rBs r# gcc_versionzCygwinCCompiler.gcc_versionvsA   X   ( ) *) * * *s <Ac|dvr |jdd|d|gy |j|j|z|d|gz|zy#t$r}t|d}~wwxYw#t$r}t|d}~wwxYw)z:Compiles the source by spawning GCC and windres if needed.).rc.reswindresz-iz-oN)spawnrr r/)rBobjsrcextcc_argsextra_postargspp_optsmsgs r#_compilezCygwinCCompiler._compiles / ! ( ItS$<= ( $$w.#tS1AANR & ("3'' (& ("3'' (s.A'A" A AA" A;+ A66A;ctj| xsg} tj|xsg}tj|xsg}|r|jt|j|j| ||j k7s|j dk(rtjj|d}tjjtjj|\}}tjj||dz}dtjj|zdg}|D]}|j||jt||fd|z|j|| s| jdt!j"||||||||d| | | | | y) zLink the objects.Nr*rz.defz LIBRARY %sEXPORTSz writing %sz-s)copyr9_runtime_library_dirs_msgextendrA EXECUTABLEr?r:pathdirnamesplitextbasenamejoinappendexecuterrlink)rB target_descobjectsoutput_filename output_dir libraries library_dirsruntime_library_dirsexport_symbolsdebug extra_preargsrZ build_temp target_langtemp_dirdll_name dll_extensiondef_filecontentssyms r#rkzCygwinCCompiler.links$ -"526 IIio2. ))GMr*  II/ 0 ++,  & 4?? *doo.Fwwwqz2H(*(8(8  1) %X} ww||Hh.?@H%rww'7'7'HH)TH% %$ % LLh%9<(;R S NN8 $   &              rJc0|jtgSN)r9rarBdirs r#runtime_library_dir_optionz*CygwinCCompiler.runtime_library_dir_options +, rJcdtjj|}t||||Sr)r:rdnormcaser3_make_out_path)rBro strip_dirsrc_name norm_src_namerIs r#rzCygwinCCompiler._make_out_paths+((2 w%j)]KKrJcbit|dDcic]}|||jzc}Scc}w)z3 Add support for rc and res files. )rSrR)r3out_extensions obj_extension)rBrXrIs r#rzCygwinCCompiler.out_extensionss@  g$ 8GHsC$,,,,H  Hs,rrr) NNNNNrNNNN)__name__ __module__ __qualname____doc__ compiler_typerstatic_lib_extensionshared_lib_extensiondylib_lib_extensionstatic_lib_formatshared_lib_formatdylib_lib_format exe_extensionr4propertyrPr]rkrrr __classcell__rIs@r#r&r&IsCMM# !! M)@ * *(*!X tL   rJr&c.eZdZdZdZdfd ZdZxZS)Mingw32CCompilerz:Handles the Mingw32 port of the GNU C compiler to Windows.mingw32c 4t||||d}t|jr t d|j d|jzd|jzd|j zd|jzdj|j|y)Nr,z1Cygwin gcc cannot be used with --compiler=mingw32z %s -O -Wallz%s -mdll -O -Wallz%sz{} {}r-) r3r4 is_cygwinccr=r r@r>r7r?)rBrCrDrErHrIs r#r4zMingw32CCompiler.__init__s '51! tww  !TU U "TWW,+dgg5&1dgg~nnT__mD  rJc ttr)rrars r#rz+Mingw32CCompiler.runtime_library_dir_options$%>??rJr)rrrrrr4rrrs@r#rr sDM @rJrokznot ok uncertaincddlm}dtjvrtdfSdtjvrtdfS|j } t |} d|jvrtd|zf|jStd |zf|jS#|jwxYw#t$r,}td j||jfcYd }~Sd }~wwxYw) awCheck if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h 'details' is a human-readable string explaining the situation. Note there are two ways to conclude "OK": either 'sys.version' contains the string "GCC" (implying that this Python was built with GCC), or the installed "pyconfig.h" contains the string "__GNUC__". r) sysconfigGCCzsys.version mentions 'GCC'Clangzsys.version mentions 'Clang'__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '{}': {}N) distutilsrrrr8get_config_h_filenameopenreadcloseCONFIG_H_NOTOKOSErrorCONFIG_H_UNCERTAINr7strerror)rfnconfig_hexcs r#r5r5+s*$  888#++:::  ( ( *B W8 X]]_,"$>$CC NN &'IB'NN NN HNN  W"$<$C$CB $UVVWsB B5B 4B5 B B5 B22B55 C*>!C%C*%C*cttj|dgz}|jj dS)zCTry to determine if the compiler that would be used is from cygwin.z -dumpmachinescygwin)rshlexsplitstripendswith)r= out_strings r#rrZs6ekk"o0@@AJ     & &y 11rJ)$rr:rrr`rrN subprocessr unixccompilerr file_utilrerrorsrrr r rr r _collectionsr leftundefined_valuerr$rar&rr8rrr5r get_versionsrJr#rs #(! >" kkkklll&&# . F I | m| @@@:  ,W^2  rJ