
     hiA                         d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
 d dlmZmZmZ d dlmZmZmZ d dlmZmZ d dlmZ d dlmc mZ er	d dlmc mZ dZd	Z  G d
 de      Z!y)    N)log)COLLECTEXE)Targetloggernormalize_toc)_check_path_overlap_rmtreeprocess_collected_binary)	is_darwinstrict_collect_mode)normalize_icon_type__dot__zOnefile mode in combination with macOS .app bundles (windowed mode) don't make sense (a .app bundle can not be a single file) and clashes with macOS's security. Please migrate to onedir mode. This will become an error in v7.0.c                   d     e Zd Z fdZdZd Zed        Zed        Zd Z	d Z
ed        Z xZS )	BUNDLEc                 	   ddl m} |D ]H  }t        |t              s|j                  r!t        j                  t        j                  t               J t        sy |j                  d      | _        | j                  sft        j                  j                  t        j                  j!                  t        j                  j!                  t"                    ddd      | _        n[t        j                  j%                  | j                        s2t        j                  j                  |d   | j                        | _        t&        
| Q          |j                  dd       | _        t        j                  j-                  | j*                        }t        j                  j                  |d	   |      | _        t        j                  j/                  |      d   | _        t3        |j                  d
d            | _        g | _        d| _        d| _        d| _        d | _        d | _         d | _!        |j                  d      | _"        | jD                  s| j0                  | _"        |j                  dd       | _#        |D ]  }t        |t              r| j6                  jI                  t        j                  j-                  |j*                        |j*                  df       | j6                  jK                  |jL                         |j8                  | _        |j:                  | _        |jN                  | _'        |j<                  | _        |j>                  | _        |j@                  | _         |jB                  | _!        t        |tP              r| j6                  jK                  |j6                         |jR                  | _        |jT                  | _        |jN                  | _'        |j<                  | _        |j>                  | _        |j@                  | _         |jB                  | _!        tW        jX                  |      r| j6                  jK                  |       t[        dt]        |             | j6                  D ]  \  }}}	|	dk(  s|| _/         n ta        d      tc        | j6                        | _        | je                          y )Nr   CONFicon
bootloaderimageszicon-windowed.icnsspecpathnamedistpathversionz0.0.0FTbundle_identifier
info_plist
EXECUTABLEz"Invalid argument type for BUNDLE: z%No EXECUTABLE entry found in the TOC!)3PyInstaller.configr   
isinstancer   exclude_binariesr   r   loggingDEPRECATIONWINDOWED_ONEFILE_DEPRCATIONr   getr   ospathjoindirname__file__isabssuper__init__r   basenamesplitextappnamestrr   tocstripupxconsoletarget_archcodesign_identityentitlements_filer   r   appendextenddependenciesupx_excluder   strip_binariesupx_binaries	miscutilsis_iterable	TypeErrortypeexename
ValueErrorr   __postinit__)selfargskwargsr   item	base_namearg	dest_namesrc_nametypecode	__class__s             DC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/building/osx.pyr-   zBUNDLE.__init__)   s~   + 	MD$$T-B-B

7..0KL	M
  JJv&	yy 9:L(ThDI
 77==+GGLLj)9499E	 JJvt,	GG$$TYY/	GGLLj!19=	ww''	215 6::i9:
!%!% "(,?!@%%%)\\D" **\48 	TC#s#!1!1#((!;SXX| TU 0 01 YY
77#&?? "{{#&?? ),)>)>&),)>)>&C)( //
++#&?? "{{#&?? ),)>)>&),)>)>&&&s+$"DT#YM RSS;	TB .2XX 	F)Ix<''	F
 DEE !*    ))r2   Nc                      y)NT )rF   data
