SILENT KILLERPanel

Current Path: > > opt > > hc_python > lib > python3.12 > site-packages > wheel > vendored > packaging


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt//hc_python/lib/python3.12/site-packages/wheel/vendored/packaging

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
LICENSE File 197 bytes April 04 2025 08:02:22.
LICENSE.APACHE File 10174 bytes April 04 2025 08:02:22.
LICENSE.BSD File 1344 bytes April 04 2025 08:02:22.
__init__.py File 0 bytes April 04 2025 08:02:22.
_elffile.py File 3266 bytes April 04 2025 08:02:22.
_manylinux.py File 9588 bytes April 04 2025 08:02:22.
_musllinux.py File 2674 bytes April 04 2025 08:02:22.
_parser.py File 10347 bytes April 04 2025 08:02:22.
_structures.py File 1431 bytes April 04 2025 08:02:22.
_tokenizer.py File 5292 bytes April 04 2025 08:02:22.
markers.py File 8232 bytes April 04 2025 08:02:22.
requirements.py File 2933 bytes April 04 2025 08:02:22.
specifiers.py File 39778 bytes April 04 2025 08:02:22.
tags.py File 18950 bytes April 04 2025 08:02:22.
utils.py File 5268 bytes April 04 2025 08:02:22.
version.py File 16234 bytes April 04 2025 08:02:22.

Reading File: //opt//hc_python/lib/python3.12/site-packages/wheel/vendored/packaging/_musllinux.py

"""PEP 656 support.

This module implements logic to detect if the currently running Python is
linked against musl, and what musl version is used.
"""

import functools
import re
import subprocess
import sys
from typing import Iterator, NamedTuple, Optional, Sequence

from ._elffile import ELFFile


class _MuslVersion(NamedTuple):
    major: int
    minor: int


def _parse_musl_version(output: str) -> Optional[_MuslVersion]:
    lines = [n for n in (n.strip() for n in output.splitlines()) if n]
    if len(lines) < 2 or lines[0][:4] != "musl":
        return None
    m = re.match(r"Version (\d+)\.(\d+)", lines[1])
    if not m:
        return None
    return _MuslVersion(major=int(m.group(1)), minor=int(m.group(2)))


@functools.lru_cache
def _get_musl_version(executable: str) -> Optional[_MuslVersion]:
    """Detect currently-running musl runtime version.

    This is done by checking the specified executable's dynamic linking
    information, and invoking the loader to parse its output for a version
    string. If the loader is musl, the output would be something like::

        musl libc (x86_64)
        Version 1.2.2
        Dynamic Program Loader
    """
    try:
        with open(executable, "rb") as f:
            ld = ELFFile(f).interpreter
    except (OSError, TypeError, ValueError):
        return None
    if ld is None or "musl" not in ld:
        return None
    proc = subprocess.run([ld], stderr=subprocess.PIPE, text=True)
    return _parse_musl_version(proc.stderr)


def platform_tags(archs: Sequence[str]) -> Iterator[str]:
    """Generate musllinux tags compatible to the current platform.

    :param archs: Sequence of compatible architectures.
        The first one shall be the closest to the actual architecture and be the part of
        platform tag after the ``linux_`` prefix, e.g. ``x86_64``.
        The ``linux_`` prefix is assumed as a prerequisite for the current platform to
        be musllinux-compatible.

    :returns: An iterator of compatible musllinux tags.
    """
    sys_musl = _get_musl_version(sys.executable)
    if sys_musl is None:  # Python not dynamically linked against musl.
        return
    for arch in archs:
        for minor in range(sys_musl.minor, -1, -1):
            yield f"musllinux_{sys_musl.major}_{minor}_{arch}"


if __name__ == "__main__":  # pragma: no cover
    import sysconfig

    plat = sysconfig.get_platform()
    assert plat.startswith("linux-"), "not linux"

    print("plat:", plat)
    print("musl:", _get_musl_version(sys.executable))
    print("tags:", end=" ")
    for t in platform_tags(re.sub(r"[.-]", "_", plat.split("-", 1)[-1])):
        print(t, end="\n      ")

SILENT KILLER Tool