PHP 8.2.30
Preview: _compat.py Size: 1.82 KB
/opt/alt/python312/lib/python3.12/site-packages/setuptools/_vendor/importlib_metadata/_compat.py

import sys
import platform


__all__ = ['install', 'NullFinder', 'Protocol']


try:
    from typing import Protocol
except ImportError:  # pragma: no cover
    # Python 3.7 compatibility
    from ..typing_extensions import Protocol  # type: ignore


def install(cls):
    """
    Class decorator for installation on sys.meta_path.

    Adds the backport DistributionFinder to sys.meta_path and
    attempts to disable the finder functionality of the stdlib
    DistributionFinder.
    """
    sys.meta_path.append(cls())
    disable_stdlib_finder()
    return cls


def disable_stdlib_finder():
    """
    Give the backport primacy for discovering path-based distributions
    by monkey-patching the stdlib O_O.

    See #91 for more background for rationale on this sketchy
    behavior.
    """

    def matches(finder):
        return getattr(
            finder, '__module__', None
        ) == '_frozen_importlib_external' and hasattr(finder, 'find_distributions')

    for finder in filter(matches, sys.meta_path):  # pragma: nocover
        del finder.find_distributions


class NullFinder:
    """
    A "Finder" (aka "MetaClassFinder") that never finds any modules,
    but may find distributions.
    """

    @staticmethod
    def find_spec(*args, **kwargs):
        return None

    # In Python 2, the import system requires finders
    # to have a find_module() method, but this usage
    # is deprecated in Python 3 in favor of find_spec().
    # For the purposes of this finder (i.e. being present
    # on sys.meta_path but having no other import
    # system functionality), the two methods are identical.
    find_module = find_spec


def pypy_partial(val):
    """
    Adjust for variable stacklevel on partial under PyPy.

    Workaround for #327.
    """
    is_pypy = platform.python_implementation() == 'PyPy'
    return val + is_pypy

Directory Contents

Dirs: 1 × Files: 10

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-10 08:06:45
Edit Download
0 B lrw-r--r-- 2026-01-08 18:42:35
Edit Download
2.40 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download
743 B lrw-r--r-- 2026-01-08 18:42:35
Edit Download
1.82 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download
2.83 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download
2.02 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download
1.14 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download
1.07 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download
2.12 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download
25.88 KB lrw-r--r-- 2026-01-08 18:42:35
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).