last_builds      rP   _check_gutszBUNDLE._check_guts   s    rQ   c                 v    t        | j                        D ]!  }|j                  j                  d      s|c S  y )Nz
.framework)reversedparentsr   endswith)	dest_pathparents     rP   _is_framework_filezBUNDLE._is_framework_file   s:     y001 	F{{##L1	 rQ   c                    t        j                  j                  g t        j                  |       j                  d      j                  j                  D cg c]  }d c}t        j                  |      j                  d       S c c}w )NContentsz..)r&   r'   r(   pathlibPurePathrelative_tor\   parts)crosslink_locationcrosslink_targetlevels      rP   _compute_relative_crosslinkz"BUNDLE._compute_relative_crosslink   sr    
 ww|| 
 ' 0 01C D P PQ[ \ c c i ijudj
-.:::F
 	
js   	B
c                    g }t               }d}d}d}d}t        j                  d      }|D ]  \  }	}
}t        j                  |	      }| j                  |      }|r|||<   d}|j                  }n|j                  }|dk(  rd}|D ]@  }||k(  r	|dk(  r|n|}|j                  ||      }||k(  r|dk(  r|}||k(  r|dk(  r|}|||<   B  t        j                  d	|       |j                         D ]  \  }}||k(  r|j                  }||k(  xs |j                  |      |k(  }|s6t        j                  d
||       ||k(  rAt        j                  j                  d|      }t        j                  j                  d|      }n@t        j                  j                  d|      }t        j                  j                  d|      }| j                  ||      }|j                  ||df        |j                         D ]  \  }}||k(  r||k(  rd|j                  vr!t        j                  dt!        |      |       |j                  t        j                  j                  d|      |j                  j#                  dt$              df        |D ]  \  }}
}t        j                  |      }|dk(  r5t        j                  j                  d|      }|j                  ||
|f       W|dk(  r{t        j                  j                  d|      }|j                  ||
|f       t        j                  j                  d|      }| j                  ||      }|j                  ||df       | j                  |      rd}d }n|dk(  rd}d}nd}d}d}|'|j                  }||k(  xs |j                  |      |k(  }|dk(  rh|rf|j                  t        j                  j                  ||      |
|f       |j                  t        j                  j                  ||      |
|f       t        j                  j                  ||      }|j                  ||
|f       |st        j                  j                  ||      }| j                  ||      }|j                  ||df        g }|D ].  \  }	}
}t        j                  |	      }|j&                  d   dk(  r'|j&                  d   dk(  r|j                  |	|
|f       V| j                  |      }|r|j                  }|j)                  |      }n|j                  }|j                  }t        j                  g |j&                  d d |j&                  dd  D cg c]  }|j#                  dt$               c}| } t!        |       }!| |k7  rt        j                  d|	|!       |j                  |!|
|f       1 |}t+        t-        |            }|S c c}w )Nz	MIXED-DIRzDATA-DIRz
BINARY-DIRzFRAMEWORK-DIR.BINARY	EXTENSIONDATAzDirectory classification: %rz%Cross-linking directory %r of type %rzContents/ResourcesContents/FrameworksSYMLINKzKCreating symlink to work around the dot in the name of directory %r (%s)...r   zContents/MacOSPKGFr   r_      	Resources   zSanitizing dest path: %r -> %r)dictr`   ra   r]   rY   r%   r   debugitemsr\   r&   r'   r(   rg   r9   r   r1   replaceDOT_REPLACEMENTrc   rb   sortedr   )"rF   r2   
bundle_tocdirectory_types_MIXED_DIR_TYPE_DATA_DIR_TYPE_BINARY_DIR_TYPE_FRAMEWORK_DIR_TYPE_TOP_LEVEL_DIRrL   rM   rN   r[   framework_dirparent_dirs
parent_dirdirectory_typedirectory_pathrequires_crosslinksymlink_srcsymlink_destsymlink_reforig_dest_nameorig_dest_path	file_destfile_base_dircrosslink_base_dirsanitized_tocframework_pathparent_pathremaining_pathpartsanitized_dest_pathsanitized_dest_names"                                     rP   _process_bundle_toczBUNDLE._process_bundle_tocB  sO   
 &%#'- ))#.-0 	=)Ix((3I 33I>M1D.#+33'//{*'H * =
 /5=5I!1~!0!4!4Z!P!^3H8L%4N!%55(f:L%4N.<
+=#	=B 	3_E
 />.C.C.E 	F*NN 0 (..J!+~!=!sATATU_A`dsAs%LL@.R`a
 / ggll+?P!ww||,A>R ggll+@.Q!ww||,@.Q::<UK|[)DE5	FL />.C.C.E 	*NN!44 / .---LL]_bcq_r 2NC##++CA +	< 36 C	J.NHh$--n=N <'GGLL)9>J	!!9h"AB
 U"GGLL)=~N	!!9h"AB
  "ww||,<nM">>|YW!!<i"HI
 &&~6 !6%)"V# 4%:" !6%9" "'!-+22
%/>%A%w_EXEXYcEdhwEw"
 9$);!!277<<~#NPXZb"cd!!277<<0BN#SU]_g"hi ]NCIy(H=> "!ww||,>O">>|YW!!<i"HIGC	JV -7 	L)Ix((3I q!Z/IOOA4F+4U$$i8%DE "44Y?N,33!*!6!6{!C'..!*")"2"2 #""2A&#ALARARSTSUAVW$,,sO4W# #
 #&&9":"i/=yJ]^  "5x!JK9	L< #
 M*56
 Xs   6W1c                 V   ddl m} t        | j                        r>t        j
                  j                  | j                        rt        | j                         t        j                  d| j                         t	        j                  t        j
                  j                  | j                  dd             t	        j                  t        j
                  j                  | j                  dd             t	        j                  t        j
                  j                  | j                  dd             t        | j                  dd	|d
         | _        t        j
                  j                  | j                        | _        t!        j"                  | j                  t        j
                  j                  | j                  ddt        j
                  j%                  | j                                     | j&                  | j&                  | j(                  t        j
                  j%                  | j*                        t        j
                  j%                  | j                        dd| j,                  d}| j.                  rd|d<   nd|d<   t1        | j2                  t4              r'| j2                  r|j7                  | j2                         t        j
                  j                  | j                  dd      }t9        |d      5 }t;        j<                  ||       d d d        | j?                  | j@                        }tC        jD                  d      }|D ]  \  }}}	t        j
                  j                  | j                  |      }
t        j
                  jG                  |
      }	 t	        j                  |d       |	dv rtM        tC        jD                  |      jO                  |            }tQ        ||| jR                  | jT                  | jV                  | jX                  | jZ                  | j\                  |	dk(  	      }|	dk(  rt	        j^                  ||
       n|	dk7  sJ d       t        j
                  ja                  |      stc        d|d      td        r1t        j
                  jg                  |
      rtc        d| d |	 d!      t!        j"                  ||
       |	d"v s-|	d#k(  st	        jh                  |t        jj                        st	        jl                  |
d$        t        j                  d%       	 to        jp                  | j                  | jZ                  | j\                  d&       t        j                  d,| j                         t        jt                  jw                  d-d(      d(k7  rQt        j                  d.| j                         | j}                  | j                         t        j                  d/       y y # 1 sw Y   xY w# tH        $ r tK        d|d      w xY w# tr        $ rf}t        jt                  jw                  d'd(      d(k(  r,t        jx                  d)|       t        jx                  d*       nt{        d+      |Y d }~(d }~ww xY w)0Nr   r   zBuilding BUNDLE %sr_   MacOSrq   
Frameworks)icnsr   workpathz6.0APPL)CFBundleDisplayNameCFBundleNameCFBundleIdentifierCFBundleExecutableCFBundleIconFileCFBundleInfoDictionaryVersionCFBundlePackageTypeCFBundleShortVersionStringTLSBackgroundOnlyNSHighResolutionCapablez
Info.plistwbrm   )exist_okz2ERROR: Pyinstaller needs to create a directory at z/, but there already exists a file at that path!)rk   rj   rk   )	use_stripuse_upxr<   r6   r7   r8   strict_arch_validationrn   
DEPENDENCYz5MERGE DEPENDENCY entries are not supported in BUNDLE!z	Resource z is not a valid file!z5Attempting to collect a duplicated file into BUNDLE: z (type: ))rk   rj   r   rl   i  zSigning the BUNDLE...)deep(PYINSTALLER_STRICT_BUNDLE_CODESIGN_ERROR0z"Error while signing the bundle: %sz*You will need to sign the bundle manually!zFailed to codesign the bundle!z*Building BUNDLE %s completed successfully.#PYINSTALLER_VERIFY_BUNDLE_SIGNATUREz$Verifying signature for BUNDLE %s...zBUNDLE verification complete!)?r   r   r	   r   r&   r'   isdirr
   r   infotocbasenamemakedirsr(   r   r   abspathshutilcopyfiler.   r0   r   rC   r   r5   r    r   rs   updateopenplistlibdumpr   r2   r`   ra   r)   FileExistsError
