How to use the packaging.tags function in packaging

To help you get started, we’ve selected a few packaging examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / packaging / tests / test_tags.py View on Github external
def test_is_linux_i686_not_elf(self, monkeypatch):
        monkeypatch.setattr(tags, "_get_elf_header", lambda: None)
        assert not tags._is_linux_i686()
github pypa / packaging / tests / test_tags.py View on Github external
def test_arch_detection(self, arch, monkeypatch):
        if platform.system() != "Darwin" or platform.mac_ver()[2] != arch:
            monkeypatch.setattr(
                platform, "mac_ver", lambda: ("10.14", ("", "", ""), arch)
            )
            monkeypatch.setattr(tags, "_mac_arch", lambda *args: arch)
        assert next(tags.mac_platforms((10, 14))).endswith(arch)
github pypa / packaging / tests / test_tags.py View on Github external
def test_is_linux_armhf_not_elf(self, monkeypatch):
        monkeypatch.setattr(tags, "_get_elf_header", lambda: None)
        assert not tags._is_linux_armhf()
github pypa / packaging / tests / test_tags.py View on Github external
def test_interpreter_name(self, name, expected, mock_interpreter_name):
        mock_interpreter_name(name)
        assert tags.interpreter_name() == expected
github pypa / packaging / tests / test_tags.py View on Github external
def test_generic(self, monkeypatch):
        monkeypatch.setattr(platform, "system", lambda: "Generic")
        monkeypatch.setattr(tags, "interpreter_name", lambda: "generic")

        result = list(tags.sys_tags())
        expected = tags.Tag(
            "py" + tags._version_nodot((sys.version_info[0], 0)), "none", "any"
        )
        assert result[-1] == expected
github pypa / packaging / tests / test_tags.py View on Github external
def test_check_glibc_version_warning(self, version_str):
        with warnings.catch_warnings(record=True) as w:
            tags._parse_glibc_version(version_str)
            assert len(w) == 1
            assert issubclass(w[0].category, RuntimeWarning)
github pypa / packaging / tests / test_tags.py View on Github external
def test_glibc_version_string_ctypes_missing(self, monkeypatch):
        monkeypatch.setitem(sys.modules, "ctypes", None)
        assert tags._glibc_version_string_ctypes() is None
github sarugaku / resolvelib / tests / functional / python / py2index.py View on Github external
def _parse_tag(s: str) -> Set[packaging.tags.Tag]:
    try:
        return packaging.tags.parse_tag(s)
    except ValueError:
        raise ValueError(f"invalid tag {s!r}")
github pypa / wheel / src / wheel / bdist_wheel.py View on Github external
plat_name = get_platform(self.bdist_dir)

            if plat_name in ('linux-x86_64', 'linux_x86_64') and sys.maxsize == 2147483647:
                plat_name = 'linux_i686'

        plat_name = plat_name.replace('-', '_').replace('.', '_')

        if self.root_is_pure:
            if self.universal:
                impl = 'py2.py3'
            else:
                impl = self.python_tag
            tag = (impl, 'none', plat_name)
        else:
            impl_name = tags.interpreter_name()
            impl_ver = tags.interpreter_version()
            impl = impl_name + impl_ver
            # We don't work on CPython 3.1, 3.0.
            if self.py_limited_api and (impl_name + impl_ver).startswith('cp3'):
                impl = self.py_limited_api
                abi_tag = 'abi3'
            else:
                abi_tag = str(get_abi_tag()).lower()
            tag = (impl, abi_tag, plat_name)
            supported_tags = [(t.interpreter, t.abi, t.platform)
                              for t in tags.sys_tags()]
            assert tag in supported_tags, "would build wheel with unsupported tag {}".format(tag)
        return tag
github blue-yonder / devpi-builder / devpi_builder / wheeler.py View on Github external
def is_compatible(package):
    """
    Check whether the given python package is a wheel compatible with the
    current platform and python interpreter.

    Compatibility is based on https://www.python.org/dev/peps/pep-0425/
    """
    try:
        w = parse_wheel_filename(package)
        for systag in tags.sys_tags():
            for tag in w.tag_triples():
                if systag in tags.parse_tag(tag):
                    return True
    except InvalidFilenameError:
        return False