grthtrhthjhtyjytjytkergtrhtrjytjerhrfh3 \ÂJã @s¾dZddlZddlZddlZddddgZd1Zd2ZdZd3dd„Zdd„Z dd„Z da dd„Z dd„Z dd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d„Zd.d„Zd/d„Zd0d„ZdS)4zShared 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_LDFLAGSZ_OSX_SUPPORT_INITIAL_cCsŒ|dkrtjd}|jtjƒ}tjj|ƒ\}}tjdkrH|dkrH|d}tjj|ƒs„x*|D]"}tjj ||ƒ}tjj|ƒrZ|SqZWdS|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#ú$/usr/lib64/python3.6/_osx_support.pyÚ_find_executables     r%cCsŠddl}yddl}|jƒ}Wn(tk rDtdtjƒfdƒ}YnX|j|ƒ�0}d||jf}tj |ƒs||j ƒj dƒj ƒSdSQRXdS)z0Output from successful command execution or NonerNz/tmp/_osx_support.%szw+bz%s 2>/dev/null >'%s'zutf-8) Ú contextlibÚtempfileZNamedTemporaryFileÚ ImportErrorÚopenrÚgetpidÚclosingÚnameÚsystemÚreadÚdecodeÚstrip)Z commandstringr&r'ÚfpÚcmdr#r#r$Ú _read_output7s  r3cCst|ƒptd|fƒpdS)z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find %sÚ)r%r3)Ztoolnamer#r#r$Ú_find_build_toolJsr5cCsxtdkrtday tdƒ}Wntk r,YnHXztjd|jƒƒ}Wd|jƒX|dk rtdj|jdƒj dƒdd…ƒatS)z*Return the OS X system version as a stringNr4z0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)Ú.éé) Ú_SYSTEM_VERSIONr)ÚOSErrorÚreÚsearchr.ÚcloserÚgroupr)r"Úmr#r#r$Ú_get_system_versionSs   r@cCs&x t|ƒD]}|jtƒr ||=q WdS)z-Remove original unmodified values for testingN)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkr#r#r$Ú_remove_original_valuesqs rFcCs8|j|dƒ}||kr,t||kr,||t|<|||<dS)z@Save modified and original unmodified value of configuration varr4N)ÚgetrC)rDÚcvZnewvalueZoldvaluer#r#r$Ú_save_modified_valuexs  rIc CsTtƒ}|r@ytdd„|jdƒDƒƒ}Wntk r>d}YnX|rPt|dkƒSdS) z=Returns True if universal builds are supported on this systemcss|]}t|ƒVqdS)N)Úint)Ú.0Úir#r#r$ú Šsz-_supports_universal_builds..r6r4é éF)rNrO)r@ÚtuplerÚ ValueErrorÚbool)Z osx_versionr#r#r$Ú_supports_universal_builds€s rScCsÞdtjkr|S|djƒd}}t|ƒs4tdƒ}n/dev/nullrUz'"'"'z-arch\s+ppc\w*\srV) rrr;r<r-rXr^r_rI)rDZstatusrHr]r#r#r$Ú_remove_unsupported_archsÜs  rbcCshdtjkrdtjd}xNtD]F}||krd||kr||}tjdd|ƒ}|d|}t|||ƒqW|S)z2Allow override of all archs with ARCHFLAGS env varÚ ARCHFLAGSz-archz -arch\s+\w+\srV)rrr^r;r_rI)rDZarchrHr]r#r#r$Ú_override_all_archss    rdcCs||jddƒ}tjd|ƒ}|dk rx|jdƒ}tjj|ƒsxx@tD]8}||kr<|tjkr<||}tj dd|ƒ}t |||ƒqrrÚexistsr^rr_rI)rDÚcflagsr?ZsdkrHr]r#r#r$Ú_check_for_unavailable_sdks     rgc CsXd}}t|ƒ}tƒs d}}nd|k}d|k}|s>dtjkrxx8y|jdƒ}|||d…=Wq@tk rrPYq@Xq@Wdtjkrš| rš|tjdjƒ}|rØx8y|jdƒ}|||d…=Wq tk rÒPYq Xq Wd}d|krü|jdƒ}||d}n d|k�r|jdƒ}||d}|�rTtjj|ƒ �rTd d l m }|j d |ƒ|j 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. FTz-archz -isysrootrcr8Nr7r)Úlogz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation) rArSrrÚindexrQrrÚisdirZ distutilsrhÚwarn)Z compiler_soZcc_argsZ stripArchZ stripSysrootriZsysrootÚidxrhr#r#r$r0sF            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 )rSrardrg)rDr#r#r$rps 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\rbrd)rDr#r#r$r™s c Cs||jddƒ}tƒp|}|p|}|�rr|}d}|jtd|jddƒƒ}|rˆy$tdd„|jdƒdd …Dƒƒ}WqŒtk r„d}YqŒXnd}|dkožd |jƒk�r6d }tjd|ƒ}tt t |ƒƒƒ}t |ƒdkrØ|d}n\|dkræd }nN|d k�röd}n>|d!k�rd}n.|d"k�rd}n|d#k�r&d}ntd|fƒ‚n<|dk�rRt j d$k�rrd}n |d%k�rrt j d&k�rnd}nd}|||fS)'z Filter values for get_platform()ÚMACOSX_DEPLOYMENT_TARGETr4Zmacosxrcss|]}t|ƒVqdS)N)rJ)rKrLr#r#r$rMÇsz#get_platform_osx..r6rr8rNrOz-archZfatz -arch\s+(\S+)r7Úi386ÚppcÚx86_64ZintelZfat3Úppc64Zfat64Z universalz%Don't know machine value for archs=%ré ÚPowerPCÚPower_Macintosh)rNr)rNr)rNrO)rnro)rnrp)rnrorp)rqrp)rnrorqrpl)rsrtl)rGr@rCrPrrQr0r;ÚfindallÚsortedÚsetÚlenrÚmaxsize)rDÚosnameÚreleaseÚmachineZmacverZ macreleaserfZarchsr#r#r$r­sP   $            ) rrrr r r r r rrrrr)r r r r )N)Ú__doc__rr;rÚ__all__r^rZrCr%r3r5r9r@rFrIrSr\rarbrdrgrrrrr#r#r#r$Ús< >(@)