
    Rh                     D    d Z ddlZddlZd
dZd Zd Zd Zd Zd Zd	 Z	y)zShared AIX support functions.    Nc                 .   ddl }ddl}t        d|j                         d      }|j	                  |      5 }|r| d|j
                  d}n| d|j
                  d}|j                  |      s|j                         ndcddd       S # 1 sw Y   yxY w)	z0Output from successful command execution or Noner   Nz/tmp/_aix_support.zw+bz >'z' 2>&1z 2>/dev/null >'')os
contextlibopengetpidclosingnamesystemread)commandstringcapture_stderrr   r   fpcmds         #/usr/lib/python3.12/_aix_support.py_read_cmd_outputr      s    
 	
		
B 
		B	 92%2BGG<C,9277CC "		#rwwyD9 9 9s   A
BBc                 ~    t         j                  dk(  rdnd}|dk7  r|nd}dj                  | d   | d   | d   ||      S )	Ni    @   r   '  zaix-{:1x}{:1d}{:02d}-{:04d}-{}      )sysmaxsizeformat)vrtlbd_sz_bds       r   _aix_tagr       sI     ("bCa"TC+2247DGT!WcSVWW    c                 x    | j                  d      d d \  }}}t        |d         t        |      t        |      gS )N.   )splitint)vrmfvrtls       r   	_aix_vrtlr,   $   s9    zz#r"HAq""JAB((r!   c                     	 ddl } | j                  g d      }|j	                  d      }|j                         j                  d      }|d   dk7  rt        |d         nd	}t        |d
         |fS # t        $ r t        d      }Y nw xY w)a(  
    Return a Tuple[str, int] e.g., ['7.1.4.34', 1806]
    The fileset bos.rte represents the current AIX run-time level. It's VRMF and
    builddate reflect the current ABI levels of the runtime environment.
    If no builddate is found give a value that will satisfy pep425 related queries
    r   N)z/usr/bin/lslppz-Lqczbos.rtez/usr/bin/lslpp -Lqc bos.rtezutf-8:r%    r   r   )	
subprocesscheck_outputImportErrorr   decodestripr&   r'   str)r0   outr   s      r   _aix_bos_rter7   *   s    >%%&KL **W
C
))+

C
 Cb'R-#c"g,TCAK  ><=>s   A1 1BBc                  F    t               \  } }t        t        |       |      S )a  
    AIX filesets are identified by four decimal values: V.R.M.F.
    V (version) and R (release) can be retrieved using ``uname``
    Since 2007, starting with AIX 5.3 TL7, the M value has been
    included with the fileset bos.rte 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.rte.
    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
    )r7   r    r,   )r(   r   s     r   aix_platformr9   ?   s     & ~HD"IdOR((r!   c                  ^    t        j                  d      } | st        d      t        |       S )NBUILD_GNU_TYPEzBUILD_GNU_TYPE is not defined)r(   )	sysconfigget_config_var
ValueErrorr,   )gnu_types    r   _aix_bgtr@   W   s-    ''(89H899(##r!   c                      t        j                  d      } 	 t        |       } t        t               |       S # t        t        f$ r t        d|       w xY w)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_dates    r   aix_buildtagrE   _   sc     ))/:J,_
 HJ
++ 	" ,D&>+ , 	,,s	   6 A)F)
__doc__r   r<   r   r    r,   r7   r9   r@   rE    r!   r   <module>rH      s2    # 
 9$X)*)0$,r!   