o
    éT•jÆ  ã                   @   sp   d Z ddlZddlZzddlZW n ey   ddlZY nw dd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ ZdS )zShared AIX support functions.é    Nc                 C   s0   t jdkrdnd}d | d | d | d ||¡S )Niÿÿÿé    é@   zaix-{:1x}{:1d}{:02d}-{:04d}-{}r   é   é   )ÚsysÚmaxsizeÚformat)ÚvrtlÚbdÚ_sz© r   ú#/usr/lib/python3.10/_aix_support.pyÚ_aix_tag   s   r   c                 C   s2   |   d¡d d… \}}}t|d ƒt|ƒt|ƒgS )NÚ.é   éÿÿÿÿ)ÚsplitÚint)ÚvrmfÚvÚrÚtlr   r   r   Ú	_aix_vrtl   s   r   c                  C   s>   t  g d¢¡} |  d¡} |  ¡  d¡} t| d ƒt| d ƒfS )z¾
    Return a Tuple[str, int] e.g., ['7.1.4.34', 1806]
    The fileset bos.mp64 is the AIX kernel. It's VRMF and builddate
    reflect the current ABI levels of the runtime environment.
    )z/usr/bin/lslppz-Lqczbos.mp64zutf-8ú:r   r   )Ú
subprocessÚcheck_outputÚdecodeÚstripr   Ústrr   )Úoutr   r   r   Ú_aix_bosmp64   s   
r    c                  C   s   t ƒ \} }tt| ƒ|ƒS )aª  
    AIX filesets are identified by four decimal values: V.R.M.F.
    V (version) and R (release) can be retreived using ``uname``
    Since 2007, starting with AIX 5.3 TL7, the M value has been
    included with the fileset bos.mp64 and represents the Technology
    Level (TL) of AIX. The F (Fix) value also increases, but is not
    relevant for comparing releases and binary compatibility.
    For binary compatibility the so-called builddate is needed.
    Again, the builddate of an AIX release is associated with bos.mp64.
    AIX ABI compatibility is described  as guaranteed at: https://www.ibm.com/    support/knowledgecenter/en/ssw_aix_72/install/binary_compatability.html

    For pep425 purposes the AIX platform tag becomes:
    "aix-{:1x}{:1d}{:02d}-{:04d}-{}".format(v, r, tl, builddate, bitsize)
    e.g., "aix-6107-1415-32" for AIX 6.1 TL7 bd 1415, 32-bit
    and, "aix-6107-1415-64" for AIX 6.1 TL7 bd 1415, 64-bit
    )r    r   r   )r   r
   r   r   r   Úaix_platform,   s   
r!   c                  C   s    t  d¡} | stdƒ‚t| d�S )NÚBUILD_GNU_TYPEzBUILD_GNU_TYPE is not defined)r   )Ú	sysconfigÚget_config_varÚ
ValueErrorr   )Úgnu_typer   r   r   Ú_aix_bgtD   s   

r'   c               	   C   sD   t  d¡} zt| ƒ} W n ttfy   td| ›�ƒ‚w ttƒ | ƒS )zD
    Return the platform_tag of the system Python was built on.
    ÚAIX_BUILDDATEz)AIX_BUILDDATE is not defined or invalid: )r#   r$   r   r%   Ú	TypeErrorr   r'   )Ú
build_dater   r   r   Úaix_buildtagL   s   
ÿÿr+   )Ú__doc__r   r#   r   ÚImportErrorÚ_bootsubprocessr   r   r    r!   r'   r+   r   r   r   r   Ú<module>   s    ý	