WcUdZddlZddlZddlZgdZdZdZdZddZdd Z d Z da d Z da d Zd ZdZdadZdZdZdZdZdZdZdZdZdZdZdZdS)zShared OS X support functions.N)compiler_fixupcustomize_config_varscustomize_compilerget_platform_osx) CFLAGSLDFLAGSCPPFLAGS BASECFLAGS BLDSHAREDLDSHAREDCCCXX PY_CFLAGS PY_LDFLAGS PY_CPPFLAGSPY_CORE_CFLAGSPY_CORE_LDFLAGS)r r r r_OSX_SUPPORT_INITIAL_c|tjd}|jtj}tjj |\}}t jdkr |dkr|dz}tjj|sO|D]I}tjj||}tjj|sG|cSdS|S)zTries 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. NPATHwin32z.exe) osenvironsplitpathseppathsplitextsysplatformisfilejoin) executablerpathsbaseextpfs %/usr/lib64/python3.12/_osx_support.py_find_executabler)s  |zz&! JJrzz "E  ,ID# cVmm&( 77>>* % %  A Q +Aww~~a  tFcddl} ddl}|j}|j|5}|r|d|jd}n|d|jd}t j|s0|jjd jndcdddS#t$r(t dt j d}YwxYw#1swYdSxYw) z0Output from successful command execution or NonerNz/tmp/_osx_support.zw+bz >'z' 2>&1z 2>/dev/null >''utf-8) contextlibtempfileNamedTemporaryFile ImportErroropenrgetpidclosingnamesystemreaddecodestrip) commandstringcapture_stderrr.r/fpcmds r( _read_outputr>7sN "  ( ( *   B Q2 >%2]]BGGGG)toolnames r(_find_build_toolrBMs+ X & ProductUserVisibleVersion\s*(.*?).) _SYSTEM_VERSIONr2researchr7closer!grouprOSError)r'ms r(_get_system_versionrOVs FGRYZZA  II89:C }"%((1771:+;+;C+@!+D"E ?        sB.'BB+. CCct;t}|r- td|jdDatStS#t$r daYtSwxYw)z} Return the macOS system version as a tuple The return value is safe to use to compare two version numbers. Nc32K|]}t|dSNint.0is r( z,_get_system_version_tuple..s"-U-Uc!fffff-U-Ur*rE)_SYSTEM_VERSION_TUPLErOtupler ValueError osx_versions r(_get_system_version_tupler_usy$)+ ; +(--U-Uk>O>OPS>T-U-U(U% !   + + +(*%%   +s%A AAc^t|D]}|jts||=dS)z-Remove original unmodified values for testingN)list startswith_INITPRE) _config_varsks r(_remove_original_valuesrfs;,    << ! !Q  r*ct|j|d}||krt|z|vr ||t|z<|||<dS)z@Save modified and original unmodified value of configuration varr@N)getrc)rdcvnewvalueoldvalues r(_save_modified_valuerlsMB'HH8b= #D#D&. X]#Lr*cLttSt|dd}d}|jD]a}|jdrd}|jdrd}-|s0|j }|dkrdaJ|j d s]|dd actdatS) z= Returns the root of the default SDK for this system, or '/' Nz -c -E -v - zEnd of search listz /usr/include/z.sdk/usr/includei)_cache_default_sysrootr> splitlinesrbr9endswith)cccontents in_incdirslines r(_default_sysrootrvs)%%""">EHJ##% 4 4 ??+ , ,JJ __1 2 2JJ Z::replace SystemError_COMPILER_CONFIG_VARSrlr!)rdrroldccdataricv_splits r(_find_appropriate_compilerrsJ" rzzd#))+A..B B  g &   "  ( ( / /| " 3 : : :=> 4J$&&!'*B 2/1 1 U{{( K KB\!!b &:&:'+113$&%KKbbR$Y $\2sxx7IJJJ r*ctD]u}||vs|tjvs||}tjdd|tj }tjdd|}t |||w|S)z5Remove all universal build arguments from config vars -arch\s+\w+\sr)flagsz-isysroot\s*\S+)_UNIVERSAL_CONFIG_VARSrrrIsubASCIIrl)rdrirs r(_remove_universal_flagsrs%::   "BJJ"6"6 $EFF+S%rxxHHEFF-sE:E r5 9 9 9 r*c|dtjvr|Stjd|dtjd|dj ddd}|rTt D]K}||vs|tjvs||}tjd d |}t|||M|S) z-Remove any unsupported archs from config varsr z -arch\s+ppcrNzecho 'int main{};' | 'r,rz6' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/nullz-arch\s+ppc\w*\sr) rrrIrJr6rrrrl)rdstatusrirs r(_remove_unsupported_archsrs rzz yyh!78D4 ((i888 ;< 6- B B%%"BJJ*>*>(,EFF#6UCE(r5AAA r*cdtjvrjtjd}tD]J}||vsd||vs||}tjdd|}|dz|z}t |||L|S)z2Allow override of all archs with ARCHFLAGS env var ARCHFLAGS-archrr)rrrrIrrl)rdarchrirs r(_override_all_archsr:s bjj  zz+&( > >B\!!gb1A&A&A$R(/e< d*$\2u=== r*cn|jdd}tjd|}||jd}tj j |sTtD]K}||vs|tjvs||}tjdd|}t|||M|S)z+Remove references to any SDKs not availablerr@z-isysroot\s*(\S+)NrFz-isysroot\s*\S+(?:\s|$)r) rhrIrJrLrrexistsrrrrl)rdcflagsrNsdkrirs r(_check_for_unavailable_sdkrKs  h +F &/A}ggajww~~c"", B B%%"BJJ*>*>(,EFF#=sEJE(r5AAA r*cdx}}t|}tsdx}}nd|v}td|D}|sdtjvr |j d}|||dz=tsLttt|D]'}||dks||dzdks |||dz=)dtjvr+|s)|tjdjz}|r? d t|D}|sn&|d }||d kr |||dz=n|||dz=>d }|}d t|D}|s|}dt|D}|D]1}||d kr ||dz}n||td d }|rtjj|sftj j#d|dtj j#dtj j%|S#t $rY~wxYw)ae 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. FTrc3BK|]}|jds|dS) -isysrootNrb)rVargs r(rXz!compiler_fixup..ys-QQ3S^^K5P5P33333QQr*rrGrFarm64c@g|]\}}|jds|SrrrVrWxs r( z"compiler_fixup..s)XXXSQqall;>W>WqqqXr*rrNc@g|]\}}|jds|Srrrs r(rz"compiler_fixup..s)LLLSQq!,,{2K2KqqqLr*c@g|]\}}|jds|Srrrs r(rz"compiler_fixup..s)TTT1!,,{:S:S111Tr*z2Compiling with an SDK that doesn't seem to exist:  z%Please check your Xcode installation )rar|anyrrindexr\rreversedrangelenr enumeraterisdirrstderrwriteflush) compiler_socc_args stripArch stripSysrootridxindicessysrootargvars r(rrfs %$I {#K % ' '$(' LLw& QQ'QQQ yK2::-- #))'2eAg . $ % %E#k"234 + +C37**{3q5/AW/L/LCE **bjj  "BJJ{$;$A$A$CC |XXIk$:XXG7AJE5![00eAg .. eAg .G FLLIg.LLG 7TT + 6TT #;+ % %SUmG ESk#k"2"34G wrww}}W-- YgYYYZZ ABB  e    sH77 IIclts t|t|t||S)aCustomize 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|rrrrds r(rrs:2 & ' ' -- %%|,, r*cTt|t|t||S)zCustomize compiler path and configuration variables. This customization is performed when the first extension module build is requested in distutils.sysconfig.customize_compiler. )rrrrs r(rrs/|,,l++ %% r*c"|jdd}tp|}|p|}|rP|}d}|jtdz|jdd}|r* td|j dddD}nd }|d krd |j vrd }tjd |}ttt|}t|dkr |d}n|dkrd}ny|dkrd }np|dkrd}ng|dkrd}n^|dkrd}nU|dkrd}nLt d||dkrtjdkr!d}n|dvrtjdkrd}nd }|||fS#t $rd }YwxYw)!z Filter values for get_platform()MACOSX_DEPLOYMENT_TARGETr@macosxrc32K|]}t|dSrRrSrUs r(rXz#get_platform_osx.. s""N"Na3q66666"N"Nr*rErrG)ryrxrfatz -arch\s+(\S+)rF)rx86_64 universal2)i386ppc)rrintel)rrrfat3)ppc64rfat64)rrrr universalz#Don't know machine value for archs=rlr)PowerPCPower_Macintoshrr)rhrOrcr[rr\r9rIfindallsortedsetrrmaxsize)rdosnamereleasemachinemacver macreleaserarchss r(rrs   8" =F$&0&J  !zF v !!(8"3$0$4$4Xr$BD : %""N"N:3C3CC3H13M"N"NN !J ' ! !w&,,.'@'@GJJ/8E&U,-E5zQ(---&/)),,,!333 ---!<<<% j>CeEGG  {{e##" 6 6 6{{e##! GW %%a % % %$  %s(E>> F FrR)F)__doc__rrIr__all__rrrcr)r>rBrHrOrZr_rfrlrorvr|rrrrrrrrrrrYr*r(rs$$    A ? #4QQQQ,<!!!&      """2BBB<<<;;;|   %%%P"6MMM`&&&R(K&K&K&K&K&r*