Skip to content

Commit 5618166

Browse files
matteiusoz123
authored andcommitted
Vendor in pip 23.2
1 parent 301d204 commit 5618166

File tree

107 files changed

+3027
-1753
lines changed

Some content is hidden

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

107 files changed

+3027
-1753
lines changed

pipenv/patched/pip/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import List, Optional
22

3-
__version__ = "23.1.2"
3+
__version__ = "23.2"
44

55

66
def main(args: Optional[List[str]] = None) -> int:

pipenv/patched/pip/__main__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import sys
3-
import warnings
43

54
# Remove '' and current working directory from the first entry
65
# of sys.path, if present to avoid using current directory
@@ -20,12 +19,6 @@
2019
sys.path.insert(0, path)
2120

2221
if __name__ == "__main__":
23-
# Work around the error reported in #9540, pending a proper fix.
24-
# Note: It is essential the warning filter is set *before* importing
25-
# pip, as the deprecation happens at import time, not runtime.
26-
warnings.filterwarnings(
27-
"ignore", category=DeprecationWarning, module=".*packaging\\.version"
28-
)
2922
import importlib.util
3023
import sys
3124
spec = importlib.util.spec_from_file_location(

pipenv/patched/pip/_internal/cache.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,17 @@ def __init__(
194194
self.origin: Optional[DirectUrl] = None
195195
origin_direct_url_path = Path(self.link.file_path).parent / ORIGIN_JSON_NAME
196196
if origin_direct_url_path.exists():
197-
self.origin = DirectUrl.from_json(origin_direct_url_path.read_text())
197+
try:
198+
self.origin = DirectUrl.from_json(
199+
origin_direct_url_path.read_text(encoding="utf-8")
200+
)
201+
except Exception as e:
202+
logger.warning(
203+
"Ignoring invalid cache entry origin file %s for %s (%s)",
204+
origin_direct_url_path,
205+
link.filename,
206+
e,
207+
)
198208

199209

200210
class WheelCache(Cache):
@@ -257,16 +267,26 @@ def get_cache_entry(
257267
@staticmethod
258268
def record_download_origin(cache_dir: str, download_info: DirectUrl) -> None:
259269
origin_path = Path(cache_dir) / ORIGIN_JSON_NAME
260-
if origin_path.is_file():
261-
origin = DirectUrl.from_json(origin_path.read_text())
262-
# TODO: use DirectUrl.equivalent when https://github.com/pypa/pip/pull/10564
263-
# is merged.
264-
if origin.url != download_info.url:
270+
if origin_path.exists():
271+
try:
272+
origin = DirectUrl.from_json(origin_path.read_text(encoding="utf-8"))
273+
except Exception as e:
265274
logger.warning(
266-
"Origin URL %s in cache entry %s does not match download URL %s. "
267-
"This is likely a pip bug or a cache corruption issue.",
268-
origin.url,
269-
cache_dir,
270-
download_info.url,
275+
"Could not read origin file %s in cache entry (%s). "
276+
"Will attempt to overwrite it.",
277+
origin_path,
278+
e,
271279
)
280+
else:
281+
# TODO: use DirectUrl.equivalent when
282+
# https://github.com/pypa/pip/pull/10564 is merged.
283+
if origin.url != download_info.url:
284+
logger.warning(
285+
"Origin URL %s in cache entry %s does not match download URL "
286+
"%s. This is likely a pip bug or a cache corruption issue. "
287+
"Will overwrite it with the new value.",
288+
origin.url,
289+
cache_dir,
290+
download_info.url,
291+
)
272292
origin_path.write_text(download_info.to_json(), encoding="utf-8")

pipenv/patched/pip/_internal/cli/base_command.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ def _main(self, args: List[str]) -> int:
131131
", ".join(sorted(always_enabled_features)),
132132
)
133133

134+
# Make sure that the --python argument isn't specified after the
135+
# subcommand. We can tell, because if --python was specified,
136+
# we should only reach this point if we're running in the created
137+
# subprocess, which has the _PIP_RUNNING_IN_SUBPROCESS environment
138+
# variable set.
139+
if options.python and "_PIP_RUNNING_IN_SUBPROCESS" not in os.environ:
140+
logger.critical(
141+
"The --python option must be placed before the pip subcommand name"
142+
)
143+
sys.exit(ERROR)
144+
134145
# TODO: Try to get these passing down from the command?
135146
# without resorting to os.environ to hold these.
136147
# This also affects isolated builds and it should.

pipenv/patched/pip/_internal/commands/check.py

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

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

2223
def run(self, options: Values, args: List[str]) -> int:
2324
package_set, parsing_probs = create_package_set_from_installed()
25+
warn_legacy_versions_and_specifiers(package_set)
2426
missing, conflicting = check_package_set(package_set)
2527

2628
for project_name in missing:

pipenv/patched/pip/_internal/commands/completion.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@
2222
complete -o default -F _pip_completion {prog}
2323
""",
2424
"zsh": """
25-
function _pip_completion {{
26-
local words cword
27-
read -Ac words
28-
read -cn cword
29-
reply=( $( COMP_WORDS="$words[*]" \\
30-
COMP_CWORD=$(( cword-1 )) \\
31-
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null ))
32-
}}
33-
compctl -K _pip_completion {prog}
25+
#compdef -P pip[0-9.]#
26+
compadd $( COMP_WORDS="$words[*]" \\
27+
COMP_CWORD=$((CURRENT-1)) \\
28+
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
3429
""",
3530
"fish": """
3631
function __fish_complete_pip

pipenv/patched/pip/_internal/commands/download.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def run(self, options: Values, args: List[str]) -> int:
137137
assert req.name is not None
138138
preparer.save_linked_requirement(req)
139139
downloaded.append(req.name)
140+
141+
preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
142+
requirement_set.warn_legacy_versions_and_specifiers()
143+
140144
if downloaded:
141145
write_output("Successfully downloaded %s", " ".join(downloaded))
142146

pipenv/patched/pip/_internal/commands/freeze.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
import sys
22
from optparse import Values
3-
from typing import List
3+
from typing import AbstractSet, List
44

55
from pipenv.patched.pip._internal.cli import cmdoptions
66
from pipenv.patched.pip._internal.cli.base_command import Command
77
from pipenv.patched.pip._internal.cli.status_codes import SUCCESS
88
from pipenv.patched.pip._internal.operations.freeze import freeze
99
from pipenv.patched.pip._internal.utils.compat import stdlib_pkgs
1010

11-
DEV_PKGS = {"pip", "setuptools", "distribute", "wheel"}
11+
12+
def _should_suppress_build_backends() -> bool:
13+
return sys.version_info < (3, 12)
14+
15+
16+
def _dev_pkgs() -> AbstractSet[str]:
17+
pkgs = {"pip"}
18+
19+
if _should_suppress_build_backends():
20+
pkgs |= {"setuptools", "distribute", "wheel"}
21+
22+
return pkgs
1223

1324

1425
class FreezeCommand(Command):
@@ -61,7 +72,7 @@ def add_options(self) -> None:
6172
action="store_true",
6273
help=(
6374
"Do not skip these packages in the output:"
64-
" {}".format(", ".join(DEV_PKGS))
75+
" {}".format(", ".join(_dev_pkgs()))
6576
),
6677
)
6778
self.cmd_opts.add_option(
@@ -77,7 +88,7 @@ def add_options(self) -> None:
7788
def run(self, options: Values, args: List[str]) -> int:
7889
skip = set(stdlib_pkgs)
7990
if not options.freeze_all:
80-
skip.update(DEV_PKGS)
91+
skip.update(_dev_pkgs())
8192

8293
if options.excludes:
8394
skip.update(options.excludes)

pipenv/patched/pip/_internal/commands/install.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ 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()
390393
would_install_items = sorted(
391394
(r.metadata["name"], r.metadata["version"])
392395
for r in requirement_set.requirements_to_install

pipenv/patched/pip/_internal/commands/list.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ def add_options(self) -> None:
103103
dest="list_format",
104104
default="columns",
105105
choices=("columns", "freeze", "json"),
106-
help="Select the output format among: columns (default), freeze, or json",
106+
help=(
107+
"Select the output format among: columns (default), freeze, or json. "
108+
"The 'freeze' format cannot be used with the --outdated option."
109+
),
107110
)
108111

109112
self.cmd_opts.add_option(
@@ -157,7 +160,7 @@ def run(self, options: Values, args: List[str]) -> int:
157160

158161
if options.outdated and options.list_format == "freeze":
159162
raise CommandError(
160-
"List format 'freeze' can not be used with the --outdated option."
163+
"List format 'freeze' cannot be used with the --outdated option."
161164
)
162165

163166
cmdoptions.check_list_path_option(options)

0 commit comments

Comments
 (0)