;i68dZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddl m Z ddlmZddlmZe jeZd Zd efd Ze jd e jzd ze jzdze jzdze jzdzZd efdZdZdadZdS)z? Utility functions related to analyzing/bundling dependencies. N)CodeType)compat)log)bytecode)include_library)ExecCommandFailedct|}t|}t|D]}|s|||tj|krL |j}n#t$rd}YnwxYwt d||||t|}|S)NUNKNOWNzPIgnoring %s imported from %s - only basenames are supported with ctypes imports!) *__recursively_scan_code_objects_for_ctypessetlistremoveospathbasename co_filename Exceptionloggerwarning_resolveCtypesImports)cobinariesbinaryfilenames LC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\PyInstaller/depend/utils.pyscan_code_for_ctypesrs9"==H8}}Hx..$$ $ OOF # # # # rw''// / / %> % % %$ % NNbdjlt    OOF # # #$X..H Os,A44 BBcodeclddlm}m}g}h|d|d|d|d|d|d|d |d }h|d }tj|D]}|D]\}}t |d krt|dts4||vr |j |C||vr|d} | r tj | } n3#t$r&d } td|dYnwxYw| r4t j| } | | ܌|t&|D]} || |S)z Detects ctypes dependencies, using reasonable heuristics that should cover most common ctypes usages; returns a list containing names of binaries detected as dependencies. r) any_aliassearch_recursivelyz ctypes.CDLLzctypes.cdll.LoadLibraryz ctypes.WinDLLzctypes.windll.LoadLibraryz ctypes.OleDLLzctypes.oledll.LoadLibraryz ctypes.PyDLLzctypes.pydll.LoadLibraryzctypes.util.find_libraryNzqctypes.util.find_library raised a FileNotFoundError. Supressing and assuming no lib with the name "%s" was found.)PyInstaller.depend.bytecoderr rrecursive_function_callsvalueslen isinstancestrappendctypesutil find_libraryFileNotFoundErrorrrrrr_scan_code_for_ctypes_getattrextend) rrr rctypes_dll_namesfind_library_namescallsnameargslibnameis rr r :sh JIIIIIIIH  = ! !  , - -  ? # #  . / /  ? # #  . / /  > " "  - . .  - . .2488??AA11! 1 1LT4t99>>DGS)A)A>'''&&&+++q' 1"(+":":7"C"C,"&[\`ab\c 1"$'"2"27";"; 000/ 16  =t D D K K M M Os.D-D>=D>sV # Matches 'foo.bar' or 'foo.bar.whizz'. # Load the 'foo'. ( (?:(?:s).)* (?:s). ) # Load the 'bar.whizz' (one opcode per name component, each possibly preceded by name reference extension). ( (?: (?:(?:s).)* (?:s). )+ ) c#Kd}tjt|jD]}|\}}tj||}tj||}|r |ddkrRt|dkr||vr |ddzVt|dkr|dkr|d|vr |ddzVd S) zs Detect uses of ``ctypes.cdll.library_name``, which implies that ``library_name.dll`` should be collected. )cdlloledllpydllwindll LoadLibraryr!r.dllr)N)rfinditer_ctypes_getattr_regexco_codegroupsloadloadsr%)r key_namesmatchr2attrss rr-r-s 6I"#8$,GG((llnn e}T4((ud++  U2Y-//  u::??y  Ah'''' u::??xE!H $9$9Ah''''((cj ddlm}ddlm tjrd ntjrd nd fd} fd}g}|}|D]} |tj |d}n#t$rd }YnwxYwtjs tj r||}t j d  tjD]a}tjtj||r"tj||}nPbt"t%|t"vr/t"|}tj|sJnd }|ot'|sWtjs5tj s)|d rt.d |t'|s|||d f|||S)a Completes ctypes BINARY entries for modules with their full path. Input is a list of c-binary-names (as found by `scan_code_instruction_for_ctypes`). Output is a list of tuples ready to be appended to the ``binaries`` of a modules. This function temporarily extents PATH, LD_LIBRARY_PATH or DYLD_LIBRARY_PATH (depending on the platform) by CONF['pathex'] so shared libs will be search there, too. Example: >>> _resolveCtypesImports(['libgs.so']) [(libgs.so', ''/usr/lib/libgs.so', 'BINARY')] r)r+)CONFLD_LIBRARY_PATHDYLD_LIBRARY_PATHPATHctjd}tj}|!tj||f}tj||S)Npathex)rpathsepjoinrgetenvsetenv)roldrJenvvars r _setPathsz(_resolveCtypesImports.._setPathss\ztH~..mF## ?:??D#;//D fd### rHcb|tjdStj|dS)N)runsetenvrS)rTrUs r _restorePathsz,_resolveCtypesImports.._restorePathss6 ; OF # # # # # M&# & & & & &rHNr=z(Library %s required via ctypes not foundBINARY) ctypes.utilr+PyInstaller.configrJris_unix is_darwinrrsplitextr, is_cygwinrRsplitrPisfilerQLDCONFIG_CACHEload_ldconfig_cacheris_winlowerendswithrrr() cbinariesr+rVrYretrTcbincpathdrJrUs @@rrrs)((((('''''' ~"  $''''' C )++C)0)0 !L!1!1$!7!7!:;;EE    EEE  > !V- !}]62..44RZ@@ ! !7>>"',,q%"8"899GLLE22EE")')))N***51E7>>%000000 E =#4(( M &*:  @U@UV\@]@]  NNEt L L L L"5))  JJeX. / / / /M# Js .A;; B  B ctdStjriadStjriadSt jd}|t jdd}|iadStjs tjrd}d}tj d}nd}d }tj d } tj ||}n-#t$r t d iaYdSwxYw||d}ia|D],}||}|2tjd |rnt d |L|d}tjs tjrt&j|dd d}d|d z} | |sJ|dz| t3|dz} n|d } | tvr |t| <.dS)z Create a cache of the `ldconfig`-output to call it only once. It contains thousands of libraries and running it on every dylib is expensive. Nldconfigz/usr/sbin:/sbin:/usr/bin:/bin)rz-rr>z^\s+\d+:-l(\S+)(\s.*)? => (\S+)z-pr!z^\s+(\S+)(\s.*)? => (\S+)z/Failed to execute ldconfig. Disabling LD cache.zCache generated by:z,Unrecognised line of output %r from ldconfigr;z.sorlib)rdrrais_muslshutilwhich is_freebsd is_openbsdrecompile exec_commandrrrstrip splitlinesrFsearchrBrrrrbgroup startswithr%) ro ldconfig_argsplitlines_countpatterntextlinemrbnamer2s rreresn!  ~|J''H< 1PQQQ  N F ;F-; *?@@ *9::"8\:: HIII ::<< " " $ $%5%6%6 7DN(( MM$   9y.55 UMtTTT xxzz"~    1 G$$T**00::1=E1771::%D??5)) ) ))5=4E #44DD771::D ~ % %#'N4 7((s&B<<&C&%C&) __doc__r\r)rrvrrtypesr PyInstallerrrloggingPyInstaller.dependrPyInstaller.depend.dylibrPyInstaller.exceptionsr getLogger__name__rrr bytecode_regex_OPCODES_EXTENDED_ARG_OPCODES_FUNCTION_GLOBAL_OPCODES_FUNCTION_LOADr@r-rrdrerHrrs &&&&&&''''''444444444444  8 $ $85X5555p0/ 0 1 4  0 1 4 2 36 0 14*(((((4WWWtZ(Z(Z(Z(Z(rH