a �DOg U�@s�ddlZddlZddlZgd�ZdZdZdZd-dd�Zd.d d �Zd d �Z da d d�Z da dd�Z dd�Zdd�Zdadd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZdS)/�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�|durtjd}|�tj�}tj�|�\}}tjdkrH|dkrH|d}tj�|�s�|D]&}tj� ||�}tj�|�rX|SqXdS|SdS)N�PATH�win32z.exe) �os�environ�split�pathsep�path�splitext�sys�platform�isfile�join)� executabler�paths�base�ext�p�f�r�$/usr/lib64/python3.9/_osx_support.py�_find_executables     rFcCs�ddl}zddl}|��}Wn&tyBtdt��fd�}Yn0|�|��R}|rdd||jf}nd||jf}t� |�s�|� �� d�� �ndWd�S1s�0YdS)Nrz/tmp/_osx_support.%szw+bz %s >'%s' 2>&1z%s 2>/dev/null >'%s'zutf-8) � contextlib�tempfile�NamedTemporaryFile� ImportError�openr �getpid�closing�name�system�read�decode�strip)Z commandstringZcapture_stderrr r!�fp�cmdrrr� _read_output7s  ��  r.cCst|�ptd|f�pdS)Nz/usr/bin/xcrun -find %s�)rr.)Ztoolnamerrr�_find_build_toolMs  ��r0cCs~tdurzdaz td�}Wnty*YnP0zt�d|���}W|��n |��0|durzd�|�d�� d�dd��atS)Nr/z0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?)�.��) �_SYSTEM_VERSIONr$�OSError�re�searchr)�closer�groupr)r�mrrr�_get_system_versionVs   �r;cCsJtdurFt�}|rFztdd�|�d�D��aWntyDdaYn0tS)Ncss|]}t|�VqdS�N��int��.0�irrr� ��z,_get_system_version_tuple..r1r)�_SYSTEM_VERSION_TUPLEr;�tupler� ValueError�Z osx_versionrrr�_get_system_version_tupleus  rHcCs"t|�D]}|�t�r||=qdSr<)�list� startswith�_INITPRE)� _config_vars�krrr�_remove_original_values�s  rNcCs8|�|d�}||kr,t||vr,||t|<|||<dS)Nr/)�getrK)rL�cvZnewvalueZoldvaluerrr�_save_modified_value�s  rQcCs�tdur tStd|fd�}d}|��D]T}|�d�rzEnd of search listz /usr/include�/z.sdk/usr/includei����)�_cache_default_sysrootr.� splitlinesrJr+�endswith)�cc�contentsZ in_incdirs�linerrr�_default_sysroot�s$    rYcCst�}|rt|dk�SdS)N�� �F)rH�boolrGrrr�_supports_universal_builds�sr^cCst�}|r|dkSdS)N)� rF)rHrGrrr�_supports_arm64_builds�sr`cCs�dtjvr|S|d��d}}t|�s4td�}n/dev/nullrarbz-arch\s+ppc\w*\src) r rr6r7r(rerlrmrQ)rL�statusrPrkrrr�_remove_unsupported_archss �� rqcCsddtjvr`tjd}tD]F}||vrd||vr||}t�dd|�}|d|}t|||�q|S)N� ARCHFLAGS�-archrjrc)r rrlr6rmrQ)rLZarchrPrkrrr�_override_all_archs:s   rtcCsx|�dd�}t�d|�}|durt|�d�}tj�|�sttD]8}||vr:|tjvr:||}t� dd|�}t |||�q:|S)Nrr/z-isysroot\s*(\S+)r2z-isysroot\s*\S+(?:\s|$)rc) rOr6r7r9r r�existsrlrrmrQ)rL�cflagsr:ZsdkrPrkrrr�_check_for_unavailable_sdkKs    rwc Cs�d}}t|�}t�s d}}nd|v}tdd�|D��}|sHdtjvr�z|�d�}|||d�=WqHtyzYq�YqH0qHnFt�s�tt t |���D].}||dkr�||dd kr�|||d�=q�dtjvr�|s�|tjd� �}|�r>d d �t |�D�}|�s�q>|d }||d k�r.|||d�=q�|||d�=q�d}|}dd �t |�D�}|�st|}dd �t |�D�}|D]B}||d k�r�||d}�q�n||t d �d�}�q��qx|�r�tj �|��s�d dlm} | �d|�| �d�|S)NFTrscss|]}|�d�r|VqdS)� -isysrootN�rJ)r@�argrrrrByrCz!compiler_fixup..rrr3r2�arm64cSsg|]\}}|�d�r|�qS�rxry�r@rA�xrrr� �rCz"compiler_fixup..rrxcSsg|]\}}|�d�r|�qSr|ryr}rrrr�rCcSsg|]\}}|�d�r|�qSr|ryr}rrrr�rC)�logz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation)rIr^�anyr r�indexrFr`�reversed�range�lenr� enumerater�isdirZ distutilsr��warn) Z compiler_soZcc_argsZ stripArchZ stripSysrootr��idx�indicesZsysrootZargvarr�rrrrfsZ       � rcCs"t�st|�t|�t|�|Sr<)r^rortrw�rLrrrr�s rcCst|�t|�t|�|Sr<)rirqrtr�rrrr�s rcCs�|�dd�}t�p|}|p|}|�r�|}d}|�td|�dd��}|r�z$tdd�|�d�dd �D��}Wq�ty�d }Yq�0nd }|d k�rDd |��v�rDd }t�d|�}tt t |���}t |�dkr�|d}nj|dkr�d}n\|dkr�d }nN|dk�rd}n>|dk�rd}n.|dk�r$d}n|dk�r4d}ntd|f��n<|dk�r`t j dk�r�d}n |dv�r�t j dk�r|d }nd!}|||fS)"NZMACOSX_DEPLOYMENT_TARGETr/Zmacosxrcss|]}t|�VqdSr<r=r?rrrrBrCz#get_platform_osx..r1rr3)r[rrZrsZfatz -arch\s+(\S+)r2)r{�x86_64Z universal2)�i386�ppc)r�r�Zintel)r�r�r�Zfat3)�ppc64r�Zfat64)r�r�r�r�� universalz%Don't know machine value for archs=%rr�lr�)ZPowerPCZPower_Macintoshr�r�)rOr;rKrErrFr+r6�findall�sorted�setr�r�maxsize)rLZosname�release�machineZmacverZ macreleaservZarchsrrrr�sX    �$         �    r)N)F)r r6r�__all__rlrgrKrr.r0r4r;rDrHrNrQrSrYr^r`rirorqrtrwrrrrrrrr�s8      >(Q)