Skip to content

Library import 250505-0050 #17983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions contrib/python/packaging/py3/.dist-info/METADATA
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.3
Metadata-Version: 2.4
Name: packaging
Version: 24.2
Version: 25.0
Summary: Core utilities for Python packages
Author-email: Donald Stufft <[email protected]>
Requires-Python: >=3.8
Expand All @@ -21,6 +21,9 @@ Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Typing :: Typed
License-File: LICENSE
License-File: LICENSE.APACHE
License-File: LICENSE.BSD
Project-URL: Documentation, https://packaging.pypa.io/
Project-URL: Source, https://github.com/pypa/packaging

Expand Down
2 changes: 1 addition & 1 deletion contrib/python/packaging/py3/packaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__summary__ = "Core utilities for Python packages"
__uri__ = "https://github.com/pypa/packaging"

__version__ = "24.2"
__version__ = "25.0"

__author__ = "Donald Stufft and individual contributors"
__email__ = "[email protected]"
Expand Down
3 changes: 1 addition & 2 deletions contrib/python/packaging/py3/packaging/_elffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def __init__(self, f: IO[bytes]) -> None:
}[(self.capacity, self.encoding)]
except KeyError as e:
raise ELFInvalid(
f"unrecognized capacity ({self.capacity}) or "
f"encoding ({self.encoding})"
f"unrecognized capacity ({self.capacity}) or encoding ({self.encoding})"
) from e

try:
Expand Down
3 changes: 1 addition & 2 deletions contrib/python/packaging/py3/packaging/_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ def _parse_glibc_version(version_str: str) -> tuple[int, int]:
m = re.match(r"(?P<major>[0-9]+)\.(?P<minor>[0-9]+)", version_str)
if not m:
warnings.warn(
f"Expected glibc version with 2 components major.minor,"
f" got: {version_str}",
f"Expected glibc version with 2 components major.minor, got: {version_str}",
RuntimeWarning,
stacklevel=2,
)
Expand Down
3 changes: 1 addition & 2 deletions contrib/python/packaging/py3/packaging/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,5 @@ def _parse_marker_op(tokenizer: Tokenizer) -> Op:
return Op(tokenizer.read().text)
else:
return tokenizer.raise_syntax_error(
"Expected marker operator, one of "
"<=, <, !=, ==, >=, >, ~=, ===, in, not in"
"Expected marker operator, one of <=, <, !=, ==, >=, >, ~=, ===, in, not in"
)
9 changes: 5 additions & 4 deletions contrib/python/packaging/py3/packaging/_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def __str__(self) -> str:
|platform[._](version|machine|python_implementation)
|python_implementation
|implementation_(name|version)
|extra
|extras?
|dependency_groups
)\b
""",
re.VERBOSE,
Expand Down Expand Up @@ -119,9 +120,9 @@ def check(self, name: str, *, peek: bool = False) -> bool:
another check. If `peek` is set to `True`, the token is not loaded and
would need to be checked again.
"""
assert (
self.next_token is None
), f"Cannot check for {name!r}, already have {self.next_token!r}"
assert self.next_token is None, (
f"Cannot check for {name!r}, already have {self.next_token!r}"
)
assert name in self.rules, f"Unknown token name: {name!r}"

expression = self.rules[name]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
from packaging.licenses._spdx import EXCEPTIONS, LICENSES

__all__ = [
"NormalizedLicenseExpression",
"InvalidLicenseExpression",
"NormalizedLicenseExpression",
"canonicalize_license_expression",
]

Expand Down
75 changes: 53 additions & 22 deletions contrib/python/packaging/py3/packaging/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import platform
import sys
from typing import Any, Callable, TypedDict, cast
from typing import AbstractSet, Any, Callable, Literal, TypedDict, Union, cast

from ._parser import MarkerAtom, MarkerList, Op, Value, Variable
from ._parser import parse_marker as _parse_marker
Expand All @@ -17,14 +17,17 @@
from .utils import canonicalize_name

__all__ = [
"EvaluateContext",
"InvalidMarker",
"Marker",
"UndefinedComparison",
"UndefinedEnvironmentName",
"default_environment",
]

