B j÷,:]{ã@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„x*|D]"}tj  ||¡}tj |¡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ú//opt/alt/python37/lib/python3.7/_osx_support.pyÚ_find_executables     rc CsŠddl}yddl}| ¡}Wn(tk rDtdt ¡fdƒ}YnX| |¡0}d||jf}t  |¡s||  ¡  d¡  ¡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 commandstringrrÚ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_toolJsr-cCsxtdkrtday tdƒ}Wntk r,YnHXzt d| ¡¡}Wd| ¡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ÚreÚsearchr&ÚcloserÚgroupr)rÚmrrrÚ_get_system_versionSs   r8cCs&x t|ƒD]}| t¡r ||=q WdS)z-Remove original unmodified values for testingN)ÚlistÚ startswithÚ_INITPRE)Ú _config_varsÚkrrrÚ_remove_original_valuesqs r>cCs8| |d¡}||kr,t||kr,||t|<|||<dS)z@Save modified and original unmodified value of configuration varr,N)Úgetr;)r<ÚcvZnewvalueZoldvaluerrrÚ_save_modified_valuexs  rAcCsTtƒ}|r@ytdd„| 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..r.r,)é éF)r8ÚtuplerÚ ValueErrorÚbool)Z osx_versionrrrÚ_supports_universal_builds€s rKcCsÞdtjkr|S|d ¡d}}t|ƒs4tdƒ}n/dev/nullrLz'"'"'z-arch\s+ppc\w*\srM) r r r3r4r%rOrUrVrA)r<Zstatusr@rTrrrÚ_remove_unsupported_archsÜs  rYcCshdtjkrdtjd}xNtD]F}||krd||kr||}t dd|¡}|d|}t|||ƒqW|S)z2Allow override of all archs with ARCHFLAGS env varÚ ARCHFLAGSz-archz -arch\s+\w+\srM)r r rUr3rVrA)r<Zarchr@rTrrrÚ_override_all_archss    r[cCs|| dd¡}t d|¡}|dk rx| d¡}tj |¡sxx@tD]8}||kr<|tjkr<||}t  dd|¡}t |||ƒq.rZr0cSsg|]\}}| d¡r|‘qS)z -isysroot)r:)rCrDÚxrrrú Usz"compiler_fixup..rz -isysrootr/NcSsg|]\}}| d¡r|‘qS)z -isysroot)r:)rCrDr`rrrraescSsg|]\}}| d¡r|‘qS)z -isysroot)r:)rCrDr`rrrrahs)Úlogz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation)r9rKÚanyr r ÚindexrIrÚ enumerateÚlenrÚisdirZ distutilsrbÚwarn) Z compiler_soZcc_argsZ stripArchZ stripSysrootrdÚindicesZsysrootZargvarÚidxrbrrrr0sT         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 )rKrXr[r^)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). )rSrYr[)r<rrrr¤s cCs|| dd¡}tƒp|}|p|}|rr|}d}| td| dd¡¡}|rˆy$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|ƒVqdS)N)rB)rCrDrrrrEÒsz#get_platform_osx..r.rr0)rFr)rFrGz-archZfatz -arch\s+(\S+)r/)Úi386Úppc)rkÚx86_64Zintel)rkrlrmZfat3)Úppc64rmZfat64)rkrlrnrmZ universalz%Don't know machine value for archs=%rrklrm)ZPowerPCZPower_Macintoshrnrl)r?r8r;rHrrIr(r3ÚfindallÚsortedÚsetrfrÚmaxsize)r<ZosnameÚreleaseÚmachineZmacverZ macreleaser]Zarchsrrrr¸sP   $           )N)Ú__doc__r r3rÚ__all__rUrQr;rr+r-r1r8r>rArKrSrXrYr[r^rrrrrrrrÚs6 >(K)