SystemExitr1   rb   r   r3   r4   r<   r6   r7   r8   symlinkisfilerD   r   existsaccessX_OKchmodosxutilssign_binary	Exceptionenvironr%   warningRuntimeErrorverify_bundle_signature)rF   r   info_plist_dictplist_filenameplist_fhry   CONTENTS_FRAMEWORKS_PATHrL   rM   rN   r[   dest_dirr   es                 rP   assemblezBUNDLE.assemble*  s   +tyy)bggmmDII.FDII($*:*:; 	BGGLLJ@A
BGGLLJDE
BGGLLJEF (		9fd:FVW	 GGOODII.	 			277<<		:{TVT[T[TdTdeienenTo#pq $(<< LL #'"8"8"$''"2"24<<"@ " 0 0 ;-2#)*.,,%
, <<26O./ :>O56 doot,""4??3dii\J.$' 	58MM/84	5 --dhh7
 $+#3#34I#J -7 5	+)IxTYY	:Iwwy1HHt4 22!$W%5%5i%@%L%LMe%f!g3""jj HH $ 0 0 $ 0 0&*&<&<&*&<&<,4,C
 9$

8Y/  </h1hh/ ww~~h/$y<Q%RSS&277>>)+D$OPY{Zbckbllmn  )4AA&299Xrww+GE*k5	+p 	+,	L  D,B,BDDZDZaef 	@$BRBRS ::>>?ELKK>		J((3KK78 M]	5 	5 #  H UD D j  	Lzz~~H#NRUUCQGKL"#CD!K M		Ls1   X&X7X9 XX69	Z(AZ##Z(c                 B   ddddd| g}t        j                  |t         j                  t         j                  d      }|j                  r(t        d| d	|j                   d
|j                         	 dd l}d}t        j                  |       j                  d      D ]W  }|j                         s|j                  |      }t!        |D cg c]  }||v  c}      sAt#        dt%        |      d       y # t        $ r t        j                  d       Y y w xY wc c}w )Nz/usr/bin/codesignz--verifyz--all-architecturesz--deepz--strictutf8)stdoutstderrencodingzcodesign command (z) failed with error code z
!
output: r   zJxattr package not available; skipping verification of extended attributes!)zcom.apple.cs.CodeDirectoryzcom.apple.cs.CodeRequirementszcom.apple.cs.CodeRequirements-1zcom.apple.cs.CodeSignature*z5Code-sign attributes found in extended attributes of !)
subprocessrunPIPESTDOUT
returncodeSystemErrorr   xattrModuleNotFoundErrorr   r   r`   Pathrglobis_file	listxattranyrD   r1   )
bundle_dircmd_argspr   CODESIGN_ATTRSentry
file_attrscodesign_attrs           rP   r   zBUNDLE.verify_bundle_signature  s    (5JHV`blmNN8JOOJDUDU`fg<<$XJ.G~U`abaiai`jk "	

 \\*-33C8 	jE==?/J^TMMZ/TU #XY\]bYcXffg!hii	j # 	KKde	  Us   3C8 D
8DD)__name__
__module____qualname__r-   _GUTSrV   staticmethodr]   rg   r   r   r   __classcell__)rO   s   @rP   r   r   (   sc    ^@E
   
 
DfPJ9X )j )jrQ   r   )"r&   r`   r   r   r   PyInstallerr   r"   PyInstaller.building.apir   r   PyInstaller.building.datastructr   r   r   PyInstaller.building.utilsr	   r
   r   PyInstaller.compatr   r   PyInstaller.building.iconr   PyInstaller.utils.miscutilsmiscr?   PyInstaller.utils.osxosxr   rw   r$   r   rS   rQ   rP   <module>r      s^    
     & 1 I I ] ] = 9 * *,,  x
jV x
jrQ   