U e5dUã@sÜddlZddlZddlZddddgZdZdZdZd,d d „Zd-d d „Zdd„Z da dd„Z da dd„Z dd„Zdd„Zdadd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d„Zd)d„Zd*d„Zd+d„ZdS).é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Œ|dkrtjd}| tj¡}tj |¡\}}tjdkrH|dkrH|d}tj |¡s„|D]&}tj  ||¡}tj |¡rX|SqXdS|SdS)NÚPATHZwin32z.exe) ÚosÚenvironÚsplitÚpathsepÚpathÚsplitextÚsysÚplatformÚisfileÚjoin)Ú executablerÚpathsÚbaseZextÚpÚf©rú$/usr/lib64/python3.8/_osx_support.pyÚ_find_executables     rFc Csªddl}zddl}| ¡}Wn(tk rDtdt ¡fdƒ}YnX| |¡P}|rfd||jf}nd||jf}t  |¡s|  ¡  d¡  ¡ndW5QR£SQRXdS)Nrz/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)Nz/usr/bin/xcrun -find %sÚ)rr+)ZtoolnamerrrÚ_find_build_toolMs  ÿþr-cCsxtdkrtdaz tdƒ}Wntk r,YnHXzt d| ¡¡}W5| ¡X|dk rtd | d¡  d¡dd…¡atS)Nr,z0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)Ú.éé) Ú_SYSTEM_VERSIONr!ÚOSErrorÚcloseÚreÚsearchr&rÚgroupr)rÚmrrrÚ_get_system_versionVs  ÿ r8cCsLtdkrHtƒ}|rHztdd„| d¡DƒƒaWntk rFdaYnXtS)Ncss|]}t|ƒVqdS©N©Úint©Ú.0ÚirrrÚ sz,_get_system_version_tuple..r.r)Ú_SYSTEM_VERSION_TUPLEr8ÚtuplerÚ ValueError©Z osx_versionrrrÚ_get_system_version_tupleus rDcCs"t|ƒD]}| t¡r||=qdSr9)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkrrrÚ_remove_original_valuesˆs  rJcCs8| |d¡}||kr,t||kr,||t|<|||<dS)Nr,)ÚgetrG)rHÚcvZnewvalueZoldvaluerrrÚ_save_modified_values  rMcCsŽtdk r tStd|fdƒ}d}| ¡D]T}| d¡rzEnd of search listz /usr/includeú/z.sdk/usr/includeiôÿÿÿ)Ú_cache_default_sysrootr+Ú splitlinesrFr(Úendswith)ÚccÚcontentsZ in_incdirsÚlinerrrÚ_default_sysroot™s$    rUcCstƒ}|rt|dkƒSdS)N©é éF)rDÚboolrCrrrÚ_supports_universal_builds²srZcCstƒ}|r|dkSdS)N)é rF)rDrCrrrÚ_supports_arm64_builds¼sr\cCsÚdtjkr|S|d ¡d}}t|ƒs4tdƒ}n/dev/nullr]r^z-arch\s+ppc\w*\sr_) r r r4r5r%rarhrirM)rHZstatusrLrgrrrÚ_remove_unsupported_archss þÿ rlcCsddtjkr`tjd}tD]F}||krd||kr||}t dd|¡}|d|}t|||ƒq|S)NÚ ARCHFLAGSú-archrfr_)r r rhr4rirM)rHZarchrLrgrrrÚ_override_all_archs:s   rocCsx| dd¡}t d|¡}|dk rt| d¡}tj |¡sttD]8}||kr:|tjkr:||}t  dd|¡}t |||ƒq:|S)Nrr,z-isysroot\s*(\S+)r/z-isysroot\s*\S+(?:\s|$)r_) rKr4r5r6r rÚexistsrhr rirM)rHÚcflagsr7ZsdkrLrgrrrÚ_check_for_unavailable_sdkKs    rrc Csød}}t|ƒ}tƒs d}}nd|k}tdd„|Dƒƒ}|sHdtjkr‚z| d¡}|||d…=WqHtk r|YqÈYqHXqHnFtƒsÈtt t |ƒƒƒD].}||dkr˜||dd kr˜|||d…=q˜dtjkrè|sè|tjd  ¡}|r@d d „t |ƒDƒ}|s q@|d }||d kr0|||d…=qî|||d…=qîd}|}dd „t |ƒDƒ}|sv|}dd „t |ƒDƒ}|D]B}||d kr ||d}q¾n||t d ƒd…}q¾qz|rôtj  |¡sôd dlm} |  d|¡|  d¡|S)NFTrncss|]}| d¡r|VqdS)ú -isysrootN©rF)r=Úargrrrr?ys z!compiler_fixup..rmr0r/Úarm64cSsg|]\}}| d¡r|‘qS©rsrt©r=r>ÚxrrrÚ ‘s z"compiler_fixup..rrscSsg|]\}}| d¡r|‘qSrwrtrxrrrrz¡s cSsg|]\}}| d¡r|‘qSrwrtrxrrrrz¤s )Úlogz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation)rErZÚanyr r ÚindexrBr\ÚreversedÚrangeÚlenrÚ enumeraterÚisdirZ distutilsr{Úwarn) Z compiler_soZcc_argsZ stripArchZ stripSysrootr}ÚidxÚindicesZsysrootZargvarr{rrrrfsZ      ÿ cCs"tƒst|ƒt|ƒt|ƒ|Sr9)rZrkrorr©rHrrrr·s cCst|ƒt|ƒt|ƒ|Sr9)rerlror†rrrràs cCsŒ| dd¡}tƒp|}|p|}|r‚|}d}| td| dd¡¡}|rˆz$tdd„| d¡dd …Dƒƒ}WqŒtk r„d }YqŒXnd }|d krFd | ¡krFd }t d|¡}tt t |ƒƒƒ}t |ƒdkrÚ|d}nj|dkrèd}n\|dkröd }nN|dkrd}n>|dkrd}n.|dkr&d}n|dkr6d}ntd|fƒ‚n<|dkrbt j dkr‚d}n |dkr‚t j dkr~d }nd!}|||fS)"NZMACOSX_DEPLOYMENT_TARGETr,Zmacosxrcss|]}t|ƒVqdSr9r:r<rrrr?sz#get_platform_osx..r.rr0)rWrrVrnZfatz -arch\s+(\S+)r/)rvÚ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‰)rKr8rGrArrBr(r4ÚfindallÚsortedÚsetr€rÚmaxsize)rHZosnameÚreleaseÚmachineZmacverZ macreleaserqZarchsrrrrôsX    ÿ$        ÿ    )N)F)r r4rÚ__all__rhrcrGrr+r-r1r8r@rDrJrMrOrUrZr\rerkrlrorrrrrrrrrrÚs@ü      >(Q)