grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026o ®û|jUã@sÜdZddlZddlZddlZgd¢ZdZdZdZd.dd„Zd/d d „Z d d „Z da dd„Z da dd„Zdd„Zdd„Zdadd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„ZdS)0zShared OS X support functions.éN)Úcompiler_fixupÚcustomize_config_varsÚcustomize_compilerÚget_platform_osx) ÚCFLAGSZLDFLAGSZCPPFLAGSZ BASECFLAGSÚ BLDSHAREDÚLDSHAREDÚCCÚCXXZ PY_CFLAGSZ PY_LDFLAGSZ PY_CPPFLAGSZPY_CORE_CFLAGSZPY_CORE_LDFLAGS)rrr r Z_OSX_SUPPORT_INITIAL_cCsˆ|dur tjd}| tj¡}tj |¡\}}tjdkr$|dkr$|d}tj |¡sB|D]}tj  ||¡}tj |¡r?|Sq,dS|S)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ÚPATHZwin32z.exe) ÚosÚenvironÚsplitÚpathsepÚpathÚsplitextÚsysÚplatformÚisfileÚjoin)Ú executablerÚpathsÚbaseZextÚpÚf©rú3/opt/alt/python310/lib64/python3.10/_osx_support.pyÚ_find_executables    þrFcCs´ddl}z ddl}| ¡}Wnty!tdt ¡fdƒ}Ynw| |¡�)}|r2d||jf}nd||jf}t  |¡sG|  ¡  d¡  ¡ndWdƒS1sSwYdS)z0Output from successful command execution or NonerNz/tmp/_osx_support.%szw+bz %s >'%s' 2>&1z%s 2>/dev/null >'%s'úutf-8) Ú contextlibÚtempfileZNamedTemporaryFileÚ ImportErrorÚopenr ÚgetpidÚclosingÚnameÚsystemÚreadÚdecodeÚstrip)Z commandstringZcapture_stderrrr ÚfpÚcmdrrrÚ _read_output7s"  ÿÿÿ $ûr,cCst|ƒp td|fƒp dS)z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find %sÚ)rr,)ZtoolnamerrrÚ_find_build_toolMs  ÿþr.cCs„tdur@daztddd�}Wn tyYtSwzt d| ¡¡}W| ¡n| ¡w|dur@d | d¡  d¡dd …¡atS) z*Return the OS X system version as a stringNr-z0/System/Library/CoreServices/SystemVersion.plistr)Úencodingz=ProductUserVisibleVersion\s*(.*?)Ú.éé) Ú_SYSTEM_VERSIONr"ÚOSErrorÚreÚsearchr'ÚcloserÚgroupr)rÚmrrrÚ_get_system_versionVs    òÿr:cCsNtdur%tƒ}|r%ztdd„| d¡DƒƒaWtSty$daYtSwtS)z} Return the macOS system version as a tuple The return value is safe to use to compare two version numbers. Ncsó�|]}t|ƒVqdS©N©Úint©Ú.0ÚirrrÚ �ó€z,_get_system_version_tuple..r0r)Ú_SYSTEM_VERSION_TUPLEr:ÚtuplerÚ ValueError©Z osx_versionrrrÚ_get_system_version_tupleus ýýrHcCs"t|ƒD] }| t¡r||=qdS)z-Remove original unmodified values for testingN)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkrrrÚ_remove_original_valuesˆs  €þrNcCs8| |d¡}||krt||vr||t|<|||<dS)z@Save modified and original unmodified value of configuration varr-N)ÚgetrK)rLÚcvZnewvalueZoldvaluerrrÚ_save_modified_value�s   rQcCsŽtdurtStd|fdƒ}d}| ¡D]*}| d¡rd}q| d¡r&d}q|r>| ¡}|dkr3daq| d ¡r>|dd …aqtdurEdatS) z= Returns the root of the default SDK for this system, or '/' Nz%s -c -E -v - zEnd of search listz /usr/includeú/z.sdk/usr/includeiôÿÿÿ)Ú_cache_default_sysrootr,Ú splitlinesrJr)Úendswith)ÚccÚcontentsZ in_incdirsÚlinerrrÚ_default_sysroot™s&     €rYcCstƒ}|r t|dkƒSdS)z=Returns True if universal builds are supported on this system©é éF)rHÚboolrGrrrÚ_supports_universal_builds²sr^cCstƒ}|r |dkSdS)z9Returns True if arm64 builds are supported on this system)é rF)rHrGrrrÚ_supports_arm64_builds¼sr`cCsÚdtjvr|S|d ¡d}}t|ƒstdƒ}ntj |¡ d¡r8td|  dd¡fƒ}|r8d|vr8tdƒ}|s>t d ƒ‚||krkt D]&}||vrj|tjvrj|| ¡}|d kr[|n|d |d<t ||d   |¡ƒqD|S) z7Find appropriate C compiler for extension module buildsr rZclangZgccz'%s' --versionú'ú'"'"'zllvm-gcczCannot locate working compilerr z++ú )r r rrr.rÚbasenamerJr,ÚreplaceÚ SystemErrorÚ_COMPILER_CONFIG_VARSrQr)rLrVZoldccÚdatarPZcv_splitrrrÚ_find_appropriate_compilerÆs.   ÿ ÿ €ricCsVtD]&}||vr(|tjvr(||}tjdd|tjd�}t dd|¡}t|||ƒq|S)z5Remove all universal build arguments from config varsú -arch\s+\w+\src)Úflagsz-isysroot\s*\S+)Ú_UNIVERSAL_CONFIG_VARSr r r5ÚsubÚASCIIrQ)rLrPrkrrrÚ_remove_universal_flagss €rocCs„dtjvr|St d|d¡dur@t d|d dd¡f¡}|r@tD]}||vr?|tjvr?||}t dd |¡}t|||ƒq#|S) z-Remove any unsupported archs from config varsr z -arch\s+ppcrNzNecho 'int main{};' | '%s' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/nullrarbz-arch\s+ppc\w*\src) r r r5r6r&rerlrmrQ)rLZstatusrPrkrrrÚ_remove_unsupported_archss þÿ  €rpcCsddtjvr0tjd}tD]#}||vr/d||vr/||}t dd|¡}|d|}t|||ƒq |S)z2Allow override of all archs with ARCHFLAGS env varÚ ARCHFLAGSú-archrjrc)r r rlr5rmrQ)rLZarchrPrkrrrÚ_override_all_archs:s    €rscCsx| dd¡}t d|¡}|dur:| d¡}tj |¡s:tD]}||vr9|tjvr9||}t  dd|¡}t |||ƒq|S)z+Remove references to any SDKs not availablerr-z-isysroot\s*(\S+)Nr1z-isysroot\s*\S+(?:\s|$)rc) rOr5r6r8r rÚexistsrlr rmrQ)rLÚcflagsr9ZsdkrPrkrrrÚ_check_for_unavailable_sdkKs    €rvc Csâd}}t|ƒ}tƒsd}}n d|v}tdd„|Dƒƒ}|s$dtjvr? z| d¡}|||d…=Wn ty<Ynwq%n#tƒsbtt t |ƒƒƒD]}||dkra||dd kra|||d…=qJdtjvrr|sr|tjd  ¡}|r› d d „t |ƒDƒ}|s�n|d }||d kr“|||d…=n|||d…=qud}|}dd „t |ƒDƒ}|sµ|}dd „t |ƒDƒ}|D]}||d krÇ||d}n ||t d ƒd…}|rïtj  |¡sïtj d|›d�¡tj d¡tj ¡|S)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. FTrrcss�|] }| d¡r|VqdS)ú -isysrootN©rJ)r@ÚargrrrrBys€z!compiler_fixup..rqr2r1Úarm64cSóg|] \}}| d¡r|‘qS©rwrx©r@rAÚxrrrÚ ‘óz"compiler_fixup..rrwNcSr{r|rxr}rrrr¡r€cSr{r|rxr}rrrr¤r€z2Compiling with an SDK that doesn't seem to exist: Ú z%Please check your Xcode installation )rIr^Úanyr r ÚindexrFr`ÚreversedÚrangeÚlenrÚ enumeraterÚisdirrÚstderrÚwriteÚflush) Z compiler_soZcc_argsZ stripArchZ stripSysrootrƒÚidxÚindicesZsysrootZargvarrrrrfsd    ÿû€ ö    rcCs"tƒst|ƒt|ƒt|ƒ|S)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^rorsrv©rLrrrr¶s rcCst|ƒt|ƒt|ƒ|S)zÄCustomize compiler path and configuration variables. This customization is performed when the first extension module build is requested in distutils.sysconfig.customize_compiler. )rirprsrŽrrrrßs rcCsp| dd¡}tƒp |}|p|}|r³|}d}| td| dd¡¡}|rAztdd„| d¡dd …Dƒƒ}Wn ty@d }Ynwd }|d kr™d | ¡vr™d }t d|¡}tt t |ƒƒƒ}t |ƒdkrh|d}nK|dkrod}nD|dkrvd }n=|dkr}d}n6|dkr„d}n/|dkr‹d}n(|dkr’d}n!td|fƒ‚|dkr¥t j dkr¤d}n|dvr³t j dkr±d }nd!}|||fS)"z Filter values for get_platform()ZMACOSX_DEPLOYMENT_TARGETr-Zmacosxrcsr;r<r=r?rrrrB rCz#get_platform_osx..r0rr2)r[érZrrZfatz -arch\s+(\S+)r1)rzÚx86_64Z universal2)Úi386Úppc)r‘r�Zintel)r‘r’r�Zfat3)Úppc64r�Zfat64)r‘r’r“r�Z universalz%Don't know machine value for archs=%rr‘lr�)ZPowerPCZPower_Macintoshr“r’)rOr:rKrErrFr)r5ÚfindallÚsortedÚsetr†rÚmaxsize)rLZosnameÚreleaseÚmachineZmacverZ macreleaseruZarchsrrrrós\   ÿ$ ÿ   ÿ €  rr<)F)Ú__doc__r r5rÚ__all__rlrgrKrr,r.r3r:rDrHrNrQrSrYr^r`rirorprsrvrrrrrrrrÚs<      >(P)