QfVdZddlZddlZddlZgdZdZdZdZddZddZ d Z da d Z da d Zd Zd ZdadZdZdZdZdZdZdZdZdZdZdZdZy)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 jdk(r |dk7r|dz}tjj|sK|D]E}tjj||}tjj|sC|cSy|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 3/opt/alt/python312/lib64/python3.12/_osx_support.py_find_executabler)s  |zz&! JJrzz "E  ,ID# cVm&( 77>>* %A Q +Aww~~a   cddl} ddl}|j}|j|5}|r|d|jd}n|d|jd}t j|s-|jjd jndcdddS#t$r$t dt j d}YwxYw#1swYyxYw) 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>7s "  ( ( *   B 2 %2BGG)toolnames r(_find_build_toolrBMs' X & X GH r*cjtda tdd} tjd|j }|j |2dj |jdjddd atStS#|j wxYw#t$rYtSwxYw) z*Return the OS X system version as a stringNr@z0/System/Library/CoreServices/SystemVersion.plistr-)encodingz=ProductUserVisibleVersion\s*(.*?).) _SYSTEM_VERSIONr2researchr7closer!grouprOSError)r'ms r(_get_system_versionrOVs FGRYZA  II89:C }"%((1771:+;+;C+@!+D"E ?      s B!$B B! B21B2ct4t}|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. c32K|]}t|ywNint.0is r( z,_get_system_version_tuple..s-U>Tc!f>TrE)_SYSTEM_VERSION_TUPLErOtupler ValueError osx_versions r(_get_system_version_tupler`usb$)+  +(--Uk>O>OPS>T-U(U% !   +(*%   +s!A AAcVt|D]}|jts||=y)z-Remove original unmodified values for testingN)list startswith_INITPRE) _config_varsks r(_remove_original_valuesrgs&,  << !Q r*cj|j|d}||k7rt|z|vr ||t|z<|||<y)z@Save modified and original unmodified value of configuration varr@N)getrd)recvnewvalueoldvalues r(_save_modified_valuermsAB'HH8b= #D&. X]#Lr*c6ttSt|dd}d}|jD]\}|jdrd}|jdrd}+|s.|j }|dk(rdaF|j d sX|dd a^tdatS) 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> splitlinesrcr9endswith)cccontents in_incdirslines r(_default_sysrootrws)%%">EHJ##% ??+ ,J __1 2J ::replace SystemError_COMPILER_CONFIG_VARSrmr!)rersoldccdatarjcv_splits r(_find_appropriate_compilerrs" rzzd#))+A..B B g &   "  ( ( / " 3 :=> J$&!'*B /1 1 U{(B\!b &:'+113$&%KbR$Y $\2sxx7IJ ( r*ctD]j}||vs|tjvs||}tjdd|tj }tjdd|}t |||l|S)z5Remove all universal build arguments from config vars -arch\s+\w+\sr)flagsz-isysroot\s*\S+)_UNIVERSAL_CONFIG_VARSrrrIsubASCIIrm)rerjrs r(_remove_universal_flagsrsk%  "BJJ"6 $EFF+S%rxxHEFF-sE:E r5 9 % r*cTdtjvr|Stjd|dztjd|dj ddd}|rLt D]C}||vs|tjvs||}tjdd |}t|||E|S) z-Remove any unsupported archs from config varsr z -arch\s+ppcrzecho 'int main{};' | 'r,rz6' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/nullz-arch\s+ppc\w*\sr) rrrIrJr6rrrrm)restatusrjrs r(_remove_unsupported_archsrs rzz yyh!78D4 ((i8 ;< -%"BJJ*>(,EFF#6UCE(r5A - r*cdtjvr\tjd}tD]@}||vsd||vs||}tjdd|}|dz|z}t |||B|S)z2Allow override of all archs with ARCHFLAGS env var ARCHFLAGS-archrr)rrrrIrrm)rearchrjrs r(_override_all_archsr:s{ bjj zz+&(B\!gb1A&A$R(/e< d*$\2u= ) r*cR|jdd}tjd|}|||jd}tj j |sLtD]C}||vs|tjvs||}tjdd|}t|||E|S)z+Remove references to any SDKs not availablerr@z-isysroot\s*(\S+)rFz-isysroot\s*\S+(?:\s|$)r) rirIrJrLrrexistsrrrrm)recflagsrNsdkrjrs r(_check_for_unavailable_sdkrKs  h +F &/A}ggajww~~c",%"BJJ*>(,EFF#=sEJE(r5A - r*cdx}}t|}tsdx}}nd|v}td|D}|sdtjvr |j d}|||dz=ts?ttt|D]}||dk(s ||dzdk(s|||dz=!dtjvr&|s$|tjdjz}|rR t|Dcgc]\}}|jd s|}}}|sn|d }||d k(r |||dz=n|||dz=Qd } |} t|Dcgc]\}}|jd s|}}}|s1|} t|Dcgc]\}}|jd s|}}}|D]&}| |d k(r | |dz} n| |td d } n| rtjj| s`t j"j%d | d t j"j%dt j"j'|S#t $rYwxYwcc}}wcc}}wcc}}w)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. FTrc3DK|]}|jds|yw) -isysrootN)rc)rVargs r(rXz!compiler_fixup..ysQ'3S^^K5P3's  rrGrFarm64rrNz2Compiling with an SDK that doesn't seem to exist:  z%Please check your Xcode installation )rbr}anyrrindexr]rreversedrangelenr enumeratercrisdirrstderrwriteflush) compiler_socc_args stripArch stripSysrootridxrWxindicessysrootargvars r(rrfs %$I {#K % '$(' Lw& Q'QQ K2::- #))'2eAg . $ %E#k"234C37*{3q5/AW/LCE *5bjj "BJJ{$;$A$A$CC $-k$:X$:SQqall;>Wq$:GXAJE5![0eAg . eAg .G F%g.L.SQq!,,{2Kq.GL  )+ 6T 61!,,{:S1 6T #;+ %SUmG Sk#k"2"34G  rww}}W- MgYVXYZ AB  e   Y MUs6 I7II I$&I$?I*I* IIc\ts 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}rrrres r(rrs.2 & ' - %|, r*cHt|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}|r d|vr|dz }txs|}|xs|}|r,|}d}|jtdz|jdd}|r& td|j ddd D}nd }|d k\rd |j vrd }tjd|}ttt|}t|dk(r|d}nu|dk(rd}nm|dk(rd }ne|dk(rd}n]|dk(rd}nU|dk(rd}nM|dk(rd}nEt d||dk(rtjdk\rd}n|dvrtjdk\rd }nd!}|||fS#t $rd }YwxYw)"z Filter values for get_platform()MACOSX_DEPLOYMENT_TARGETr@rEz.0macosxrc32K|]}t|ywrRrSrUs r(rXz#get_platform_osx..s"N3Ma3q63MrYrrG)rzryrfatz -arch\s+(\S+)rF)rx86_64 universal2)i386ppc)rrintel)rrrfat3)ppc64rfat64)rrrr universalz#Don't know machine value for archs=rlr)PowerPCPower_Macintoshrr)rirOrdr\rr]r9rIfindallsortedsetrrmaxsize)reosnamereleasemachinemacver macreleaserarchss r(rrs  8" =F #V# $$&0&J  !zF  !!(8"3$0$4$4Xr$BD  %""N:3C3CC3H13M"NN !J ' !w&,,.'@GJJ/8E&U,-E5zQ(--&/),,!33 --!<<% >CEGG {{e#" 6 6{{e#! GW %%a %$  %s%$E&& E43E4rR)F)__doc__rrIr__all__rrrdr)r>rBrHrOr[r`rgrmrprwr}rrrrrrrrrrrZr*r(rs$  A ? #4Q,<!&  "2B<;| %P"6M`&R(P&r*