????
Your IP : 3.142.201.19
�qc�J�@sdZddlZddlZddlZddddgZd0Zd1ZdZddd�Zdd�Z dd�Z
dadd�Zdd�Z
dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d�Zd-d�Zd.d�Zd/d�ZdS)2zShared 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_CFLAGSZ_OSX_SUPPORT_INITIAL_cCs�|dkrtjd}|jtj�}tjj|�\}}tjdkrh|dkrh|d}tjj|�s�x9|D]1}tjj ||�}tjj|�r�|Sq�WdS|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�baseZext�p�f�r#�1/opt/alt/python35/lib64/python3.5/_osx_support.py�_find_executables
r%cCs�ddl}yddl}|j�}Wn.tk
rXtdtj�fd�}YnX|j|��F}d||jf}tj |�s�|j
�jd�j�SdSWdQRXdS)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
r3cCs#t|�p"td|f�p"dS)z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find %s�)r%r3)Ztoolnamer#r#r$�_find_build_toolJsr5cCs�tdkr�daytd�}Wntk
r6YnbXztjd|j��}Wd|j�X|dk r�dj|jd�j d�dd��atS)z*Return the OS X system version as a stringNr4z0/System/Library/CoreServices/SystemVersion.plistz=<key>ProductUserVisibleVersion</key>\s*<string>(.*?)</string>�.��)
�_SYSTEM_VERSIONr)�OSError�re�searchr.�closer�groupr)r"�mr#r#r$�_get_system_versionSs
+r@cCs1x*t|�D]}|jt�r
||=q
WdS)z-Remove original unmodified values for testingN)�list�
startswith�_INITPRE)�_config_vars�kr#r#r$�_remove_original_valuesqsrFcCsJ|j|d�}||kr<t||kr<||t|<|||<dS)z@Save modified and original unmodified value of configuration varr4N)�getrC)rD�cvZnewvalueZoldvaluer#r#r$�_save_modified_valuexsrIcCsjt�}|rPy&tdd�|jd�D��}Wntk
rOd}YnX|rft|dk�SdS) z=Returns True if universal builds are supported on this systemcss|]}t|�VqdS)N)�int)�.0�ir#r#r$� <genexpr>�sz-_supports_universal_builds.<locals>.<genexpr>r6r4�
�F)rNrO)r@�tupler�
ValueError�bool)Zosx_versionr#r#r$�_supports_universal_builds�s &
rScCs5dtjkr|S|dj�d}}t|�sFtd�}nXtjj|�jd�r�td|j dd�f�}|r�d|kr�td�}|s�t
d ��||kr1xrtD]j}||kr�|tjkr�||j�}|d
kr|n|d|d<t||dj
|��q�W|S)
z7Find appropriate C compiler for extension module buildsrrZclang�gccz'%s' --version�'z'"'"'zllvm-gcczCannot locate working compilerr
z++� )rrrr%r5r�basenamerBr3�replace�SystemError�_COMPILER_CONFIG_VARSrIr)rDZccZoldcc�datarHZcv_splitr#r#r$�_find_appropriate_compiler�s(
r\cCs}xvtD]n}||kr|tjkr||}tjdd|dtj�}tjdd|�}t|||�qW|S)z5Remove all universal build arguments from config varsz
-arch\s+\w+\srV�flagsz-isysroot [^ ]*)�_UNIVERSAL_CONFIG_VARSrrr;�sub�ASCIIrI)rDrHr]r#r#r$�_remove_universal_flags�s
racCs�dtjkr|Stjd|d�dk r�tjd|djdd�f�}|r�xXtD]P}||krb|tjkrb||}tjdd |�}t|||�qbW|S)
z-Remove any unsupported archs from config varsrz-arch\s+ppcrNzNecho 'int main{};' | '%s' -c -arch ppc -x c -o /dev/null /dev/null 2>/dev/nullrUz'"'"'z-arch\s+ppc\w*\srV) rrr;r<r-rXr^r_rI)rDZstatusrHr]r#r#r$�_remove_unsupported_archs�s
rbcCs�dtjkr�tjd}xgtD]_}||kr#d||kr#||}tjdd|�}|d|}t|||�q#W|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 r�|jd�}tjj|�s�xXtD]P}||krX|tjkrX||}tj dd|�}t
|||�qXW|S)z+Remove references to any SDKs not availablerr4z-isysroot\s+(\S+)Nr7z-isysroot\s+\S+(?:\s|$)rV)rGr;r<r>rr�existsr^rr_rI)rD�cflagsr?ZsdkrHr]r#r#r$�_check_for_unavailable_sdks
rgcCs�d}}t|�}t�s,d}}nd|k}d|k}|sYdtjkr�x>y$|jd�}|||d�=Wq\tk
r�PYq\Xq\Wdtjkr�|r�|tjdj�}|rx>y$|jd�}|||d�=Wq�tk
r PYq�Xq�Wd}d|kr@|jd�}||d}n)d|kri|jd�}||d}|r�tjj|�r�d d
l m
}|jd|�|jd�|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)Zcompiler_soZcc_argsZ stripArchZstripSysrootriZsysroot�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
cCs"t|�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*|}|r�|}d}|jtd|jdd��}|r�y0tdd�|jd�dd �D��}Wq�tk
r�d}Yq�Xnd}|dkr�d|j�kr�d
}tjd|�}tt t
|���}t|�dkr(|d}q�|dkr=d
}q�|d krRd}q�|d!krgd}q�|d"kr|d}q�|d#kr�d}q�td|f��nN|dkr�tj
d$kr�d}n*|d%kr�tj
d&kr�d}nd}|||fS)'z Filter values for get_platform()�MACOSX_DEPLOYMENT_TARGETr4Zmacosxrcss|]}t|�VqdS)N)rJ)rKrLr#r#r$rM�sz#get_platform_osx.<locals>.<genexpr>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
0
)rrrr r
rrr
rrrr)r
rrr
)�__doc__rr;r�__all__r^rZrCr%r3r5r9r@rFrIrSr\rarbrdrgrrrrr#r#r#r$�<module>s< >(@)