Operator = Callable[[str, str], bool]
Operator = Callable[[str, Union[str, AbstractSet[str]]], bool]
EvaluateContext = Literal["metadata", "lock_file", "requirement"]
MARKERS_ALLOWING_SET = {"extras", "dependency_groups"}


class InvalidMarker(ValueError):
Expand Down Expand Up @@ -174,13 +177,14 @@ def _format_marker(
}


def _eval_op(lhs: str, op: Op, rhs: str) -> bool:
try:
spec = Specifier("".join([op.serialize(), rhs]))
except InvalidSpecifier:
pass
else:
return spec.contains(lhs, prereleases=True)
def _eval_op(lhs: str, op: Op, rhs: str | AbstractSet[str]) -> bool:
if isinstance(rhs, str):
try:
spec = Specifier("".join([op.serialize(), rhs]))
except InvalidSpecifier:
pass
else:
return spec.contains(lhs, prereleases=True)

oper: Operator | None = _operators.get(op.serialize())
if oper is None:
Expand All @@ -189,19 +193,29 @@ def _eval_op(lhs: str, op: Op, rhs: str) -> bool:
return oper(lhs, rhs)


def _normalize(*values: str, key: str) -> tuple[str, ...]:
def _normalize(
lhs: str, rhs: str | AbstractSet[str], key: str
) -> tuple[str, str | AbstractSet[str]]:
# PEP 685 – Comparison of extra names for optional distribution dependencies
# https://peps.python.org/pep-0685/
# > When comparing extra names, tools MUST normalize the names being
# > compared using the semantics outlined in PEP 503 for names
if key == "extra":
return tuple(canonicalize_name(v) for v in values)
assert isinstance(rhs, str), "extra value must be a string"
return (canonicalize_name(lhs), canonicalize_name(rhs))
if key in MARKERS_ALLOWING_SET:
if isinstance(rhs, str): # pragma: no cover
return (canonicalize_name(lhs), canonicalize_name(rhs))
else:
return (canonicalize_name(lhs), {canonicalize_name(v) for v in rhs})

# other environment markers don't have such standards
return values
return lhs, rhs


def _evaluate_markers(markers: MarkerList, environment: dict[str, str]) -> bool:
def _evaluate_markers(
markers: MarkerList, environment: dict[str, str | AbstractSet[str]]
) -> bool:
groups: list[list[bool]] = [[]]

for marker in markers:
Expand All @@ -220,7 +234,7 @@ def _evaluate_markers(markers: MarkerList, environment: dict[str, str]) -> bool:
lhs_value = lhs.value
environment_key = rhs.value
rhs_value = environment[environment_key]

assert isinstance(lhs_value, str), "lhs must be a string"
lhs_value, rhs_value = _normalize(lhs_value, rhs_value, key=environment_key)
groups[-1].append(_eval_op(lhs_value, op, rhs_value))
else:
Expand Down Expand Up @@ -298,34 +312,51 @@ def __eq__(self, other: Any) -> bool:

return str(self) == str(other)

def evaluate(self, environment: dict[str, str] | None = None) -> bool:
def evaluate(
self,
environment: dict[str, str] | None = None,
context: EvaluateContext = "metadata",
) -> bool:
"""Evaluate a marker.

Return the boolean from evaluating the given marker against the
environment. environment is an optional argument to override all or
part of the determined environment.
part of the determined environment. The *context* parameter specifies what
context the markers are being evaluated for, which influences what markers
are considered valid. Acceptable values are "metadata" (for core metadata;
default), "lock_file", and "requirement" (i.e. all other situations).

The environment is determined from the current Python process.
"""
current_environment = cast("dict[str, str]", default_environment())
current_environment["extra"] = ""
current_environment = cast(
"dict[str, str | AbstractSet[str]]", default_environment()
)
if context == "lock_file":
current_environment.update(
extras=frozenset(), dependency_groups=frozenset()
)
elif context == "metadata":
current_environment["extra"] = ""
if environment is not None:
current_environment.update(environment)
# The API used to allow setting extra to None. We need to handle this
# case for backwards compatibility.
if current_environment["extra"] is None:
if "extra" in current_environment and current_environment["extra"] is None:
current_environment["extra"] = ""

return _evaluate_markers(
self._markers, _repair_python_full_version(current_environment)
)


