
    !hi;?                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ ej                  rd dl
mZ  ej                  e      Zej                   d        Z G d d	      Z e       Zy)
    N)compat)isolated)log)	bindepend)osxc                     	 ddl } ddl}	 | j                         }|j                  d      }t        |j                  j                  d      d         }|dk\  rd}n	 |j                  d       d}dt        |d	d      |j                  |j                  ||d
S # t        $ r Y yw xY w# | j                  $ r Y yw xY w# | j                  $ r d}Y _w xY w)a  
    Isolated-subprocess helper to retrieve the basic Tcl/Tk information:
     - tkinter_extension_file = the value of __file__ attribute of the _tkinter binary extension (path to file).
     - tcl_data_dir = path to the Tcl library/data directory.
     - tcl_version = Tcl version
     - tk_version = Tk version
     - tcl_theaded = boolean indicating whether Tcl/Tk is built with multi-threading support.
    r   Nzinfo library.	   Tztcl_platform(threaded)F__file__)	availabletkinter_extension_filetcl_version
tk_versiontcl_threadedtcl_data_dir)tkinter_tkinterImportErrorTclTclErrorevalintTCL_VERSIONsplitgetvargetattr
TK_VERSION)r   r   tclr   	TCL_MAJORr   s         JC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/utils/hooks/tcl_tk.py_get_tcl_tk_infor!      s    kkm
 88N+L
 H((..s3A67IA~	!JJ/0L
 ")(J"E++))$$ 1  
     	! L	!s4   B B& B; 	B#"B#&B87B8;CCc                   n    e Zd ZdZdZd Zd Zd Zd Ze	dd       Z
e	d	        Ze	d
        Ze	d        Zy)	TclTkInfo	_tcl_data_tk_datac                      y N selfs    r    __init__zTclTkInfo.__init__V   s        c                      y)Nr#   r(   r)   s    r    __repr__zTclTkInfo.__repr__Y   s    r,   c                 l    d| j                   v rt        |      | j                          t        | |      S )Nr   )__dict__AttributeError_load_tcl_tk_infor   )r*   names     r    __getattr__zTclTkInfo.__getattr__]   s4    $--' && 	 tT""r,   c                    t         j                  d|        d| _        d | _        d | _        d | _        d| _        d | _        d | _        d | _	        d| _
        d | _        d | _        g | _        	 t               }|t         j#                  d|        y |j%                         D ]  \  }}t'        | ||        t)        d | j                  j+                  d      d d D              | _        t)        d | j
                  j+                  d      d d D              | _        | j                  r	 | j-                  | j                        \  | _        | _        t.        j0                  rG| j3                  | j                        | _
        | j                  s| j5                  | j                         dt6        j8                  v rt6        j8                  d   | _        n/t.        j0                  r| j                  rt;        j<                  | j                        s| j                  j?                  d      rmt6        j@                  jC                  | j                        }t6        j@                  jE                  t6        j@                  jG                  |      dd      | _        nlt6        j@                  jE                  t6        j@                  jG                  | j                        d| j
                  d    d| j
                  d          | _        t6        j@                  jE                  t6        j@                  jG                  | j                        d| j                  d          | _	        | j                  rt         j                  d|        y t6        j@                  jI                  | j                        r>| xj                  | jK                  | j                  | jL                  g d      z  c_        n!t         j!                  d| | j                         t6        j@                  jI                  | j                        r>| xj                  | jK                  | j                  | jN                  g d      z  c_        n!t         j!                  d| | j                         t6        j@                  jI                  | j                        rX| xj                  | jK                  | j                  t6        j@                  jQ                  | j                              z  c_        y t         j!                  d| | j                         y # t        $ r!}t         j!                  d| |       Y d }~y d }~ww xY w# t        $ r t         j!                  d	| d
       Y 5w xY w)Nz&%s: initializing cached Tcl/Tk info...Fz$%s: failed to obtain Tcl/Tk info: %szI%s: failed to obtain Tcl/Tk info: tkinter/_tkinter could not be imported.c              3   2   K   | ]  }t        |        y wr'   r   .0xs     r    	<genexpr>z.TclTkInfo._load_tcl_tk_info.<locals>.<genexpr>   s     !RQ#a&!R   r	      c              3   2   K   | ]  }t        |        y wr'   r7   r8   s     r    r;   z.TclTkInfo._load_tcl_tk_info.<locals>.<genexpr>   s      PAQ Pr<   z;%s: failed to determine Tcl and Tk shared library location!T)exc_info
