mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-01-06 11:09:57 -08:00
e69852fa0e
* Bump importlib-metadata from 8.2.0 to 8.5.0 Bumps [importlib-metadata](https://github.com/python/importlib_metadata) from 8.2.0 to 8.5.0. - [Release notes](https://github.com/python/importlib_metadata/releases) - [Changelog](https://github.com/python/importlib_metadata/blob/main/NEWS.rst) - [Commits](https://github.com/python/importlib_metadata/compare/v8.2.0...v8.5.0) --- updated-dependencies: - dependency-name: importlib-metadata dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update importlib-metadata==8.5.0 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
import platform
|
|
import sys
|
|
|
|
__all__ = ['install', 'NullFinder']
|
|
|
|
|
|
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 "MetaPathFinder") that never finds any modules,
|
|
but may find distributions.
|
|
"""
|
|
|
|
@staticmethod
|
|
def find_spec(*args, **kwargs):
|
|
return None
|
|
|
|
|
|
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
|