Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._internal.utils.packaging Namespace Reference

Functions

bool check_requires_python (Optional[str] requires_python, Tuple[int,...] version_info)
 
Requirement get_requirement (str req_string)
 
NormalizedExtra safe_extra (str extra)
 

Variables

 NormalizedExtra = NewType("NormalizedExtra", str)
 
 logger = logging.getLogger(__name__)
 

Function Documentation

◆ check_requires_python()

bool check_requires_python ( Optional[str]  requires_python,
Tuple[int, ...]   version_info 
)
Check if the given Python version matches a "Requires-Python" specifier.

:param version_info: A 3-tuple of ints representing a Python
    major-minor-micro version to check (e.g. `sys.version_info[:3]`).

:return: `True` if the given Python version satisfies the requirement.
    Otherwise, return `False`.

:raises InvalidSpecifier: If `requires_python` has an invalid format.

Definition at line 14 of file packaging.py.

16) -> bool:
17 """
18 Check if the given Python version matches a "Requires-Python" specifier.
19
20 :param version_info: A 3-tuple of ints representing a Python
21 major-minor-micro version to check (e.g. `sys.version_info[:3]`).
22
23 :return: `True` if the given Python version satisfies the requirement.
24 Otherwise, return `False`.
25
26 :raises InvalidSpecifier: If `requires_python` has an invalid format.
27 """
28 if requires_python is None:
29 # The package provides no information
30 return True
31 requires_python_specifier = specifiers.SpecifierSet(requires_python)
32
33 python_version = version.parse(".".join(map(str, version_info)))
34 return python_version in requires_python_specifier
35
36
37@functools.lru_cache(maxsize=512)
for i

References i.

◆ get_requirement()

Requirement get_requirement ( str  req_string)
Construct a packaging.Requirement object with caching

Definition at line 38 of file packaging.py.

38def get_requirement(req_string: str) -> Requirement:
39 """Construct a packaging.Requirement object with caching"""
40 # Parsing requirement strings is expensive, and is also expected to happen
41 # with a low diversity of different arguments (at least relative the number
42 # constructed). This method adds a cache to requirement object creation to
43 # minimize repeated parsing of the same string to construct equivalent
44 # Requirement objects.
45 return Requirement(req_string)
46
47

◆ safe_extra()

NormalizedExtra safe_extra ( str  extra)
Convert an arbitrary string to a standard 'extra' name

Any runs of non-alphanumeric characters are replaced with a single '_',
and the result is always lowercased.

This function is duplicated from ``pkg_resources``. Note that this is not
the same to either ``canonicalize_name`` or ``_egg_link_name``.

Definition at line 48 of file packaging.py.

48def safe_extra(extra: str) -> NormalizedExtra:
49 """Convert an arbitrary string to a standard 'extra' name
50
51 Any runs of non-alphanumeric characters are replaced with a single '_',
52 and the result is always lowercased.
53
54 This function is duplicated from ``pkg_resources``. Note that this is not
55 the same to either ``canonicalize_name`` or ``_egg_link_name``.
56 """
57 return cast(NormalizedExtra, re.sub("[^A-Za-z0-9.-]+", "_", extra).lower())

References i.

Variable Documentation

◆ logger

logger = logging.getLogger(__name__)

Definition at line 11 of file packaging.py.

◆ NormalizedExtra

NormalizedExtra = NewType("NormalizedExtra", str)

Definition at line 9 of file packaging.py.