a €šçd 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Ú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_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/lib64/python3.9/_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ÚtempfileÚNamedTemporaryFileÚ ImportErrorÚopenrÚgetpidÚclosingÚnameÚsystemÚreadÚdecodeÚstrip)Ú commandstringÚcapture_stderrr)r*ÚfpÚcmdr&r&r'Ú _read_output7s  ÿÿ  r9cCst|ƒptd|fƒpdS)z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find %sÚ)r(r9)Útoolnamer&r&r'Ú_find_build_toolMs  ÿþr<cCs~tdurzdaz tdƒ}Wnty*YnP0zt d| ¡¡}W| ¡n | ¡0|durzd | d¡  d¡dd…¡atS)z*Return the OS X system version as a stringNr:z0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)Ú.éé) Ú_SYSTEM_VERSIONr-ÚOSErrorÚreÚsearchr2ÚcloserÚgroupr)r%Úmr&r&r'Ú_get_system_versionVs   ÿrGcCsJtdurFtƒ}|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Úir&r&r'Ú óz,_get_system_version_tuple..r=r&)Ú_SYSTEM_VERSION_TUPLErGÚtuplerÚ ValueError©Ú osx_versionr&r&r'Ú_get_system_version_tupleus  rUcCs"t|ƒD]}| t¡r||=qdS)z-Remove original unmodified values for testingN)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkr&r&r'Ú_remove_original_valuesˆs  r[cCs8| |d¡}||kr,t||vr,||t|<|||<dS)z@Save modified and original unmodified value of configuration varr:N)ÚgetrX)rYÚcvÚnewvalueÚoldvaluer&r&r'Ú_save_modified_values  r`cCsŽtdur tStd|fdƒ}d}| ¡D]T}| d¡rzEnd of search listz /usr/includeú/z.sdk/usr/includeiôÿÿÿ)Ú_cache_default_sysrootr9Ú splitlinesrWr4Úendswith)ÚccÚcontentsÚ in_incdirsÚliner&r&r'Ú_default_sysroot™s$    ricCstƒ}|rt|dkƒSdS)z=Returns True if universal builds are supported on this system©é éF)rUÚboolrSr&r&r'Ú_supports_universal_builds²srncCstƒ}|r|dkSdS)z9Returns True if arm64 builds are supported on this system)é rF)rUrSr&r&r'Ú_supports_arm64_builds¼srpcCsÚdtjvr|S|d ¡d}}t|ƒs4tdƒ}n/dev/nullrsrtz-arch\s+ppc\w*\sru) rrrBrCr1rwr€rr`)rYÚstatusr]rr&r&r'Ú_remove_unsupported_archss þÿ r…cCsddtjvr`tjd}tD]F}||vrd||vr||}t dd|¡}|d|}t|||ƒq|S)z2Allow override of all archs with ARCHFLAGS env varÚ ARCHFLAGSú-archr~ru)rrr€rBrr`)rYÚarchr]rr&r&r'Ú_override_all_archs:s   r‰cCsx| dd¡}t d|¡}|durt| d¡}tj |¡sttD]8}||vr:|tjvr:||}t  dd|¡}t |||ƒq:|S)z+Remove references to any SDKs not availablerr:z-isysroot\s*(\S+)Nr>z-isysroot\s*\S+(?:\s|$)ru) r\rBrCrErrÚexistsr€rrr`)rYÚcflagsrFÚsdkr]rr&r&r'Ú_check_for_unavailable_sdkKs    rc 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. FTr‡css|]}| d¡r|VqdS)ú -isysrootN©rW)rLÚargr&r&r'rNyrOz!compiler_fixup..r†r?r>Úarm64cSsg|]\}}| d¡r|‘qS©rŽr©rLrMÚxr&r&r'Ú ‘rOz"compiler_fixup..rrŽNcSsg|]\}}| d¡r|‘qSr’rr“r&r&r'r•¡rOcSsg|]\}}| d¡r|‘qSr’rr“r&r&r'r•¤rO)Úlogz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation)rVrnÚanyrrÚindexrRrpÚreversedÚrangeÚlenrÚ enumeraterÚisdirÚ distutilsr–Úwarn) Ú compiler_soÚcc_argsÚ stripArchÚ stripSysrootr˜ÚidxÚindicesÚsysrootÚargvarr–r&r&r'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 )rnrƒr‰r©rYr&r&r'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. )r}r…r‰r¨r&r&r'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_TARGETr:Úmacosxrcss|]}t|ƒVqdSrHrIrKr&r&r'rNrOz#get_platform_osx..r=rr?)rkrrjr‡Úfatz -arch\s+(\S+)r>)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=%rr®lr¬)ÚPowerPCÚPower_Macintoshr²r¯)r\rGrXrQrrRr4rBÚfindallÚsortedÚsetr›rÚmaxsize)rYÚosnameÚreleaseÚmachineÚmacverÚ macreleaser‹Úarchsr&r&r'rôsX    ÿ$         ÿ    r)N)F)Ú__doc__rrBrÚ__all__r€ryrXr(r9r<r@rGrPrUr[r`rbrirnrpr}rƒr…r‰rrrrrr&r&r&r'Ús:      >(Q)