TK_LIBRARYzTk.framework/Tk	ResourcesScriptstkr      r   zD%s: using macOS system Tcl/Tk framework - not collecting data files.)demos*.libztclConfig.sh)prefixexcludesz1%s: Tcl library/data directory %r does not exist!)rE   rF   ztkConfig.shz0%s: Tk library/data directory %r does not exist!)rG   z+%s: Tcl module directory %r does not exist!))loggerinfor   r   r   r   r   r   tk_data_dirtcl_module_diris_macos_system_frameworktcl_shared_librarytk_shared_library
data_filesr!   	Exceptionwarningdebugitemssetattrtupler   _find_tcl_tk_shared_librariesr   	is_darwin_check_macos_system_framework"_warn_if_using_activetcl_or_teapotosenvironosxutilsis_framework_bundle_libendswithpathrealpathjoindirnameisdir_collect_files_from_directoryTCL_ROOTNAMETK_ROOTNAMEbasename)r*   tcl_tk_infoekeyvaluetk_lib_realpaths         r    r2   zTclTkInfo._load_tcl_tk_infog   sn   <dC &*#! ").&"&!%	*,K LLdfjk &++- 	&JCD#u%	& !!R$2B2B2H2H2Mbq2Q!RS P1F1Fs1KBQ1O PQ &&s 66t7R7RS+* 151S1STXTkTk1l. 55;;D<M<MN 2::%!zz,7D$"8"8--d.D.DE##--.?@ !gg..t/E/EFO!ww||BGGOOO,Lk[deD!ww|| 1 12T__Q'($//!*<)=> D !ggllGGOOD--.$""1%&'
 ))KK^`de ww}}T../4#E#E%%,,? $F $  RTXZ^ZkZklww}}T--.4#E#E$$++> $F $  QSWY]YiYij ww}}T0014#E#E''77++D,?,?@ $F $ 
 LdTXTgTghe  	NNA4K	:  s\^bmqrss*   ,
T3 '(U  3	U<UU !VVNc                    |xs g }| |fg}g }|r|j                         \  }}t        j                  |      D ]  t        fd|D              rt        j                  j                  |      }|r t        j                  j                  |      n}t        j                  j                  |      r|j                  ||f       |j                  ||df        |r|S )z
        A minimal port of PyInstaller.building.datastruct.Tree() functionality, which allows us to avoid using Tree
        here. This way, the TclTkInfo data structure can be used without having PyInstaller's config context set up.
        c              3   J   K   | ]  }t        j                   |        y wr'   )fnmatch)r9   excludeentrys     r    r;   z:TclTkInfo._collect_files_from_directory.<locals>.<genexpr>  s     PGw7Ps    #DATA)popr[   listdiranyr`   rb   rd   append)	rootrG   rH   todooutput
target_dirsrc_path	dest_pathrr   s	           @r    re   z'TclTkInfo._collect_files_from_directory   s     >rv!%JJ/ APxPQ77<<
E:;ABGGLL7u	77==*KK9 56 MM9h"?@A " r,   c                     d}d}t        j                  |       D ]E  \  }}|	t        j                  j	                  |      }|j                         }d|v r|}?d|v sD|}G ||fS )zi
        Find Tcl and Tk shared libraries against which the _tkinter extension module is linked.
        NrC   r   )r   get_importsr[   r`   rh   lower)tkinter_ext_filetcl_libtk_lib_lib_pathlib_namelib_name_lowers          r    rW   z'TclTkInfo._find_tcl_tk_shared_libraries  s    
 $001AB 	#KAx ww''1H%^^-N
 ~%!.("	#" r,   c                     | yd| v S )NTz Library/Frameworks/Tcl.frameworkr(   )tcl_shared_libs    r    rY   z'TclTkInfo._check_macos_system_framework*  s    
 ! 2^CCr,   c                    | yt         j                  j                  | d      }t         j                  j                  |      syd}d}t	        |dd      5 }|j                         D ]E  }|j                         j                         }|j                  d      r3d|v rd	}d
|v rd	}|sB|sE n ddd       |r|rt        j                  d|d       yyy# 1 sw Y   )xY w)a  
        Check if Tcl installation is a Teapot-distributed version of ActiveTcl, and log a non-fatal warning that the
        resulting frozen application will (likely) fail to run on other systems.

        PyInstaller does *not* freeze all ActiveTcl dependencies -- including Teapot, which is typically ignorable.
        Since Teapot is *not* ignorable in this case, this function warns of impending failure.

        See Also
        -------
        https://github.com/pyinstaller/pyinstaller/issues/621
        Nzinit.tclFrutf8)encoding#	activetclTteapotzYou appear to be using an ActiveTcl build of Tcl/Tk, which PyInstaller has
difficulty freezing. To fix this, comment out all references to 'teapot' in
zP
See https://github.com/pyinstaller/pyinstaller/issues/621 for more information.)r[   r`   rb   isfileopen	readlinesstripr   
startswithrI   rR   )tcl_rootinit_tclmentions_activetclmentions_teapotfplines         r    rZ   z,TclTkInfo._warn_if_using_activetcl_or_teapot5  s      77<<*5ww~~h'" (C&1 
	R 	zz|))+??3'$&)-&t#&*O%/	
	 /NN`, bb #2
	 
	s   AC)C,CC )NN)__name__
__module____qualname__rf   rg   r+   r.   r4   r2   staticmethodre   rW   rY   rZ   r(   r,   r    r#   r#   J   sw     LK#IiV  8  4 D D + +r,   r#   )r[   rp   PyInstallerr   r   r   loggingPyInstaller.dependr   rX   PyInstaller.utilsr   r]   	getLoggerr   rI   decorater!   r#   
tcltk_infor(   r,   r    <module>r      sh    
     & (	1			8	$ 
, ,^W Wt [
r,   