a ÕDOg 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) ÚCFLAGSZLDFLAGSZCPPFLAGSZ BASECFLAGSÚ BLDSHAREDÚLDSHAREDÚCCÚCXXZ PY_CFLAGSZ PY_LDFLAGSZ PY_CPPFLAGSZPY_CORE_CFLAGSZPY_CORE_LDFLAGS)rrr 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ÚPATHZwin32z.exe) ÚosÚenvironÚsplitÚpathsepÚpathÚsplitextÚsysÚplatformÚisfileÚjoin)Ú executablerÚpathsÚbaseZextÚpÚf©rú1/opt/alt/python39/lib64/python3.9/_osx_support.pyÚ_find_executables     rFcCs´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_stderrrrÚfpÚcmdrrrÚ _read_output7s  ÿÿ  r+cCst|ƒptd|fƒpdS)z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find %sÚ)rr+)ZtoolnamerrrÚ_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Úsearchr&ÚcloserÚgroupr)rÚmrrrÚ_get_system_versionVs   ÿr8cCsJtdurFtƒ}|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..r.r)Ú_SYSTEM_VERSION_TUPLEr8ÚtuplerÚ ValueError©Z osx_versionrrrÚ_get_system_version_tupleus  rEcCs"t|ƒD]}| t¡r||=qdS)z-Remove original unmodified values for testingN)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkrrrÚ_remove_original_valuesˆs  rKcCs8| |d¡}||kr,t||vr,||t|<|||<dS)z@Save modified and original unmodified value of configuration varr,N)ÚgetrH)rIÚcvZnewvalueZoldvaluerrrÚ_save_modified_values  rNcCsŽtdur tStd|fdƒ}d}| ¡D]T}| d¡rzEnd of search listz /usr/includeú/z.sdk/usr/includeiôÿÿÿ)Ú_cache_default_sysrootr+Ú splitlinesrGr(Úendswith)ÚccÚcontentsZ in_incdirsÚlinerrrÚ_default_sysroot™s$    rVcCstƒ}|rt|dkƒSdS)z=Returns True if universal builds are supported on this system©é éF)rEÚboolrDrrrÚ_supports_universal_builds²sr[cCstƒ}|r|dkSdS)z9Returns True if arm64 builds are supported on this system)é rF)rErDrrrÚ_supports_arm64_builds¼sr]cCsÚdtjvr|S|d ¡d}}t|ƒs4tdƒ}n/dev/nullr^r_z-arch\s+ppc\w*\sr`) r r r3r4r%rbrirjrN)rIZstatusrMrhrrrÚ_remove_unsupported_archss þÿ rmcCsddtjvr`tjd}tD]F}||vrd||vr||}t dd|¡}|d|}t|||ƒq|S)z2Allow override of all archs with ARCHFLAGS env varÚ ARCHFLAGSú-archrgr`)r r rir3rjrN)rIZarchrMrhrrrÚ_override_all_archs:s   rpcCsx| 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|$)r`) rLr3r4r6r rÚexistsrir rjrN)rIÚcflagsr7ZsdkrMrhrrrÚ_check_for_unavailable_sdkKs    rsc 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. FTrocss|]}| d¡r|VqdS)ú -isysrootN©rG)r=Úargrrrr?yr@z!compiler_fixup..rnr0r/Úarm64cSsg|]\}}| d¡r|‘qS©rtru©r=r>ÚxrrrÚ ‘r@z"compiler_fixup..rrtNcSsg|]\}}| d¡r|‘qSrxruryrrrr{¡r@cSsg|]\}}| d¡r|‘qSrxruryrrrr{¤r@)Úlogz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation)rFr[Úanyr r ÚindexrCr]ÚreversedÚrangeÚlenrÚ enumeraterÚisdirZ distutilsr|Úwarn) Z compiler_soZcc_argsZ stripArchZ stripSysrootr~ÚidxÚindicesZsysrootZargvarr|rrrrfsZ       ÿ 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[rlrprs©rIrrrr·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. )rfrmrpr‡rrrrà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()ZMACOSX_DEPLOYMENT_TARGETr,Zmacosxrcss|]}t|ƒVqdSr9r:r<rrrr?r@z#get_platform_osx..r.rr0)rXrrWroZfatz -arch\s+(\S+)r/)rwÚ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Š)rLr8rHrBrrCr(r3ÚfindallÚsortedÚsetrrÚmaxsize)rIZosnameÚreleaseÚmachineZmacverZ macreleaserrZarchsrrrrôsX    ÿ$         ÿ    r)N)F)Ú__doc__r r3rÚ__all__rirdrHrr+r-r1r8rArErKrNrPrVr[r]rfrlrmrprsrrrrrrrrÚs:      >(Q)