U Ä:âeLã@s¾dZddlZddlZddlZddddgZdZdZd Zd&d d „Zd d „Z dd„Z da dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d„Zd#d„Zd$d„Zd%d„ZdS)'zShared 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Œ|dkrtjd}| 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ú1/usr/local/python38/lib/python3.8/_osx_support.pyÚ_find_executables     rc Cs–ddl}zddl}| ¡}Wn(tk rDtdt ¡fdƒ}YnX| |¡<}d||jf}t  |¡s||  ¡  d¡  ¡ndW5QR£SQRXdS)z0Output from successful command execution or NonerNz/tmp/_osx_support.%szw+bz%s 2>/dev/null >'%s'zutf-8) Ú contextlibÚtempfileÚNamedTemporaryFileÚ ImportErrorÚopenr ÚgetpidÚclosingÚnameÚsystemÚreadÚdecodeÚstrip)Z commandstringr 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Ú)rr.)ZtoolnamerrrÚ_find_build_toolJs  ÿþr0cCsxtdkrtdaz tdƒ}Wntk r,YnHXzt d| ¡¡}W5| ¡X|dk rtd | 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ÚcloseÚreÚsearchr)rÚgroupr)rÚmrrrÚ_get_system_versionSs  ÿ r;cCs"t|ƒD]}| t¡r||=qdS)z-Remove original unmodified values for testingN)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkrrrÚ_remove_original_valuesqs  rAcCs8| |d¡}||kr,t||kr,||t|<|||<dS)z@Save modified and original unmodified value of configuration varr/N)Úgetr>)r?ÚcvZnewvalueZoldvaluerrrÚ_save_modified_valuexs  rDcCsTtƒ}|r@ztdd„| d¡Dƒƒ}Wntk r>d}YnX|rPt|dkƒSdS)z=Returns True if universal builds are supported on this systemcss|]}t|ƒVqdS©N©Úint©Ú.0ÚirrrÚ Šsz-_supports_universal_builds..r1r/©é éF)r;ÚtuplerÚ ValueErrorÚbool)Z osx_versionrrrÚ_supports_universal_builds€s rRcCsÚdtjkr|S|d ¡d}}t|ƒs4tdƒ}n/dev/nullrSrTz-arch\s+ppc\w*\srU) r rr7r8r(rWr^r_rD)r?ÚstatusrCr]rrrÚ_remove_unsupported_archsÜs þÿ rccCsddtjkr`tjd}tD]F}||krd||kr||}t dd|¡}|d|}t|||ƒq|S)z2Allow override of all archs with ARCHFLAGS env varÚ ARCHFLAGSú-archr\rU)r rr^r7r_rD)r?ZarchrCr]rrrÚ_override_all_archss   rfcCsx| dd¡}t d|¡}|dk rt| d¡}tj |¡sttD]8}||kr:|tjkr:||}t  dd|¡}t |||ƒq:|S)z+Remove references to any SDKs not availablerr/z-isysroot\s*(\S+)Nr2z-isysroot\s*\S+(?:\s|$)rU) rBr7r8r9r rÚexistsr^rr_rD)r?Úcflagsr:ZsdkrCr]rrrÚ_check_for_unavailable_sdks    ric Cs¨d}}t|ƒ}tƒs d}}nd|k}tdd„|Dƒƒ}|sHdtjkr€z| d¡}|||d…=WqHtk r|Yq€YqHXqHdtjkr |s |tjd ¡}|rðdd „t|ƒDƒ}|s¼qð|d }||d krà|||d…=q¤|||d …=q¤d }|}dd „t|ƒDƒ}|s&|}dd „t|ƒDƒ}|D]B}||d krP||d }qnn||t d ƒd …}qnq*|r¤tj   |¡s¤d dl m } |  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. FTrecss|]}| d¡r|VqdS)ú -isysrootN©r=)rIÚargrrrrKCs z!compiler_fixup..rdr3cSsg|]\}}| d¡r|‘qS©rjrk©rIrJÚxrrrÚ Us z"compiler_fixup..rrjr2NcSsg|]\}}| d¡r|‘qSrmrkrnrrrrpes cSsg|]\}}| d¡r|‘qSrmrkrnrrrrphs )Úlogz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation)r<rRÚanyr rÚindexrPrÚ enumerateÚlenrÚisdirZ distutilsrqÚwarn) Z compiler_soZcc_argsZ stripArchZ stripSysrootrsÚindicesZsysrootZargvarÚidxrqrrrr0sR        ÿ cCs"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 )rRrarfri©r?rrrr{s cCst|ƒ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[rcrfrzrrrr¤s cCs|| dd¡}tƒp|}|p|}|rr|}d}| td| dd¡¡}|rˆz$tdd„| d¡dd …Dƒƒ}WqŒtk r„d }YqŒXnd }|d kr6d | ¡kr6d }t d|¡}tt t |ƒƒƒ}t |ƒdkrÚ|d}nZ|dkrèd }nL|dkröd}n>|dkrd}n.|dkrd}n|dkr&d}ntd|fƒ‚n<|dkrRt j dkrrd}n |dkrrt j dkrnd}nd}|||fS) z Filter values for get_platform()ZMACOSX_DEPLOYMENT_TARGETr/Zmacosxrcss|]}t|ƒVqdSrErFrHrrrrKÒsz#get_platform_osx..r1rr3)rMrrLreZfatz -arch\s+(\S+)r2)Úi386Úppc)r{Úx86_64Zintel)r{r|r}Zfat3)Úppc64r}Zfat64)r{r|r~r}Ú universalz%Don't know machine value for archs=%rr{lr})ZPowerPCZPower_Macintoshr~r|)rBr;r>rOrrPr+r7ÚfindallÚsortedÚsetrurÚmaxsize)r?ZosnameÚreleaseÚmachineZmacverZ macreleaserhZarchsrrrr¸sT    ÿ$       ÿ    )N)Ú__doc__r r7rÚ__all__r^rYr>rr.r0r4r;rArDrRr[rarcrfrirrrrrrrrÚs8ü  >(K)