Skip to content

Commit 4caa6c3

Browse files
authored
Merge pull request #12300 from sbidoul/packaging-upgrade
Upgrade vendored packaging lib
2 parents d2f2da9 + 84ad55a commit 4caa6c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3091
-12220
lines changed

news/12063.removal.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Remove support for legacy versions and dependency specifiers. Packages with non
2+
standard-compliant versions or dependency specifiers are now ignored by the resolver.
3+
Already installed packages with non standard-compliant versions or dependency specifiers
4+
must be uninstalled before upgrading them.

news/packaging.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade packaging to 24.0

news/pyparsing.vendor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade pyparsing to 3.1.2
1+
Remove pyparsing

src/pip/_internal/commands/check.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from pip._internal.operations.check import (
88
check_package_set,
99
create_package_set_from_installed,
10-
warn_legacy_versions_and_specifiers,
1110
)
1211
from pip._internal.utils.misc import write_output
1312

@@ -22,7 +21,6 @@ class CheckCommand(Command):
2221

2322
def run(self, options: Values, args: List[str]) -> int:
2423
package_set, parsing_probs = create_package_set_from_installed()
25-
warn_legacy_versions_and_specifiers(package_set)
2624
missing, conflicting = check_package_set(package_set)
2725

2826
for project_name in missing:

src/pip/_internal/commands/download.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def run(self, options: Values, args: List[str]) -> int:
139139
downloaded.append(req.name)
140140

141141
preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
142-
requirement_set.warn_legacy_versions_and_specifiers()
143142

144143
if downloaded:
145144
write_output("Successfully downloaded %s", " ".join(downloaded))

src/pip/_internal/commands/index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22
from optparse import Values
3-
from typing import Any, Iterable, List, Optional, Union
3+
from typing import Any, Iterable, List, Optional
44

5-
from pip._vendor.packaging.version import LegacyVersion, Version
5+
from pip._vendor.packaging.version import Version
66

77
from pip._internal.cli import cmdoptions
88
from pip._internal.cli.req_command import IndexGroupCommand
@@ -115,7 +115,7 @@ def get_available_package_versions(self, options: Values, args: List[Any]) -> No
115115
ignore_requires_python=options.ignore_requires_python,
116116
)
117117

118-
versions: Iterable[Union[LegacyVersion, Version]] = (
118+
versions: Iterable[Version] = (
119119
candidate.version for candidate in finder.find_all_candidates(query)
120120
)
121121

src/pip/_internal/commands/install.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,6 @@ def run(self, options: Values, args: List[str]) -> int:
387387
json.dump(report.to_dict(), f, indent=2, ensure_ascii=False)
388388

389389
if options.dry_run:
390-
# In non dry-run mode, the legacy versions and specifiers check
391-
# will be done as part of conflict detection.
392-
requirement_set.warn_legacy_versions_and_specifiers()
393390
would_install_items = sorted(
394391
(r.metadata["name"], r.metadata["version"])
395392
for r in requirement_set.requirements_to_install

src/pip/_internal/commands/list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import TYPE_CHECKING, Generator, List, Optional, Sequence, Tuple, cast
55

66
from pip._vendor.packaging.utils import canonicalize_name
7+
from pip._vendor.packaging.version import Version
78

89
from pip._internal.cli import cmdoptions
910
from pip._internal.cli.req_command import IndexGroupCommand
@@ -18,7 +19,6 @@
1819
from pip._internal.utils.misc import tabulate, write_output
1920

2021
if TYPE_CHECKING:
21-
from pip._internal.metadata.base import DistributionVersion
2222

2323
class _DistWithLatestInfo(BaseDistribution):
2424
"""Give the distribution object a couple of extra fields.
@@ -27,7 +27,7 @@ class _DistWithLatestInfo(BaseDistribution):
2727
makes the rest of the code much cleaner.
2828
"""
2929

30-
latest_version: DistributionVersion
30+
latest_version: Version
3131
latest_filetype: str
3232

3333
_ProcessedDists = Sequence[_DistWithLatestInfo]
@@ -333,7 +333,7 @@ def format_for_columns(
333333
for proj in pkgs:
334334
# if we're working on the 'outdated' list, separate out the
335335
# latest_version and type
336-
row = [proj.raw_name, str(proj.version)]
336+
row = [proj.raw_name, proj.raw_version]
337337

338338
if running_outdated:
339339
row.append(str(proj.latest_version))

src/pip/_internal/commands/show.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from optparse import Values
33
from typing import Generator, Iterable, Iterator, List, NamedTuple, Optional
44

5+
from pip._vendor.packaging.requirements import InvalidRequirement
56
from pip._vendor.packaging.utils import canonicalize_name
67

78
from pip._internal.cli.base_command import Command
@@ -100,12 +101,19 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]:
100101
except KeyError:
101102
continue
102103

103-
requires = sorted(
104-
# Avoid duplicates in requirements (e.g. due to environment markers).
105-
{req.name for req in dist.iter_dependencies()},
106-
key=str.lower,
107-
)
108-
required_by = sorted(_get_requiring_packages(dist), key=str.lower)
104+
try:
105+
requires = sorted(
106+
# Avoid duplicates in requirements (e.g. due to environment markers).
107+
{req.name for req in dist.iter_dependencies()},
108+
key=str.lower,
109+
)
110+
except InvalidRequirement:
111+
requires = sorted(dist.iter_raw_dependencies(), key=str.lower)
112+
113+
try:
114+
required_by = sorted(_get_requiring_packages(dist), key=str.lower)
115+
except InvalidRequirement:
116+
required_by = ["#N/A"]
109117

110118
try:
111119
entry_points_text = dist.read_text("entry_points.txt")
@@ -139,7 +147,7 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]:
139147

140148
yield _PackageInfo(
141149
name=dist.raw_name,
142-
version=str(dist.version),
150+
version=dist.raw_version,
143151
location=dist.location or "",
144152
editable_project_location=dist.editable_project_location,
145153
requires=requires,

src/pip/_internal/commands/wheel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ def run(self, options: Values, args: List[str]) -> int:
154154
reqs_to_build.append(req)
155155

156156
preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
157-
requirement_set.warn_legacy_versions_and_specifiers()
158157

159158
# build wheels
160159
build_successes, build_failures = build(

0 commit comments

Comments
 (0)