def _repair_python_full_version(env: dict[str, str]) -> dict[str, str]:
def _repair_python_full_version(
env: dict[str, str | AbstractSet[str]],
) -> dict[str, str | AbstractSet[str]]:
"""
Work around platform.python_version() returning something that is not PEP 440
compliant for non-tagged Python builds.
"""
if env["python_full_version"].endswith("+"):
env["python_full_version"] += "local"
python_full_version = cast(str, env["python_full_version"])
if python_full_version.endswith("+"):
env["python_full_version"] = f"{python_full_version}local"
return env
3 changes: 1 addition & 2 deletions contrib/python/packaging/py3/packaging/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,7 @@ def _process_license_files(self, value: list[str]) -> list[str]:
)
if pathlib.PureWindowsPath(path).as_posix() != path:
raise self._invalid_metadata(
f"{path!r} is invalid for {{field}}, "
"paths must use '/' delimiter"
f"{path!r} is invalid for {{field}}, paths must use '/' delimiter"
)
paths.append(path)
return paths
Expand Down
3 changes: 1 addition & 2 deletions contrib/python/packaging/py3/packaging/specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ def __and__(self, other: SpecifierSet | str) -> SpecifierSet:
specifier._prereleases = self._prereleases
else:
raise ValueError(
"Cannot combine SpecifierSets with True and False prerelease "
"overrides."
"Cannot combine SpecifierSets with True and False prerelease overrides."
)

return specifier
Expand Down
39 changes: 39 additions & 0 deletions contrib/python/packaging/py3/packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,43 @@ def ios_platforms(
)


def android_platforms(
api_level: int | None = None, abi: str | None = None
) -> Iterator[str]:
"""
Yields the :attr:`~Tag.platform` tags for Android. If this function is invoked on
non-Android platforms, the ``api_level`` and ``abi`` arguments are required.

:param int api_level: The maximum `API level
<https://developer.android.com/tools/releases/platforms>`__ to return. Defaults
to the current system's version, as returned by ``platform.android_ver``.
:param str abi: The `Android ABI <https://developer.android.com/ndk/guides/abis>`__,
e.g. ``arm64_v8a``. Defaults to the current system's ABI , as returned by
``sysconfig.get_platform``. Hyphens and periods will be replaced with
underscores.
"""
if platform.system() != "Android" and (api_level is None or abi is None):
raise TypeError(
"on non-Android platforms, the api_level and abi arguments are required"
)

if api_level is None:
# Python 3.13 was the first version to return platform.system() == "Android",
# and also the first version to define platform.android_ver().
api_level = platform.android_ver().api_level # type: ignore[attr-defined]

if abi is None:
abi = sysconfig.get_platform().split("-")[-1]
abi = _normalize_string(abi)

# 16 is the minimum API level known to have enough features to support CPython
# without major patching. Yield every API level from the maximum down to the
# minimum, inclusive.
min_api_level = 16
for ver in range(api_level, min_api_level - 1, -1):
yield f"android_{ver}_{abi}"


def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:
linux = _normalize_string(sysconfig.get_platform())
if not linux.startswith("linux_"):
Expand Down Expand Up @@ -561,6 +598,8 @@ def platform_tags() -> Iterator[str]:
return mac_platforms()
elif platform.system() == "iOS":
return ios_platforms()
elif platform.system() == "Android":
return android_platforms()
elif platform.system() == "Linux":
return _linux_platforms()
else:
Expand Down
2 changes: 1 addition & 1 deletion contrib/python/packaging/py3/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PY3_LIBRARY()

VERSION(24.2)
VERSION(25.0)

LICENSE(BSD-2-Clause AND Apache-2.0)

Expand Down
2 changes: 1 addition & 1 deletion library/cpp/tld/tlds-alpha-by-domain.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version 2025050100, Last Updated Thu May 1 07:07:02 2025 UTC
# Version 2025050301, Last Updated Sun May 4 07:07:02 2025 UTC
AAA
AARP
ABB
Expand Down
2 changes: 1 addition & 1 deletion ydb/ci/rightlib.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4c780f0058b83cbc54813f40a3e7d1816e5c04c7
74c68d5ada88cc1acc7c521cd2570838fce6607e
Loading