File size: 740 Bytes
d1ed09d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import importlib.metadata
import sys

from packaging.version import parse as parse_version

_PY_VERSION = parse_version(".".join(map(str, sys.version_info[:3])))

_EMSCRIPTEN = sys.platform == "emscripten"


def entry_points(group=None):
    """Returns an iterable of entrypoints.

    For compatibility with Python 3.8/3.9.
    In 3.10 the return type changed from a dict to an ``importlib.metadata.EntryPoints``.
    This compatibility utility can be removed once Python 3.10 is the minimum.
    """
    if _PY_VERSION >= parse_version("3.10"):
        return importlib.metadata.entry_points(group=group)
    else:
        eps = importlib.metadata.entry_points()
        if group:
            return eps.get(group, [])
        return eps