logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

_aix_support.py (3270B)


  1. """Shared AIX support functions."""
  2. import sys
  3. import sysconfig
  4. try:
  5. import subprocess
  6. except ImportError: # pragma: no cover
  7. # _aix_support is used in distutils by setup.py to build C extensions,
  8. # before subprocess dependencies like _posixsubprocess are available.
  9. import _bootsubprocess as subprocess
  10. def _aix_tag(vrtl, bd):
  11. # type: (List[int], int) -> str
  12. # Infer the ABI bitwidth from maxsize (assuming 64 bit as the default)
  13. _sz = 32 if sys.maxsize == (2**31-1) else 64
  14. # vrtl[version, release, technology_level]
  15. return "aix-{:1x}{:1d}{:02d}-{:04d}-{}".format(vrtl[0], vrtl[1], vrtl[2], bd, _sz)
  16. # extract version, release and technology level from a VRMF string
  17. def _aix_vrtl(vrmf):
  18. # type: (str) -> List[int]
  19. v, r, tl = vrmf.split(".")[:3]
  20. return [int(v[-1]), int(r), int(tl)]
  21. def _aix_bosmp64():
  22. # type: () -> Tuple[str, int]
  23. """
  24. Return a Tuple[str, int] e.g., ['7.1.4.34', 1806]
  25. The fileset bos.mp64 is the AIX kernel. It's VRMF and builddate
  26. reflect the current ABI levels of the runtime environment.
  27. """
  28. # We expect all AIX systems to have lslpp installed in this location
  29. out = subprocess.check_output(["/usr/bin/lslpp", "-Lqc", "bos.mp64"])
  30. out = out.decode("utf-8")
  31. out = out.strip().split(":") # type: ignore
  32. # Use str() and int() to help mypy see types
  33. return (str(out[2]), int(out[-1]))
  34. def aix_platform():
  35. # type: () -> str
  36. """
  37. AIX filesets are identified by four decimal values: V.R.M.F.
  38. V (version) and R (release) can be retreived using ``uname``
  39. Since 2007, starting with AIX 5.3 TL7, the M value has been
  40. included with the fileset bos.mp64 and represents the Technology
  41. Level (TL) of AIX. The F (Fix) value also increases, but is not
  42. relevant for comparing releases and binary compatibility.
  43. For binary compatibility the so-called builddate is needed.
  44. Again, the builddate of an AIX release is associated with bos.mp64.
  45. AIX ABI compatibility is described as guaranteed at: https://www.ibm.com/\
  46. support/knowledgecenter/en/ssw_aix_72/install/binary_compatability.html
  47. For pep425 purposes the AIX platform tag becomes:
  48. "aix-{:1x}{:1d}{:02d}-{:04d}-{}".format(v, r, tl, builddate, bitsize)
  49. e.g., "aix-6107-1415-32" for AIX 6.1 TL7 bd 1415, 32-bit
  50. and, "aix-6107-1415-64" for AIX 6.1 TL7 bd 1415, 64-bit
  51. """
  52. vrmf, bd = _aix_bosmp64()
  53. return _aix_tag(_aix_vrtl(vrmf), bd)
  54. # extract vrtl from the BUILD_GNU_TYPE as an int
  55. def _aix_bgt():
  56. # type: () -> List[int]
  57. gnu_type = sysconfig.get_config_var("BUILD_GNU_TYPE")
  58. if not gnu_type:
  59. raise ValueError("BUILD_GNU_TYPE is not defined")
  60. return _aix_vrtl(vrmf=gnu_type)
  61. def aix_buildtag():
  62. # type: () -> str
  63. """
  64. Return the platform_tag of the system Python was built on.
  65. """
  66. # AIX_BUILDDATE is defined by configure with:
  67. # lslpp -Lcq bos.mp64 | awk -F: '{ print $NF }'
  68. build_date = sysconfig.get_config_var("AIX_BUILDDATE")
  69. try:
  70. build_date = int(build_date)
  71. except (ValueError, TypeError):
  72. raise ValueError(f"AIX_BUILDDATE is not defined or invalid: "
  73. f"{build_date!r}")
  74. return _aix_tag(_aix_bgt(), build_date)