ó
    ¯iz  ã                   óŒ  • S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJr  SSKJr  SSKrSSKJr  SSKJr  \R<                  " \5      r S r!S r"S r#S	 r$S
 r%S r&S r'S\(S\)4S jr*S r+S r,S r-S r. " S S\/5      r0 " S S\/5      r1S r2S"S jr3S r4S"S jr5S r6S#S jr7S r8S r9S  r:S! r;g)$z
Utils for macOS platform.
é    N)ÚLC_BUILD_VERSIONÚLC_CODE_SIGNATUREÚLC_ID_DYLIBÚLC_LOAD_DYLIBÚLC_LOAD_UPWARD_DYLIBÚLC_LOAD_WEAK_DYLIBÚLC_PREBOUND_DYLIBÚLC_REEXPORT_DYLIBÚLC_RPATHÚLC_SEGMENT_64Ú	LC_SYMTABÚLC_UUIDÚLC_VERSION_MIN_MACOSX)ÚMachO)Úcompatc                  óp   • [        5       n U (       a%  [        R                  R                  U 5      (       a  gg)zs
Check if Python interpreter was installed via Homebrew command 'brew'.

:return: True if Homebrew else otherwise.
TF)Úget_homebrew_prefixr   Úbase_prefixÚ
startswith©Ú
env_prefixs    ÚBC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller/utils/osx.pyÚis_homebrew_envr   .   ó+   € ô %Ó&€JÞ”f×(Ñ(×3Ñ3°J×?Ñ?ØØó    c                  óp   • [        5       n U (       a%  [        R                  R                  U 5      (       a  gg)zs
Check if Python interpreter was installed via Macports command 'port'.

:return: True if Macports else otherwise.
TF)Úget_macports_prefixr   r   r   r   s    r   Úis_macports_envr   ;   r   r   c                  óª   • [         R                  " S5      n [        R                  R	                  [        R                  R	                  U 5      5      n U $ )z1
:return: Root path of the Homebrew environment.
Úbrew©ÚshutilÚwhichÚosÚpathÚdirname©Úprefixs    r   r   r   H   ó6   € ô �\Š\˜&Ó!€Fä�W‰W�_‰_œRŸW™WŸ_™_¨VÓ4Ó5€FØ€Mr   c                  óª   • [         R                  " S5      n [        R                  R	                  [        R                  R	                  U 5      5      n U $ )z1
:return: Root path of the Macports environment.
Úportr!   r'   s    r   r   r   R   r)   r   c                 óÐ   • U R                    Vs/ s H#  oS   R                  [        [        1;   d  M!  UPM%     nn[	        U5      S:X  d   S[	        U5       S35       eUS   $ s  snf )zB
Helper that finds the version command in the given MachO header.
r   é   zNExpected exactly one LC_BUILD_VERSION or LC_VERSION_MIN_MACOSX command, found Ú!)ÚcommandsÚcmdr   r   Úlen)Úheaderr0   Úversion_cmds      r   Ú_find_version_cmdr4   \   sq   € ð #)§/¢/Óm¢/˜3¸±V·Z±ZÔDTÔVkÐClÑ5l—3¡/€KÐmÜˆ{Ó˜qÓ ð mØ
XÔY\Ð]hÓYiÐXjÐjkÐlómÐ à�q‰>Ðùò ns
   � A#³A#c                 ó|   • [        U 5      nUR                  S   n[        U5      n[        US   R                  5      $ )zÉ
Obtain the version of macOS SDK against which the given binary was built.

NOTE: currently, version is retrieved only from the first arch slice in the binary.

:return: (major, minor, revision) tuple
r   r-   )r   Úheadersr4   Ú_hex_tripletÚsdk)ÚfilenameÚbinaryr2   r3   s       r   Úget_macos_sdk_versionr;   h   s:   € ô �8‹_€FØ�^‰^˜AÑ€Fä# FÓ+€KÜ˜ A™×*Ñ*Ó+Ð+r   c                 ó4   • U S-  S-	  nU S-  S-	  nU S-  nXU4$ )Ni  ÿ é   i ÿ  é   éÿ   © )ÚversionÚmajorÚminorÚrevisions       r   r7   r7   w   s4   € à�xÑ BÑ&€EØ�vÑ !Ñ#€EØ˜$‘€HØ˜Ð!Ð!r   r9   Úreturnc                 ó0  • / n[        U 5      R                   Hc  n[        U5      nUS   R                  [        :X  a   UR                  US   R                  5        ME  UR                  US   R                  5        Me     [        [        [        U5      5      $ )zq
Get the -macosx-version-min used to compile a macOS binary.

For fat binaries, the minimum version is selected.
r   r-   )r   r6   r4   r0   r   ÚappendrA   ÚminosÚminÚmapr7   )r9   Úversionsr2   r0   s       r   Úmacosx_version_minrL      sv   € ð €HÜ˜“/×)Ô)ˆÜ Ó'ˆØˆq‰6�:‰:Ô.Ó.Ø�O‰O˜C ™FŸN™NÖ+ð �O‰O˜C ™FŸL™LÖ)ñ *ô Œs”< Ó*Ó+Ð+r   c                 ó¤  • SUs=::  a  S::  d   S5       e   S5       eSUs=::  a  S::  d   S5       e   S5       eSUs=::  a  S::  d   S5       e   S5       e[        U 5      nUR                  S   n[        U5      nUS-  US-  -  U-  US   l        [	        UR
                  S	5       nUR                  U5        S
