def _is_compatible_platform_tag()

in aws_lambda_builders/workflows/python_pip/packager.py [0:0]


    def _is_compatible_platform_tag(self, expected_abi, platform):
        """
        Verify if a platform tag is compatible based on PEP 600
        https://www.python.org/dev/peps/pep-0600/#specification

        In addition to checking the tag pattern, we also need to verify the glibc version
        """
        if platform in self._COMPATIBLE_PLATFORMS[self.architecture]:
            return True

        arch = "aarch64" if self.architecture == ARM64 else "x86_64"

        # Verify the tag pattern
        # Try to get the matching value for legacy values or keep the current
        perennial_tag = self._MANYLINUX_LEGACY_MAP.get(platform, platform)

        match = re.match("manylinux_([0-9]+)_([0-9]+)_" + arch, perennial_tag)
        if match is None:
            return False

        # Get the glibc major and minor versions and compare them with the expected ABI
        # platform: manylinux_2_17_aarch64 -> 2 and 17
        # expected_abi: cp37m -> compat glibc -> 2 and 17
        # -> Compatible
        tag_major, tag_minor = [int(x) for x in match.groups()[:2]]
        runtime_major, runtime_minor = self._RUNTIME_GLIBC.get(expected_abi, self._DEFAULT_GLIBC)

        return (tag_major, tag_minor) <= (runtime_major, runtime_minor)