ó
    F\hV  ã                   óº   • S r SSKrSSKrSSKr/ SQrSrSrSrSS jrSS jr	S	 r
SqS
 rSqS rS rS rSqS rS rS rS rS rS rS rS rS rS rS rS rg)zShared OS X support functions.é    N)Úcompiler_fixupÚcustomize_config_varsÚcustomize_compilerÚget_platform_osx)ÚCFLAGSÚLDFLAGSÚCPPFLAGSÚ
BASECFLAGSÚ	BLDSHAREDÚLDSHAREDÚCCÚCXXÚ	PY_CFLAGSÚ
PY_LDFLAGSÚPY_CPPFLAGSÚPY_CORE_CFLAGSÚPY_CORE_LDFLAGS)r   r   r   r   Ú_OSX_SUPPORT_INITIAL_c                 óÚ  • Uc  [         R                  S   nUR                  [         R                  5      n[         R                  R                  U 5      u  p4[        R                  S:X  a  US:w  a  U S-   n [         R                  R                  U 5      (       dQ  U HJ  n[         R                  R                  XP5      n[         R                  R                  U5      (       d  MH  Us  $    gU $ )zÎTries to find 'executable' in the directories listed in 'path'.

A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH'].  Returns the complete filename or None if not found.
NÚPATHÚwin32z.exe)
ÚosÚenvironÚsplitÚpathsepÚpathÚsplitextÚsysÚplatformÚisfileÚjoin)Ú
executabler   ÚpathsÚbaseÚextÚpÚfs          Ú#/usr/lib/python3.13/_osx_support.pyÚ_find_executabler)      s­   € ð �|Ü�z‰z˜&Ñ!ˆà�J‰J”r—z‘zÓ"€EÜ—‘× Ñ  Ó,�I€Dä�‰˜Ó c¨V£mØ &Ñ(ˆ
ä�7‰7�>‰>˜*×%Ñ%ÛˆAÜ—‘—‘˜QÓ+ˆAÜ�w‰w�~‰~˜a× Ó à’ñ	 ð
 àÐó    c                 óæ  • SSK n SSKnUR                  5       nUR                  U5       nU(       a  U < SUR                  < S3nOU < SUR                  < S3n[
        R                  " U5      (       d-  UR                  5       R                  S	5      R                  5       OSsSSS5        $ ! [         a&    [	        S[
        R                  " 5       < 3S5      n NÄf = f! , (       d  f       g= f)
z0Output from successful command execution or Noner   Nz/tmp/_osx_support.zw+bz >'z' 2>&1z 2>/dev/null >'Ú'úutf-8)Ú
contextlibÚtempfileÚNamedTemporaryFileÚImportErrorÚopenr   ÚgetpidÚclosingÚnameÚsystemÚreadÚdecodeÚstrip)ÚcommandstringÚcapture_stderrr.   r/   ÚfpÚcmds         r(   Ú_read_outputr>   7   s¶   € ó ð"ÛØ×(Ñ(Ó*ˆð
 
×	Ñ	˜BÔ	 2ÞÛ%2°B·G´GÐ<‰Cã,9¸2¿7¼7ÐCˆCÜ8:¿	º	À#¿¹ˆr�w‰w‹y×Ñ Ó(×.Ñ.Ô0ÈD÷ 
 Ñ	øô	 ó "ÝÜ�IŠI�KðØ ó"Šð"ú÷ 
 Õ	ús   †B/ «A:C"Â/-CÃCÃ"
C0c                 óV   • [        U 5      =(       d    [        SU < 35      =(       d    S$ )z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find Ú )r)   r>   )Útoolnames    r(   Ú_find_build_toolrB   M   s'   € ä˜XÓ&÷ ÝºXÐ GÓH÷àðr*   c                  ól  • [         c~  Sq  [        SSS9n  [        R                  " SU R	                  5       5      nU R                  5         Ub2  SR                  UR                  S5      R                  S5      SS	 5      q [         $ [         $ ! U R                  5         f = f! [         a     [         $ f = f)
z*Return the OS X system version as a stringNr@   z0/System/Library/CoreServices/SystemVersion.plistr-   )Úencodingz=<key>ProductUserVisibleVersion</key>\s*<string>(.*?)</string>Ú.é   é   )
Ú_SYSTEM_VERSIONr2   ÚreÚsearchr7   Úcloser!   Úgroupr   ÚOSError)r'   Úms     r(   Ú_get_system_versionrO   V   s´   € ô ÑØˆð	FÜÐGÐRYÑZˆAðÜ—I’Ið 8Ø9:¿¹»óC�ð —‘”	Ø‰}Ø"%§(¡(¨1¯7©7°1«:×+;Ñ+;¸CÓ+@ÀÀ!Ð+DÓ"E�ô ÐŒ?Ðøð —‘•	ûô ó 	ð ô Ðð	ús   ‹
B! –%B ÂBÂ!
B3Â2B3c                  ó¼   • [         c9  [        5       n U (       a(   [        S U R                  S5       5       5      q [         $ [         $ ! [         a
    Sq  [         $ f = f)zm
Return the macOS system version as a tuple

The return value is safe to use to compare
two version numbers.
c              3   ó8   #   • U  H  n[        U5      v •  M     g 7f©N©Úint©Ú.0Úis     r(   Ú	<genexpr>Ú,_get_system_version_tuple.<locals>.<genexpr>�   s   é € Ð-UÒ>T¸¬c°!¯f¨fÒ>Tùó   ‚rE   © )Ú_SYSTEM_VERSION_TUPLErO   Útupler   Ú
ValueError©Úosx_versions    r(   Ú_get_system_version_tuplera   u   sb   € ô Ñ$Ü)Ó+ˆÞð+Ü(-Ñ-U¸k×>OÑ>OÐPSÔ>TÓ-UÓ(UÐ%ô !Ð Ô Ð øô ó +Ø(*Ñ%ä Ð ð+ús   š!A ÁAÁAc                 ód   • [        U 5       H!  nUR                  [        5      (       d  M  X	 M#     g)z-Remove original unmodified values for testingN)ÚlistÚ
startswithÚ_INITPRE)Ú_config_varsÚks     r(   Ú_remove_original_valuesrh   ˆ   s'   € ô �,ÖˆØ�<‰<œ×!Ó!Ø’ò  r*   c                 ój   • U R                  US5      nX2:w  a  [        U-   U ;  a  X0[        U-   '   X U'   g)z@Save modified and original unmodified value of configuration varr@   N)Úgetre   )rf   ÚcvÚnewvalueÚoldvalues       r(   Ú_save_modified_valuern   �   s;   € ð ×Ñ  BÓ'€HØÓ¤8¨b¡=¸Ó#DØ&.”X ‘]Ñ#Ø�Òr*   c                 ót  • [         b  [         $ [        U < S3S5      nSnUR                  5        Hw  nUR                  S5      (       a  SnM  UR                  S5      (       a  SnM7  U(       d  M@  UR	                  5       nUS:X  a  Sq MZ  UR                  S	5      (       d  Mr  USS
 q My     [         c  Sq [         $ )z<Returns the root of the default SDK for this system, or '/' Nz -c -E -v - </dev/nullTFz#include <...>zEnd of search listz/usr/includeÚ/z.sdk/usr/includeiôÿÿÿ)Ú_cache_default_sysrootr>   Ú
splitlinesrd   r9   Úendswith)ÚccÚcontentsÚ
in_incdirsÚlines       r(   Ú_default_sysrootrx   ™   s¯   € ô Ñ)Ü%Ð%ä»"Ð>ÀÓE€HØ€JØ×#Ñ#Ö%ˆØ�?‰?Ð+×,Ñ,ØŠJØ�_‰_Ð1×2Ñ2ØŠJßˆZØ—:‘:“<ˆDØ�~Ó%Ø),Ò&Ø—‘Ð1×2Ó2Ø)-¨d¨s¨Ò&ñ &ô Ñ%Ø!$Ðä!Ð!r*   c                  óD   • [        5       n U (       a  [        U S:¬  5      $ S$ )z=Returns True if universal builds are supported on this system©é
   é   F)ra   Úboolr_   s    r(   Ú_supports_universal_buildsr~   ²   s#   € ô ,Ó-€KÞ+6Œ4�˜wÑ&Ó'ÐA¸EÐAr*   c                  ó2   • [        5       n U (       a  U S:¬  $ S$ )z9Returns True if arm64 builds are supported on this system)é   r   F)ra   r_   s    r(   Ú_supports_arm64_buildsr�   ¼   s   € ô ,Ó-€KÞ%0ˆ;˜'Ñ!Ð;°eÐ;r*   c                 ój  • S[         R                  ;   a  U $ U S   R                  5       S   =p[        U5      (       d  [	        S5      nOk[         R
                  R                  U5      R                  S5      (       a8  [        SUR                  SS5      < S35      nU(       a  SU;   a  [	        S5      nU(       d  [        S	5      eX:w  ag  [         H]  nX@;   d  M
  U[         R                  ;  d  M   X   R                  5       nUS
:w  a  UOUS-   US'   [        XSR                  U5      5        M_     U $ )z7Find appropriate C compiler for extension module buildsr   r   ÚclangÚgccr,   ú'"'"'z' --versionzllvm-gcczCannot locate working compilerr   z++Ú )r   r   r   r)   rB   r   Úbasenamerd   r>   ÚreplaceÚSystemErrorÚ_COMPILER_CONFIG_VARSrn   r!   )rf   rt   ÚoldccÚdatark   Úcv_splits         r(   Ú_find_appropriate_compilerrŽ   Æ   s  € ð" Œr�z‰zÓØÐð ˜dÑ#×)Ñ)Ó+¨AÑ.Ð.€BÜ˜B×Ñô ˜gÓ&‰ä	�‰×	Ñ	˜"Ó	×	(Ñ	(¨×	/Ñ	/åØ "§
¡
¨3°	Ö :ð=ó >ˆæ�J $Ó&ä! 'Ó*ˆBæÜØ/ó1ð 	1ð 
ƒ{÷ (ˆBØÕ! b´·
±
Õ&:Ø'Ñ+×1Ñ1Ó3�Ø$&¨%£K™b°R¸$±Y�˜‘Ü$ \°s·x±xÀÓ7IÖJñ	 (ð Ðr*   c                 óô   • [          Hm  nX;   d  M
  U[        R                  ;  d  M   X   n[        R                  " SSU[        R
                  S9n[        R                  " SSU5      n[        XU5        Mo     U $ )z5Remove all universal build arguments from config varsú-arch\s+\w+\sr†   )Úflagsz-isysroot\s*\S+)Ú_UNIVERSAL_CONFIG_VARSr   r   rI   ÚsubÚASCIIrn   )rf   rk   r‘   s      r(   Ú_remove_universal_flagsr•     se   € ÷ %ˆàÕ "¬B¯J©JÕ"6Ø Ñ$ˆEÜ—F’FÐ+¨S°%¼r¿x¹xÑHˆEÜ—F’FÐ-¨s°EÓ:ˆEÜ  °5Ö9ñ %ð Ðr*   c                 óv  • S[         R                  ;   a  U $ [        R                  " SU S   5      b‡  [         R                  " SU S   R                  SS5      < S35      nU(       aR  [         HH  nX ;   d  M
  U[         R                  ;  d  M   X   n[        R                  " SS	U5      n[        XU5        MJ     U $ )
z-Remove any unsupported archs from config varsr   z-arch\s+ppcr   zecho 'int main{};' | 'r,   r…   z6' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/nullz-arch\s+ppc\w*\sr†   )	r   r   rI   rJ   r6   rˆ   r’   r“   rn   )rf   Ústatusrk   r‘   s       r(   Ú_remove_unsupported_archsr˜     s§   € ð Œr�z‰zÓØÐä	‡y‚y� ¨hÑ!7Ó8ÑDô —“ð ˜4Ñ ×(Ñ(¨¨iÖ8ð;ó<ˆö ÷ -�ØÕ%¨"´B·J±JÕ*>Ø(Ñ,�EÜŸFšFÐ#6¸¸UÓC�EÜ(¨¸5ÖAñ	 -ð Ðr*   c                 óð   • S[         R                  ;   aa  [         R                  S   n[         HD  nX ;   d  M
  SX   ;   d  M  X   n[        R                  " SSU5      nUS-   U-   n[        XU5        MF     U $ )z2Allow override of all archs with ARCHFLAGS env varÚ	ARCHFLAGSú-archr�   r†   )r   r   r’   rI   r“   rn   )rf   Úarchrk   r‘   s       r(   Ú_override_all_archsr�   :  ss   € ð
 ”b—j‘jÓ Ü�z‰z˜+Ñ&ˆß(ˆBØÕ! g°Ñ1AÕ&AØ$Ñ(�ÜŸšÐ/°°eÓ<�Ø ™ dÑ*�Ü$ \°uÖ=ñ )ð Ðr*   c                 ól  • U R                  SS5      n[        R                  " SU5      nUb‡  UR                  S5      n[        R
                  R                  U5      (       dR  [         HH  nX@;   d  M
  U[        R                  ;  d  M   X   n[        R                  " SSU5      n[        XU5        MJ     U $ )z+Remove references to any SDKs not availabler   r@   z-isysroot\s*(\S+)rF   z-isysroot\s*\S+(?:\s|$)r†   )rj   rI   rJ   rL   r   r   Úexistsr’   r   r“   rn   )rf   ÚcflagsrN   Úsdkrk   r‘   s         r(   Ú_check_for_unavailable_sdkr¢   K  s”   € ð ×Ñ˜h¨Ó+€FÜ
�	Š	Ð&¨Ó/€AØ�}Ø�g‰g�a‹jˆÜ�w‰w�~‰~˜c×"Ñ"ß,�àÕ%¨"´B·J±JÕ*>Ø(Ñ,�EÜŸFšFÐ#=¸sÀEÓJ�EÜ(¨¸5ÖAñ -ð Ðr*   c                 óv  • S=p#[        U 5      n [        5       (       d  S=p#OSU;   n[        S U 5       5      nU(       d  S[        R                  ;   a    U R                  S5      nXUS-   2	 M  [        5       (       dB  [        [        [        U 5      5      5       H!  nX   S:X  d  M  XS-      S:X  d  M  XUS-   2	 M#     S[        R                  ;   a+  U(       d$  U [        R                  S   R                  5       -   n U(       a^   [        U 5       VVs/ s H  u  pgUR                  S	5      (       d  M  UPM!     nnnU(       d  OUS
   nX   S	:X  a  XUS-   2	 OXUS-   2	 M]  Sn	Un
[        U5       VVs/ s H  u  pgUR                  S	5      (       d  M  UPM!     nnnU(       d9  U n
[        U 5       VVs/ s H  u  pgUR                  S	5      (       d  M  UPM!     nnnU H$  nX¥   S	:X  a	  X¥S-      n	  OX¥   [        S	5      S n	  O   U	(       a„  [        R                  R                  U	5      (       d`  [         R"                  R%                  SU	 S35        [         R"                  R%                  S5        [         R"                  R'                  5         U $ ! [         a     GMä  f = fs  snnf s  snnf s  snnf )aM  
This function will strip '-isysroot PATH' and '-arch ARCH' from the
compile flags if the user has specified one them in extra_compile_flags.

This is needed because '-arch ARCH' adds another architecture to the
build, without a way to remove an architecture. Furthermore GCC will
barf if multiple '-isysroot' arguments are present.
FTr›   c              3   óT   #   • U  H  oR                  S 5      (       d  M  Uv •  M      g7f)ú	-isysrootN)rd   )rV   Úargs     r(   rX   Ú!compiler_fixup.<locals>.<genexpr>y  s   é € ÐQª' 3·^±^ÀK×5PŸ3™3ª'ùs   ‚(Ÿ	(rš   rG   rF   Úarm64r¥   r   Nz2Compiling with an SDK that doesn't seem to exist: Ú
z%Please check your Xcode installation
)rc   r~   Úanyr   r   Úindexr^   r�   ÚreversedÚrangeÚlenr   Ú	enumeraterd   r   Úisdirr   ÚstderrÚwriteÚflush)Úcompiler_soÚcc_argsÚ	stripArchÚstripSysrootr«   ÚidxrW   ÚxÚindicesÚsysrootÚargvars              r(   r   r   f  s‚  € ð  %Ð$€Iä�{Ó#€Kä%×'Ñ'ð $(Ð'ˆ	�Là˜wÑ&ˆ	ÜÑQ©'ÓQÓQˆæ�K¤2§:¡:Ó-ØðØ#×)Ñ)¨'Ó2�à e¨A¡g Ð.ñ	 ô $×%Ñ%äœE¤# kÓ"2Ó3Ö4ˆCØÑ 7Õ*¨{¸q¹5Ñ/AÀWÕ/LØ C¨¡E 	Ò*ñ 5ð ”b—j‘jÓ ®ð "¤B§J¡J¨{Ñ$;×$AÑ$AÓ$CÑCˆæØÜ$-¨kÔ$:ÔXÒ$:™S˜Q¸a¿l¹lÈ;×>W—qÑ$:ˆGÑXÞØØ˜A‘JˆEØÑ! [Ó0à e¨A¡g Ñ.ð   e¨A¡g Ð.ñ ð €GØ€FÜ% gÔ.ÔLÒ.‘S�Q°!·,±,¸{×2K�qÑ.€GÑLÞØˆÜ )¨+Ô 6ÔTÒ 6™˜¸!¿,¹,À{×:S—1Ñ 6ˆÑTãˆØ‰;˜+Ó%Ø ™U‘mˆGÙà‘k¤# kÓ"2Ð"3Ð4ˆGÙñ ö ”r—w‘w—}‘} W×-Ñ-Ü�
‰
×ÑÐMÈgÈYÐVXÐYÔZÜ�
‰
×ÑÐAÔBÜ�
‰
×ÑÔàÐøôe ó Ûðüó  Yùó  Mùó Us6   ÁJ ÄJ)Ä6J)Å7J/ÆJ/Æ7J5ÇJ5Ê
J&Ê%J&c                 óf   • [        5       (       d  [        U 5        [        U 5        [        U 5        U $ )aª  Customize Python build configuration variables.

Called internally from sysconfig with a mutable mapping
containing name/value pairs parsed from the configured
makefile used to build this interpreter.  Returns
the mapping updated as needed to reflect the environment
in which the interpreter is running; in the case of
a Python from a binary installer, the installed
environment may be very different from the build
environment, i.e. different OS levels, different
built tools, different available CPU architectures.

This customization is performed whenever
distutils.sysconfig.get_config_vars() is first
called.  It may be used in environments where no
compilers are present, i.e. when installing pure
Python dists.  Customization of compiler paths
and detection of unavailable archs is deferred
until the first extension module build is
requested (in distutils.sysconfig.customize_compiler).

Currently called from distutils.sysconfig
)r~   r•   r�   r¢   ©rf   s    r(   r   r   ¶  s1   € ô2 &×'Ñ'ô
 	  Ô-ô ˜Ô%ô ˜|Ô,àÐr*   c                 óH   • [        U 5        [        U 5        [        U 5        U $ )z´Customize compiler path and configuration variables.

This customization is performed when the first
extension module build is requested
in distutils.sysconfig.customize_compiler.
)rŽ   r˜   r�   r¾   s    r(   r   r   ß  s&   € ô ˜|Ô,ô ˜lÔ+ô ˜Ô%àÐr*   c                 óF  • U R                  SS5      nU(       a  SU;  a  US-  n[        5       =(       d    UnU=(       d    UnU(       GaB  UnSnU R                  [        S-   U R                  SS5      5      nU(       a&   [        S UR	                  S5      SS	  5       5      nOS
nUS:¼  a¤  SUR                  5       ;   a�  Sn[        R                  " SU5      n[        [        [        U5      5      5      n[        U5      S:X  a  US   nO�US:X  a  SnOxUS:X  a  SnOoUS:X  a  SnOfUS:X  a  SnO]US:X  a  SnOTUS:X  a  SnOK[        SU< 35      eUS:X  a  [        R                  S:¼  a  SnOUS;   a  [        R                  S:¼  a  S nOS!nXU4$ ! [
         a    S
n Nøf = f)"z Filter values for get_platform()ÚMACOSX_DEPLOYMENT_TARGETr@   rE   z.0Úmacosxr   c              3   ó8   #   • U  H  n[        U5      v •  M     g 7frR   rS   rU   s     r(   rX   Ú#get_platform_osx.<locals>.<genexpr>  s   é € Ð"NÒ3M¨a¤3 q§6 6Ò3MùrZ   r   rG   )r{   é   rz   r›   Úfatz-arch\s+(\S+)rF   )r¨   Úx86_64Ú
universal2)Úi386Úppc)rÉ   rÇ   Úintel)rÉ   rÊ   rÇ   Úfat3)Úppc64rÇ   Úfat64)rÉ   rÊ   rÍ   rÇ   Ú	universalz#Don't know machine value for archs=rÉ   l        rÇ   )ÚPowerPCÚPower_MacintoshrÍ   rÊ   )rj   rO   re   r]   r   r^   r9   rI   ÚfindallÚsortedÚsetr®   r   Úmaxsize)rf   ÚosnameÚreleaseÚmachineÚmacverÚ
macreleaser    Úarchss           r(   r   r   ó  sÈ  € ð ×ÑÐ8¸"Ó=€FÞ�#˜VÓ#ð 	�$‰ˆÜ$Ó&×0¨&€JØ×!�z€FçØˆØˆð ×!Ñ!¤(¨8Ñ"3Ø$0×$4Ñ$4°X¸rÓ$BóDˆæð%Ü"Ñ"N°:×3CÑ3CÀCÓ3HÈÈ1Ñ3MÓ"NÓN‘
ð
 !ˆJà˜'Ó! w°&·,±,³.Ó'@ð ˆGä—J’JÐ/°Ó8ˆEÜœ&¤ U£Ó,Ó-ˆEä�5‹z˜Q‹Ø ™(‘ØÐ-Ó-Ø&‘Ø˜/Ó)Ø‘ØÐ,Ó,Ø!‘ØÐ3Ó3Ø ‘ØÐ-Ó-Ø!‘ØÐ<Ó<Ø%‘å Ú>CÐEóGð Gð ˜Óô �{‰{˜eÓ#Ø"�øàÐ6Ó6ô �{‰{˜eÓ#Ø!‘à�à˜WÐ%Ð%øôa ó %Ø$’
ð%ús   Â $F ÆF ÆF rR   )F)Ú__doc__r   rI   r   Ú__all__r’   rŠ   re   r)   r>   rB   rH   rO   r\   ra   rh   rn   rq   rx   r~   r�   rŽ   r•   r˜   r�   r¢   r   r   r   r   r[   r*   r(   Ú<module>rÞ      s®   ðÙ $ã 	Û 	Û 
ò€ðAÐ ð ?Ð ð #€ôô4Qò,ð €òð< Ð ò!ò& ò ð Ð ò"ò2Bò<ò;ò|ò%òPò"ò6Mò`&òRó(P&r*   