3 \�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< >(@)