S
S
5        g
! , (       d  f       g
= f)zž
Overwrite the macOS SDK version declared in the given binary with the specified version.

NOTE: currently, only version in the first arch slice is modified.
r   r?   zInvalid major version value!zInvalid minor version value!zInvalid revision value!r=   r>   r-   úrb+N)r   r6   r4   r8   Úopenr9   Úwrite)r9   rB   rC   rD   r:   r2   r3   Úfps           r   Úset_macos_sdk_versionrR   ‘   sÚ   € ð �Õ˜ÓÐ<Ð<Ó<ÑÐ<Ð<Ó<ÐØ�Õ˜ÓÐ<Ð<Ó<ÑÐ<Ð<Ó<ÐØ�Õ˜CÓÐ:Ð!:Ó:ÑÐ:Ð!:Ó:Ðä�8‹_€FØ�^‰^˜AÑ€Fä# FÓ+€Kà "™ u°¡zÑ1°HÑ<€K��NÔä	ˆf�o‰o˜uÔ	%¨Ø�‰�RÔ÷ 
&×	%Ö	%ús   Â&CÃ
Cc                 ó¾  • [         R                  R                  U 5      n[        U 5      nUR                  S   nUR
                   Vs/ s H  oDS   R                  [        :X  d  M  UPM     nn[        U5      S:X  d   S5       eSnUR
                   Vs/ s H2  oDS   R                  [        :X  d  M  US   R                  U:X  d  M0  UPM4     nn[        U5      S:X  d   S5       eUS   S   nUR
                   Vs/ s H  oDS   R                  [        :X  d  M  UPM     nn[        U5      S:X  d   S5       eUS   S   nXR                  UR                  -   -
  Ul        XR                  UR                  -   -
  Ul        [#        UR$                  5      R'                  S5      (       a  S	OS
n	[(        R*                  " UR                   U	-  5      U	-  Ul        [/        U S5       n
UR1                  U
5        SSS5        UR2                  (       Ga  SSKJnJnJnJnJn  [/        U S5       n
URA                  U
5      nURB                  U:X  a5  [E        URF                  5       Vs/ s H  nURA                  U
5      PM     nnODURB                  U:X  a4  [E        URF                  5       Vs/ s H  nURA                  U
5      PM     nnWS   nUUR                  -
  Ul$        U
RK                  S5        URM                  U
5        U H  nURM                  U
5        M     SSS5        ggs  snf s  snf s  snf ! , (       d  f       GND= fs  snf s  snf ! , (       d  f       g= f)aÞ  
Fixes the Mach-O headers to make code signing possible.

Code signing on macOS does not work out of the box with embedding .pkg archive into the executable.

The fix is done this way:
- Make the embedded .pkg archive part of the Mach-O 'String Table'. 'String Table' is at end of the macOS exe file,
  so just change the size of the table to cover the end of the file.
- Fix the size of the __LINKEDIT segment.

Note: the above fix works only if the single-arch thin executable or the last arch slice in a multi-arch fat
executable is not signed, because LC_CODE_SIGNATURE comes after LC_SYMTAB, and because modification of headers
invalidates the code signature. On modern arm64 macOS, code signature is mandatory, and therefore compilers
create a dummy signature when executable is built. In such cases, that signature needs to be removed before this
function is called.

Mach-O format specification: http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/Mach-O.5.html
éÿÿÿÿr   z#Executable contains code signature!s   __LINKEDIT      r-   z(Expected exactly one __LINKEDIT segment!z$Expected exactly one SYMTAB section!Úarm64i @  i   rN   N)Ú	FAT_MAGICÚFAT_MAGIC_64Úfat_archÚ
fat_arch64Ú
fat_header)'r$   r%   Úgetsizer   r6   r/   r0   r   r1   r   Úsegnamer   ÚoffsetÚstroffÚstrsizeÚfileoffÚfilesizeÚ_get_arch_stringr2   r   ÚmathÚceilÚvmsizerO   rP   ÚfatÚmacholib.mach_orV   rW   rX   rY   rZ   Úfrom_fileobjÚmagicÚrangeÚ	nfat_archÚsizeÚseekÚ
to_fileobj)r9   Ú	file_sizeÚ
executabler2   r0   Úsign_secÚ__LINKEDIT_NAMEÚlinkedit_segÚ
symtab_secÚ	page_sizerQ   rV   rW   rX   rY   rZ   rf   ÚiÚarchsÚarchs                       r   Úfix_exe_for_code_signingry   §   sÞ  € ô( —‘—‘ Ó)€Iô �x“€JØ×Ñ Ñ#€Fð  &ŸšÓRš˜°a±&·*±*Ô@QÑ2Q—™€HÐRÜˆx‹=˜AÓÐDÐDÓDÐð <€OØ#)§?¢?Óx¢?˜C¸!±f·j±jÄMÑ6Q“CÐVYÐZ[ÑV\×VdÑVdÐhwÑVw—C¡?€LÐxÜˆ|Ó Ó!ÐMÐ#MÓMÐ!Ø ‘? 1Ñ%€Là!'§¢ÓL¢˜#¸±F·J±JÄ)Ñ4K—#¡€JÐLÜˆz‹?˜aÓÐGÐ!GÓGÐØ˜A‘˜qÑ!€Jð  #§m¡m°j×6GÑ6GÑ&GÑH€JÔØ%¯©¸×9MÑ9MÑ)MÑN€LÔô ,¨F¯M©MÓ:×EÑEÀg×NÑN‘ÐTZ€IÜŸ)š) L×$9Ñ$9¸IÑ$EÓFÈÑR€LÔô 
ˆh˜Ô	 "Ø×Ñ˜Ô÷ 
ð
 ‡~‡~€~ß_Õ_Ü�(˜EÔ" bð ×)Ñ)¨"Ó-ˆCØ�y‰y˜IÓ%Ü<AÀ#Ç-Á-Ô<PÓQÒ<P°q˜×.Ñ.¨rÖ2Ñ<P�ÐQ�Ø—‘˜lÓ*Ü>CÀCÇMÁMÔ>RÓSÒ>R¸˜×0Ñ0°Ö4Ñ>R�ÐSà˜‘9ˆDØ! D§K¡KÑ/ˆDŒIà�G‰G�AŒJØ�N‰N˜2ÔÛ�Ø—‘ Ö#ñ ÷ #Ð"ð ùòY Sùò
 yùò M÷< 
Ö	üò RùâS÷ #Õ"úsa   ÁL#Á&L#ÂL(Â2L(ÃL(Ã;L-ÄL-Ç#L2È)9MÉ"MÉ=*MÊ'M	ËAMÌ2
MÍ
MÍ
Mc                 óŒ   • U R                   nU R                  S-  nUS:X  a  US:X  a  ggUS:X  a  US:X  a  gg	US
:X  a  g S5       e)z­
Converts cputype and cpusubtype from mach_o.mach_header_64 into arch string comparible with lipo/codesign.
The list of supported architectures can be found in man(1) arch.
iÿÿÿi  r>   Úx86_64hÚx86_64i  é   Úarm64erU   é   Úi386zUnhandled architecture!)ÚcputypeÚ
cpusubtype)r2   r�   r‚   s      r   rb   rb     s\   € ð �n‰n€GØ×"Ñ" ZÑ/€JØ�.Ó Ø˜‹?ØàØ	�OÓ	#Ø˜‹?ØàØ	�A‹ØØ+Ð+Ó+ˆ5r   c                 ó¼  ^• SSK nUR                  5       n[        US5       m[        U4S jS5       H  nUR	                  U5        M     SSS5        [        U 5      nUR                   H¢  nUR                   Vs/ s H  owS   R                  [        :X  d  M  UPM     nnU(       d  M@  US   nUS   R                  n	UR                  5       n
U
R	                  U	5        U
R                  5       SS n[        U5      S:X  d   eX¸S   l
        M¤     [        U S5       mUR                  T5        SSS5        g! , (       d  f       Nò= fs  snf ! , (       d  f       g= f)	a7  
Modifies the Mach-O image UUID stored in the LC_UUID command (if present) in order to ensure that different
frozen applications have different identifiers. See TN3178 for details on why this is required:
https://developer.apple.com/documentation/technotes/tn3178-checking-for-and-resolving-build-uuid-problems
r   NÚrbc                  ó&   >• T R                  S5      $ )Ni    )Úread)rQ   s   €r   Ú<lambda>Ú'update_exe_identifier.<locals>.<lambda>&  s   ø€  "§'¡'¨$¤-r   r   r-   r=   rN   )ÚhashlibÚsha1rO   ÚiterÚupdater   r6   r/   r0   r   ÚuuidÚcopyÚdigestr1   rP   )r9   Úpkg_filenamer‰   Úpkg_hashÚchunkrp   r2   r0   Úuuid_cmdÚoriginal_uuidÚcombined_hashÚnew_uuidrQ   s               @r   Úupdate_exe_identifierr—     s)  ø€ ó Ø�|‰|‹~€HÜ	ˆl˜DÔ	! RÜÔ/°Ö5ˆEØ�O‰O˜EÖ"ñ 6÷ 
"ô
 �x“€JØ×$Ô$ˆà#)§?¢?ÓL¢?˜C¸!±f·j±jÄGÑ6K—C¡?ˆÐLÞÙØ˜A‘;ˆð ! ™×(Ñ(ˆð
 !Ÿ™›ˆØ×Ñ˜]Ô+à ×'Ñ'Ó)¨#¨2Ð.ˆÜ�8‹} Ó"Ð"Ð"à#�‰Öñ' %ô, 
ˆh˜Ô	 "Ø×Ñ˜Ô÷ 
Ð	÷9 
"Õ	!üò M÷( 
Õ	ús#   ¢)D7Á;EÂEÄEÄ7
EÅ
Ec                   ó   • \ rS rSrSrSrg)ÚInvalidBinaryErroriE  zU
Exception raised by `get_binary_architectures` when it is passed an invalid binary.
r@   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r@   r   r   r™   r™   E  s   † ñò 	r   r™   c                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )ÚIncompatibleBinaryArchErroriL  zi
Exception raised by `binary_to_target_arch` when the passed binary fails the strict architecture check.
c                 ó2   >• Sn[         TU ]  U SU 35        g )NzMhttps://pyinstaller.org/en/stable/feature-notes.html#macos-multi-arch-supportz, For details about this error message, see: )ÚsuperÚ__init__)ÚselfÚmessageÚurlÚ	__class__s      €r   r¤   Ú$IncompatibleBinaryArchError.__init__P  s#   ø€ Ø]ˆÜ‰Ñ˜G˜9Ð$PÐQTÐPUÐVÕWr   r@   )rš   r›   rœ   r�   rž   r¤   rŸ   Ú__classcell__)r¨   s   @r   r¡   r¡   L  s   ø† ñ÷Xó Xr   r¡   c                 óê   •  [        U 5      n[        UR                  5      UR
                   Vs/ s H  n[        UR                  5      PM     sn4$ ! [         a  n[        S5      UeSnAff = fs  snf )z¹
Inspects the given binary and returns tuple (is_fat, archs), where is_fat is boolean indicating fat/thin binary,
and arch is list of architectures with lipo/codesign compatible names.
zInvalid Mach-O binary!N)r   Ú
ValueErrorr™   Úboolrf   r6   rb   r2   )r9   rp   ÚeÚhdrs       r   Úget_binary_architecturesr°   U  sl   € ð
BÜ˜8“_ˆ
ô �
—‘ÓÈ*×J\ÒJ\Ó!]ÒJ\À3Ô"2°3·:±:Ö">ÑJ\Ñ!]Ð]Ð]øô ó BÜ Ð!9Ó:ÀÐAûðBüâ!]s   ‚A ¯A0Á
A-ÁA(Á(A-c                 ó   • U=(       d    U nSSXSU/n[         R                  " U[         R                  [         R                  SS9nUR                  (       a(  [        SU SUR                   SUR                   35      eg	)
zT
Convert the given fat binary into thin one with the specified target architecture.
Úlipoz-thinú-outputúutf-8©ÚstdoutÚstderrÚencodingúlipo command (ú) failed with error code ú
!
output: N©Ú
subprocessÚrunÚPIPEÚSTDOUTÚ
returncodeÚSystemErrorr¶   )r9   Ú	thin_archÚoutput_filenameÚcmd_argsÚps        r   Úconvert_binary_to_thin_archrÇ   a  su   € ð &×1¨€OØ˜ °iÀÐQ€HÜ�Š�x¬
¯©Ä
×@QÑ@QÐ\cÑd€AØ‡|‡|Ü˜N¨8¨*Ð4MÈaÏlÉlÈ^Ð[fÐgh×goÑgoÐfpÐqÓrÐrð r   c                 óì   • SSSU /UQn[         R                  " U[         R                  [         R                  SS9nUR                  (       a(  [        SU SUR                   SUR                   35      eg	)
zB
Merge the given single-arch thin binary files into a fat binary.
r²   z-creater³   r´   rµ   r¹   rº   r»   Nr¼   )rÄ   Úslice_filenamesrÅ   rÆ   s       r   Úmerge_into_fat_binaryrÊ   l  sn   € ð ˜	 9¨oÐPÀÐP€HÜ�Š�x¬
¯©Ä
×@QÑ@QÐ\cÑd€AØ‡|‡|Ü˜N¨8¨*Ð4MÈaÏlÉlÈ^Ð[fÐgh×goÑgoÐfpÐqÓrÐrð r   c                 ó   • U(       d  U n[        U 5      u  p4US:X  a  U(       d  [        U S35      eg
U(       a9  X;  a  [        U SU S35      e[        R                  SXU5        [	        X5        g
X;  a  [        U SU SUS    S	35      eg
)z}
Check that the given binary contains required architecture slice(s) and convert the fat binary into thin one,
if necessary.
Ú
universal2z is not a fat binary!z does not contain slice for r.   z1Converting fat binary %s (%s) to thin binary (%s)z" is incompatible with target arch z (has arch: r   z)!N)r°   r¡   ÚloggerÚdebugrÇ   )r9   Útarget_archÚdisplay_nameÚis_fatrw   s        r   Úbinary_to_target_archrÒ   v  sµ   € ö
 Øˆä,¨XÓ6�M€FØ�lÓ"ÞÜ-°°Ð>SÐ.TÓUÐUð ö ØÓ'Ü1°\°NÐB^Ð_jÐ^kÐklÐ2mÓnÐnä�L‰LÐLÈhÐfqÔrÜ'¨Õ>àÓ'Ü1Ø#�nÐ$FÀ{ÀmÐS_Ð`eÐfgÑ`hÐ_iÐikÐlóð ð (r   c                 ó  • [         R                  SU 5        SSSU /n[        R                  " U[        R                  [        R
                  SS9nUR                  (       a(  [        SU SUR                   S	UR                   35      eg
)zh
Remove the signature from all architecture slices of the given binary file using the codesign utility.
zRemoving signature from file %rú/usr/bin/codesignz--removeú--all-architecturesr´   rµ   úcodesign command (rº   r»   N)	rÍ   rÎ   r½   r¾   r¿   rÀ   rÁ   rÂ   r¶   )r9   rÅ   rÆ   s      r   Úremove_signature_from_binaryr×   ’  s~   € ô ‡L�LÐ2°HÔ=Ø# ZÐ1FÈÐQ€HÜ�Š�x¬
¯©Ä
×@QÑ@QÐ\cÑd€AØ‡|‡|ÜÐ.¨x¨jÐ8QÐRS×R^ÑR^ÐQ_Ð_jÐkl×ksÑksÐjtÐuÓvÐvð r   c                 óÜ  • / nU(       d  SnOUR                  S5        U(       a"  UR                  S5        UR                  U5        U(       a  UR                  S5        [        R                  SU 5        SSUSS	S
/UQU Pn[        R                  " U[        R
                  [        R                  SS9nUR                  (       a(  [        SU SUR                   SUR                   35      eg)zb
Sign the binary using codesign utility. If no identity is provided, ad-hoc signing is performed.
Ú-z--options=runtimez--entitlementsz--deepzSigning file %rrÔ   z-sz--forcerÕ   z--timestampr´   rµ   rÖ   rº   r»   N)
rG   rÍ   rÎ   r½   r¾   r¿   rÀ   rÁ   rÂ   r¶   )r9   ÚidentityÚentitlements_fileÚdeepÚ
extra_argsrÅ   rÆ   s          r   Úsign_binaryrÞ   �  sä   € ð €JÞØ‰à×ÑÐ-Ô.ÞØ×ÑÐ*Ô+Ø×ÑÐ+Ô,ÞØ×Ñ˜(Ô#ä
‡L�LÐ" HÔ-à˜T 8¨YÐ8MÈ}ðØ_iðØksð€Hô 	�Š�x¬
¯©Ä
×@QÑ@QÐ\cÑd€AØ‡|‡|ÜÐ.¨x¨jÐ8QÐRS×R^ÑR^ÐQ_Ð_jÐkl×ksÑksÐjtÐuÓvÐvð r   c                 óZ  • [        U 5      u  p#U(       a{  [        R                  " 5        n/ nU HH  n[        R                  R                  XF5      n[        XUS9  [        Xq5        UR                  U5        MJ     [        U /UQ76   SSS5        g[        X5        g! , (       d  f       g= f)aÅ  
Modify the given dylib's identity (in LC_ID_DYLIB command) and the paths to dependent dylibs (in LC_LOAD_DYLIB)
commands into `@rpath/<basename>` format, remove any existing rpaths (LC_RPATH commands), and add a new rpath
(LC_RPATH command) with the specified path.

Uses `install-tool-name` utility to make the changes.

The system libraries (e.g., the ones found in /usr/lib) are exempted from path rewrite.

For multi-arch fat binaries, this function extracts each slice into temporary file, processes it separately,
and then merges all processed slices back into fat binary. This is necessary because `install-tool-name` cannot
modify rpaths in cases when an existing rpath is present only in one slice.
)rÄ   N)
r°   ÚtempfileÚTemporaryDirectoryr$   r%   ÚjoinrÇ   Ú_set_dylib_dependency_pathsrG   rÊ   )r9   Útarget_rpathrÑ   rw   ÚtmpdirrÉ   rx   Úslice_filenames           r   Úset_dylib_dependency_pathsrç   µ  sŒ   € ô$ -¨XÓ6�M€FæÜ×(Ò(Ô*¨fØ ˆOÛ�Ü!#§¡§¡¨fÓ!;�Ü+¨HÈNÒ[Ü+¨NÔIØ×&Ñ& ~Ö6ñ	 ô
 " (Ð=¨_Ó=÷ +Ð*ô 	$ HÕ;÷ +Õ*ús   ªABÂ
B*c                 ó�  • [         [        [        [        [        1n[        U 5      nSn[        5       n[        5       nUR                   H¢  nUR                   H�  nUS   R                  n	X’;  a  U	[        [        1;  a  M)  US   R                  S5      R                  S5      n
X’;   a  UR                  U
5        Md  U	[        :X  a  UR                  U
5        M�  U	[        :X  d  M�  U
nM‘     M¤     ASnU(       a@  [        [         R"                  " S5      [         R"                  " U5      R$                  -  5      n/ nSnU H°  n[&        R(                  R+                  U5      (       a  M)  SS	/n[-        U Vs/ s H  nUU;   PM
     sn5      (       a  MS  S
n[        [         R"                  " S5      [         R"                  " U5      R$                  -  5      nUU:X  a  M�  UR/                  UU45        M²     / nU(       a  X´:w  a  USU/-  nU H  u  nnUSUU/-  nM     U H  nUU:X  a  M  USU/-  nM     U(       a  X;  a  USU/-  nU(       d  gS/UQU Pn[0        R2                  " U[0        R4                  [0        R6                  SS9nUR8                  (       a(  [;        SU SUR8                   SUR<                   35      egs  snf )z…
The actual implementation of set_dylib_dependency_paths functionality.

Implicitly assumes that a single-arch thin binary is given.
Nr   r}   r´   Ú z@rpathFz"/Library/Frameworks/Tcl.framework/z!/Library/Frameworks/Tk.framework/Tz-idz-changez-delete_rpathz
-add_rpathÚinstall_name_toolrµ   zinstall_name_tool command (rº   r»   )r   r   r   r	   r
   r   Úsetr6   r/   r0   r   r   ÚdecodeÚrstripÚaddÚstrÚpathlibÚPurePathÚnameÚmacholibÚutilÚin_system_pathÚanyrG   r½   r¾   r¿   rÀ   rÁ   rÂ   r¶   )r9   rä   Ú_RELOCATABLEr:   Údylib_idÚrpathsÚlinked_libsr2   r0   Úlc_typer%   Únormalized_dylib_idÚchanged_lib_pathsÚrpath_requiredÚ
linked_libÚ_exemptionsÚxÚnew_pathÚinstall_name_tool_argsÚoriginal_pathÚrpathrÅ   rÆ   s                          r   rã   rã   ×  sÉ  € ô 	ÜÜÜÜð€Lô �8‹_€Fà€HÜ‹U€FÜ“%€Kà—.”.ˆØ—?”?ˆCØ˜!‘f—j‘jˆGØÓ*¨w¼xÌÐ>UÓ/UÙð �q‘6—=‘= Ó)×0Ñ0°Ó8ˆDàÓ&Ø—‘ Ö%ØœHÓ$Ø—
‘
˜4Ö ØœKÕ'Ø’ó #ñ !ð  	ð ÐÞÜ!¤'×"2Ò"2°8Ó"<¼w×?OÒ?OÐPXÓ?Y×?^Ñ?^Ñ"^Ó_Ðð
 ÐØ€NÛ!ˆ
ä�=‰=×'Ñ'¨
×3Ñ3Ùð 1Ø/ð
ˆô ©Ó5ª A��Z”©Ñ5×6Ñ6Ùð ˆä”w×'Ò'¨Ó1´G×4DÒ4DÀZÓ4P×4UÑ4UÑUÓVˆØ˜Ó!Ùà× Ñ  *¨hÐ!7Ö8ñ1 "ð6  Ðö Ð2Ó>Ø 5Ð*=Ð">Ñ>Ðó $5Ñˆ�xØ 9¨m¸XÐ"FÑFÒñ $5ó
 ˆØ�LÓ ÙØØØð#
ñ 	
Òñ ö ˜,Ó4ØØØð#
ñ 	
Ðö "Øð $ÐGÐ&<ÐG¸hÐG€HÜ�Š�x¬
¯©Ä
×@QÑ@QÐ\cÑd€AØ‡|‡|ÜØ)¨(¨Ð3LÈQÏ\É\ÈNÐZeÐfg×fnÑfnÐeoÐpó
ð 	
ð ùòa 6s   Å5K
c                 óò   • [         R                  " U 5      n U R                  R                  R                  S:w  a  gU R                  R                  R                  R                  U R                  S-   :w  a  gg)zC
Check if the given shared library is part of a .framework bundle.
ÚVersionsFz
.frameworkT)rð   rñ   Úparentrò   )Úlib_paths    r   Úis_framework_bundle_libr
  Q  s^   € ô
 ×Ò Ó)€Hð ‡�×Ñ×"Ñ" jÓ0ØØ‡�×Ñ×$Ñ$×)Ñ)¨X¯]©]¸\Ñ-IÓIØàr   c           
      ó”  • Sn[        5       n[        5       nU  GHO  u  pEnUS:w  a  M  [        R                  " U5      n[        R                  " U5      n[	        U5      (       d  MM  [	        U5      (       d  M_  UR
                  S-  S-  n	U	R                  5       (       dœ  UR
                  R
                  R
                  S-  S-  n
U
R                  5       (       d_  SnUR
                  R
                  R
                  n[        R                  (       a  [        SU S35      e[        R                  SU5        GM   U
n	UR
                  S-  S-  nUR                  [        U5      [        U	5      S	45        UR                  [        UR
                  R
                  S
-  5      [        UR
                  R                  5      S45        UR
                  R
                  R
                  nUR                  [        XØR                  -  5      [        [        R                  " S5      UR                  -  5      S45        UR                  [        US-  5      SS45        UR                  U5        GMR     SS1nU H›  nU  H’  u  pEn[        R                  " U5      n UR                  U5      nUR"                  nUS   S:w  a  ME  US   nUU;  a  MR  UR                  [        UU-  5      [        [        R                  " S5      U-  5      S45        M”     M�     U(       a  [        R                  S5        [%        U5      $ ! [          a     MÎ  f = f)aä  
Scan the given TOC list of collected files for shared libraries that are collected from macOS .framework bundles,
and collect the bundles' Info.plist files. Additionally, the following symbolic links:
  - `Versions/Current` pointing to the `Versions/<version>` directory containing the binary
  - `<name>` in the top-level .framework directory, pointing to `Versions/Current/<name>`
  - `Resources` in the top-level .framework directory, pointing to `Versions/Current/Resources`
  - additional directories in top-level .framework directory, pointing to their counterparts in `Versions/Current`
    directory.

Returns TOC list for the discovered Info.plist files and generated symbolic links. The list does not contain
duplicated entries.
FÚBINARYÚ	Resourcesz
Info.plistTzCould not find Info.plist in r.   z Could not find Info.plist in %s!ÚDATAÚCurrentÚSYMLINKzVersions/CurrentzVersions/Current/ResourcesÚHelpersr   r  r}   zœOne or more collected .framework bundles have missing Info.plist file. If you are building an .app bundle, you will most likely not be able to code-sign it.)rë   rð   ÚPathrñ   r
  r  Úis_filer   Ústrict_collect_moderÂ   rÍ   Úwarningrî   rï   rò   Úrelative_tor¬   ÚpartsÚsorted)Úcollected_filesÚinvalid_framework_foundÚframework_filesÚframework_pathsÚ	dest_nameÚsrc_nameÚtypecodeÚsrc_pathÚ	dest_pathÚinfo_plist_srcÚinfo_plist_src_topÚframework_dirÚinfo_plist_destÚdest_framework_pathÚVALID_SUBDIRSÚremaining_pathÚremaining_path_partsÚdir_names                     r   Ú$collect_files_from_framework_bundlesr+  a  s  € ð $Ðä“e€OÜ“e€Oô *9Ñ%ˆ	˜XØ�xÓÙä—<’< Ó)ˆÜ×$Ò$ YÓ/ˆ	ô ' x×0Ñ0Ùô ' y×1Ñ1Ùð "Ÿ™¨;Ñ6¸ÑEˆØ×%Ñ%×'Ñ'ð "*§¡×!7Ñ!7×!>Ñ!>ÀÑ!LÈ|Ñ![ÐØ%×-Ñ-×/Ñ/ð +/Ð'Ø (§¡× 6Ñ 6× =Ñ =�Ü×-×-Ü%Ð(EÀmÀ_ÐTUÐ&VÓWÐWä—N‘NÐ#EÀ}ÔUÚØ/ˆNØ#×*Ñ*¨[Ñ8¸<ÑGˆØ×ÑœS Ó1´3°~Ó3FÈÐOÔPð
 	×ÑœS ×!1Ñ!1×!8Ñ!8¸9Ñ!DÓEÄsÈ9×K[ÑK[×K`ÑK`ÓGaÐclÐmÔnà'×.Ñ.×5Ñ5×<Ñ<Ðð 	×ÑÜÐ#§n¡nÑ4Ó5Ü”× Ò Ð!3Ó4°y·~±~ÑEÓFØð
ô 	ð 	×ÑÜÐ# kÑ1Ó2Ø(Øð
ô 	ð 	×ÑÐ/×0ñ{ *9ðD  Ð,€Mã.ÐÛ-<Ñ)ˆI Ü×(Ò(¨Ó3ˆIðØ!*×!6Ñ!6Ð7JÓ!K�ð $2×#7Ñ#7Ð ð $ AÑ&¨*Ó4Ùð ,¨AÑ.ˆHØ˜}Ó,Ùà×ÑÜÐ'¨(Ñ2Ó3Ü”G×$Ò$Ð%7Ó8¸8ÑCÓDØð!ö ó) .=ñ  /ö: Ü�‰ðHô	
ô
 �/Ó"Ð"øô9 ó Úðús   ÊL9Ì9
MÍM)N)NNF)<rž   rc   r$   rð   r½   r"   rà   rg   r   r   r   r   r   r   r	   r
   r   r   r   r   r   Úmacholib.MachOr   Úmacholib.utilró   ÚPyInstaller.logÚlogÚloggingÚPyInstallerr   Ú	getLoggerrš   rÍ   r   r   r   r   r4   r;   r7   rï   ÚtuplerL   rR   ry   rb   r—   Ú	Exceptionr™   r¡   r°   rÇ   rÊ   rÒ   r×   rÞ   rç   rã   r
  r+  r@   r   r   Ú<module>r5     sò   ðñó Û 	Û Û Û Û ÷÷ ÷ õ õ !Û å !Ý à	×	Ò	˜8Ó	$€ò
ò
òòò	ò,ò"ð, ð ,¨ô ,ò$ò,Z$òz,ò.'ôT	˜ô 	ôX )ô Xò	^ôsòsôò8wôwò0<òDw
òtó ~#r   