a ª‡Ù`Uã@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) ÚCFLAGSÚLDFLAGSÚCPPFLAGSZ BASECFLAGSÚ BLDSHAREDÚLDSHAREDÚCCÚCXXZ PY_CFLAGSZ PY_LDFLAGSZ PY_CPPFLAGSZPY_CORE_CFLAGSZPY_CORE_LDFLAGS)r r r r Z_OSX_SUPPORT_INITIAL_cCsŒ|durtjd}| tj¡}tj |¡\}}tjdkrH|dkrH|d}tj |¡s„|D]&}tj  ||¡}tj |¡rX|SqXdS|SdS)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Úf©rú//usr/local/src/Python-3.9.6/Lib/_osx_support.pyÚ_find_executables     r!FcCs´ddl}zddl}| ¡}Wn&tyBtdt ¡fdƒ}Yn0| |¡R}|rdd||jf}nd||jf}t  |¡sŽ|  ¡  d¡  ¡ndWdƒS1s¦0YdS)z0Output from successful command execution or NonerNz/tmp/_osx_support.%szw+bz %s >'%s' 2>&1z%s 2>/dev/null >'%s'zutf-8) Ú contextlibÚtempfileZNamedTemporaryFileÚ ImportErrorÚopenrÚgetpidÚclosingÚnameÚsystemÚreadÚdecodeÚstrip)Z commandstringZcapture_stderrr"r#ÚfpÚcmdrrr Ú _read_output7s  ÿÿ  r/cCst|ƒptd|fƒpdS)z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find %sÚ)r!r/)Ztoolnamerrr Ú_find_build_toolMs  ÿþr1cCs~tdurzdaz tdƒ}Wnty*YnP0zt d| ¡¡}W| ¡n | ¡0|durzd | d¡  d¡dd…¡atS)z*Return the OS X system version as a stringNr0z0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)Ú.éé) Ú_SYSTEM_VERSIONr%ÚOSErrorÚreÚsearchr*ÚcloserÚgroupr)rÚmrrr Ú_get_system_versionVs   ÿr<cCsJtdurFtƒ}|rFztdd„| d¡DƒƒaWntyDdaYn0tS)z} Return the macOS system version as a tuple The return value is safe to use to compare two version numbers. Ncss|]}t|ƒVqdS©N©Úint©Ú.0Úirrr Ú óz,_get_system_version_tuple..r2r)Ú_SYSTEM_VERSION_TUPLEr<ÚtuplerÚ ValueError©Z osx_versionrrr Ú_get_system_version_tupleus  rIcCs"t|ƒD]}| t¡r||=qdS)z-Remove original unmodified values for testingN)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkrrr Ú_remove_original_valuesˆs  rOcCs8| |d¡}||kr,t||vr,||t|<|||<dS)z@Save modified and original unmodified value of configuration varr0N)ÚgetrL)rMÚcvZnewvalueZoldvaluerrr Ú_save_modified_values  rRcCsŽtdur tStd|fdƒ}d}| ¡D]T}| d¡rzEnd of search listz /usr/includeú/z.sdk/usr/includeiôÿÿÿ)Ú_cache_default_sysrootr/Ú splitlinesrKr,Úendswith)ÚccÚcontentsÚ in_incdirsÚlinerrr Ú_default_sysroot™s$    r[cCstƒ}|rt|dkƒSdS)z=Returns True if universal builds are supported on this system©é éF)rIÚboolrHrrr Ú_supports_universal_builds²sr`cCstƒ}|r|dkSdS)z9Returns True if arm64 builds are supported on this system)é rF)rIrHrrr Ú_supports_arm64_builds¼srbcCsÚdtjvr|S|d ¡d}}t|ƒs4tdƒ}n/dev/nullrerfz-arch\s+ppc\w*\srg) rrr7r8r)rirprqrR)rMÚstatusrQrorrr Ú_remove_unsupported_archss þÿ rucCsddtjvr`tjd}tD]F}||vrd||vr||}t dd|¡}|d|}t|||ƒq|S)z2Allow override of all archs with ARCHFLAGS env varÚ ARCHFLAGSú-archrnrg)rrrpr7rqrR)rMZarchrQrorrr Ú_override_all_archs:s   rxcCsx| dd¡}t d|¡}|durt| d¡}tj |¡sttD]8}||vr:|tjvr:||}t  dd|¡}t |||ƒq:|S)z+Remove references to any SDKs not availablerr0z-isysroot\s*(\S+)Nr3z-isysroot\s*\S+(?:\s|$)rg) rPr7r8r:rrÚexistsrprrqrR)rMÚcflagsr;ZsdkrQrorrr Ú_check_for_unavailable_sdkKs    r{c Csöd}}t|ƒ}tƒs d}}nd|v}tdd„|Dƒƒ}|sHdtjvr€z| d¡}|||d…=WqHtyzYqÆYqH0qHnFtƒsÆtt t |ƒƒƒD].}||dkr–||dd kr–|||d…=q–dtjvræ|sæ|tjd  ¡}|r>d d „t |ƒDƒ}|sq>|d }||d kr.|||d…=qì|||d…=qìd}|}dd „t |ƒDƒ}|st|}dd „t |ƒDƒ}|D]B}||d krž||d}q¼n||t d ƒd…}q¼qx|ròtj  |¡sòd dlm} |  d|¡|  d¡|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. FTrwcss|]}| d¡r|VqdS)ú -isysrootN©rK)rAÚargrrr rCyrDz!compiler_fixup..rvr4r3Úarm64cSsg|]\}}| d¡r|‘qS©r|r}©rArBÚxrrr Ú ‘rDz"compiler_fixup..rr|NcSsg|]\}}| d¡r|‘qSr€r}rrrr rƒ¡rDcSsg|]\}}| d¡r|‘qSr€r}rrrr rƒ¤rD)Úlogz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation)rJr`ÚanyrrÚindexrGrbÚreversedÚrangeÚlenrÚ enumeraterÚisdirÚ distutilsr„Úwarn) Ú compiler_soZcc_argsZ stripArchZ stripSysrootr†ÚidxÚindicesÚsysrootZargvarr„rrr rfsZ       ÿ 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`rsrxr{©rMrrr r·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). )rmrurxr’rrr ràs rcCsŠ| dd¡}tƒp|}|p|}|r€|}d}| td| dd¡¡}|r†z$tdd„| d¡dd …Dƒƒ}WqŠty‚d }YqŠ0nd }|d krDd | ¡vrDd }t d|¡}tt t |ƒƒƒ}t |ƒdkrØ|d}nj|dkræd}n\|dkrôd }nN|dkrd}n>|dkrd}n.|dkr$d}n|dkr4d}ntd|fƒ‚n<|dkr`t j dkr€d}n |dvr€t j dkr|d }nd!}|||fS)"z Filter values for get_platform()ÚMACOSX_DEPLOYMENT_TARGETr0Zmacosxrcss|]}t|ƒVqdSr=r>r@rrr rCrDz#get_platform_osx..r2rr4)r]rr\rwZfatz -arch\s+(\S+)r3)rÚx86_64Z universal2)Úi386Úppc)r•r”Zintel)r•r–r”Zfat3)Úppc64r”Zfat64)r•r–r—r”Ú universalz%Don't know machine value for archs=%rr•lr”)ZPowerPCZPower_Macintoshr—r–)rPr<rLrFrrGr,r7ÚfindallÚsortedÚsetr‰rÚmaxsize)rMÚosnameÚreleaseÚmachineZmacverZ macreleaserzÚarchsrrr rôsX    ÿ$         ÿ    r)N)F)Ú__doc__rr7rÚ__all__rprkrLr!r/r1r5r<rErIrOrRrTr[r`rbrmrsrurxr{rrrrrrrr Ús:      >(Q)