Skip to content
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

vendor in Pip==23.1 #5655

Merged
merged 4 commits into from
Apr 17, 2023
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
1 change: 1 addition & 0 deletions news/5655.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vendor in the updates, upgrades and fixes provided by ``pip==23.1``.
2 changes: 1 addition & 1 deletion pipenv/patched/patched.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip==23.0.1
pip==23.1
safety==2.3.2
2 changes: 1 addition & 1 deletion pipenv/patched/pip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

__version__ = "23.0.1"
__version__ = "23.1"


def main(args: Optional[List[str]] = None) -> int:
Expand Down
41 changes: 10 additions & 31 deletions pipenv/patched/pip/_internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import logging
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Set
from typing import Any, Dict, List, Optional

from pipenv.patched.pip._vendor.packaging.tags import Tag, interpreter_name, interpreter_version
from pipenv.patched.pip._vendor.packaging.utils import canonicalize_name

from pipenv.patched.pip._internal.exceptions import InvalidWheelFilename
from pipenv.patched.pip._internal.models.direct_url import DirectUrl
from pipenv.patched.pip._internal.models.format_control import FormatControl
from pipenv.patched.pip._internal.models.link import Link
from pipenv.patched.pip._internal.models.wheel import Wheel
from pipenv.patched.pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
Expand All @@ -33,25 +32,13 @@ def _hash_dict(d: Dict[str, str]) -> str:
class Cache:
"""An abstract class - provides cache directories for data from links


:param cache_dir: The root of the cache.
:param format_control: An object of FormatControl class to limit
binaries being read from the cache.
:param allowed_formats: which formats of files the cache should store.
('binary' and 'source' are the only allowed values)
"""

def __init__(
self, cache_dir: str, format_control: FormatControl, allowed_formats: Set[str]
) -> None:
def __init__(self, cache_dir: str) -> None:
super().__init__()
assert not cache_dir or os.path.isabs(cache_dir)
self.cache_dir = cache_dir or None
self.format_control = format_control
self.allowed_formats = allowed_formats

_valid_formats = {"source", "binary"}
assert self.allowed_formats.union(_valid_formats) == _valid_formats

def _get_cache_path_parts(self, link: Link) -> List[str]:
"""Get parts of part that must be os.path.joined with cache_dir"""
Expand Down Expand Up @@ -91,10 +78,6 @@ def _get_candidates(self, link: Link, canonical_package_name: str) -> List[Any]:
if can_not_cache:
return []

formats = self.format_control.get_allowed_formats(canonical_package_name)
if not self.allowed_formats.intersection(formats):
return []

candidates = []
path = self.get_path_for_link(link)
if os.path.isdir(path):
Expand All @@ -121,8 +104,8 @@ def get(
class SimpleWheelCache(Cache):
"""A cache of wheels for future installs."""

def __init__(self, cache_dir: str, format_control: FormatControl) -> None:
super().__init__(cache_dir, format_control, {"binary"})
def __init__(self, cache_dir: str) -> None:
super().__init__(cache_dir)

def get_path_for_link(self, link: Link) -> str:
"""Return a directory to store cached wheels for link
Expand Down Expand Up @@ -191,13 +174,13 @@ def get(
class EphemWheelCache(SimpleWheelCache):
"""A SimpleWheelCache that creates it's own temporary cache directory"""

def __init__(self, format_control: FormatControl) -> None:
def __init__(self) -> None:
self._temp_dir = TempDirectory(
kind=tempdir_kinds.EPHEM_WHEEL_CACHE,
globally_managed=True,
)

super().__init__(self._temp_dir.path, format_control)
super().__init__(self._temp_dir.path)


class CacheEntry:
Expand All @@ -221,14 +204,10 @@ class WheelCache(Cache):
when a certain link is not found in the simple wheel cache first.
"""

def __init__(
self, cache_dir: str, format_control: Optional[FormatControl] = None
) -> None:
if format_control is None:
format_control = FormatControl()
super().__init__(cache_dir, format_control, {"binary"})
self._wheel_cache = SimpleWheelCache(cache_dir, format_control)
self._ephem_cache = EphemWheelCache(format_control)
def __init__(self, cache_dir: str) -> None:
super().__init__(cache_dir)
self._wheel_cache = SimpleWheelCache(cache_dir)
self._ephem_cache = EphemWheelCache()

def get_path_for_link(self, link: Link) -> str:
return self._wheel_cache.get_path_for_link(link)
Expand Down
9 changes: 9 additions & 0 deletions pipenv/patched/pip/_internal/cli/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ def _main(self, args: List[str]) -> int:
user_log_file=options.log,
)

always_enabled_features = set(options.features_enabled) & set(
cmdoptions.ALWAYS_ENABLED_FEATURES
)
if always_enabled_features:
logger.warning(
"The following features are always enabled: %s. ",
", ".join(sorted(always_enabled_features)),
)

# TODO: Try to get these passing down from the command?
# without resorting to os.environ to hold these.
# This also affects isolated builds and it should.
Expand Down
53 changes: 36 additions & 17 deletions pipenv/patched/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,19 @@ class PipOption(Option):
help="Disable prompting for input.",
)

keyring_provider: Callable[..., Option] = partial(
Option,
"--keyring-provider",
dest="keyring_provider",
choices=["auto", "disabled", "import", "subprocess"],
default="auto",
help=(
"Enable the credential lookup via the keyring library if user input is allowed."
" Specify which mechanism to use [disabled, import, subprocess]."
" (default: disabled)"
),
)

proxy: Callable[..., Option] = partial(
Option,
"--proxy",
Expand Down Expand Up @@ -770,10 +783,14 @@ def _handle_no_use_pep517(
"""
raise_option_error(parser, option=option, msg=msg)

# If user doesn't wish to use pep517, we check if setuptools is installed
# If user doesn't wish to use pep517, we check if setuptools and wheel are installed
# and raise error if it is not.
if not importlib.util.find_spec("setuptools"):
msg = "It is not possible to use --no-use-pep517 without setuptools installed."
packages = ("setuptools", "wheel")
if not all(importlib.util.find_spec(package) for package in packages):
msg = (
f"It is not possible to use --no-use-pep517 "
f"without {' and '.join(packages)} installed."
)
raise_option_error(parser, option=option, msg=msg)

# Otherwise, --no-use-pep517 was passed via the command-line.
Expand Down Expand Up @@ -811,11 +828,18 @@ def _handle_config_settings(
if dest is None:
dest = {}
setattr(parser.values, option.dest, dest)
dest[key] = val
if key in dest:
if isinstance(dest[key], list):
dest[key].append(val)
else:
dest[key] = [dest[key], val]
else:
dest[key] = val


config_settings: Callable[..., Option] = partial(
Option,
"-C",
"--config-settings",
dest="config_settings",
type=str,
Expand All @@ -827,17 +851,6 @@ def _handle_config_settings(
"to pass multiple keys to the backend.",
)

install_options: Callable[..., Option] = partial(
Option,
"--install-option",
dest="install_options",
action="append",
metavar="options",
help="This option is deprecated. Using this option with location-changing "
"options may cause unexpected behavior. "
"Use pip-level options like --user, --prefix, --root, and --target.",
)

build_options: Callable[..., Option] = partial(
Option,
"--build-option",
Expand Down Expand Up @@ -981,6 +994,11 @@ def check_list_path_option(options: Values) -> None:
)


# Features that are now always on. A warning is printed if they are used.
ALWAYS_ENABLED_FEATURES = [
"no-binary-enable-wheel-cache", # always on since 23.1
]

use_new_feature: Callable[..., Option] = partial(
Option,
"--use-feature",
Expand All @@ -991,8 +1009,8 @@ def check_list_path_option(options: Values) -> None:
choices=[
"fast-deps",
"truststore",
"no-binary-enable-wheel-cache",
],
]
+ ALWAYS_ENABLED_FEATURES,
help="Enable new functionality, that may be backward incompatible.",
)

Expand Down Expand Up @@ -1027,6 +1045,7 @@ def check_list_path_option(options: Values) -> None:
quiet,
log,
no_input,
keyring_provider,
proxy,
retries,
timeout,
Expand Down
7 changes: 5 additions & 2 deletions pipenv/patched/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def _build_session(

# Determine if we can prompt the user for authentication or not
session.auth.prompting = not options.no_input
session.auth.keyring_provider = options.keyring_provider

return session

Expand Down Expand Up @@ -343,7 +344,6 @@ def make_resolver(
install_req_from_req_string,
isolated=options.isolated_mode,
use_pep517=use_pep517,
config_settings=getattr(options, "config_settings", None),
)
resolver_variant = cls.determine_resolver_variant(options)
# The long import name and duplicated invocation is needed to convince
Expand Down Expand Up @@ -410,7 +410,7 @@ def get_requirements(
for req in args:
req_to_add = install_req_from_line(
req,
None,
comes_from=None,
isolated=options.isolated_mode,
use_pep517=options.use_pep517,
user_supplied=True,
Expand Down Expand Up @@ -438,6 +438,9 @@ def get_requirements(
isolated=options.isolated_mode,
use_pep517=options.use_pep517,
user_supplied=True,
config_settings=parsed_req.options.get("config_settings")
if parsed_req.options
else None,
)
requirements.append(req_to_add)

Expand Down
1 change: 0 additions & 1 deletion pipenv/patched/pip/_internal/commands/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class CacheCommand(Command):
"""

def add_options(self) -> None:

self.cmd_opts.add_option(
"--format",
action="store",
Expand Down
1 change: 0 additions & 1 deletion pipenv/patched/pip/_internal/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class CheckCommand(Command):
%prog [options]"""

def run(self, options: Values, args: List[str]) -> int:

package_set, parsing_probs = create_package_set_from_installed()
missing, conflicting = check_package_set(package_set)

Expand Down
10 changes: 2 additions & 8 deletions pipenv/patched/pip/_internal/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from pipenv.patched.pip._internal.cli.req_command import RequirementCommand, with_cleanup
from pipenv.patched.pip._internal.cli.status_codes import SUCCESS
from pipenv.patched.pip._internal.operations.build.build_tracker import get_build_tracker
from pipenv.patched.pip._internal.req.req_install import (
LegacySetupPyOptionsCheckMode,
check_legacy_setup_py_options,
)
from pipenv.patched.pip._internal.req.req_install import check_legacy_setup_py_options
from pipenv.patched.pip._internal.utils.misc import ensure_dir, normalize_path, write_output
from pipenv.patched.pip._internal.utils.temp_dir import TempDirectory

Expand Down Expand Up @@ -79,7 +76,6 @@ def add_options(self) -> None:

@with_cleanup
def run(self, options: Values, args: List[str]) -> int:

options.ignore_installed = True
# editable doesn't really make sense for `pip download`, but the bowels
# of the RequirementSet code require that property.
Expand Down Expand Up @@ -109,9 +105,7 @@ def run(self, options: Values, args: List[str]) -> int:
)

reqs = self.get_requirements(args, options, finder, session)
check_legacy_setup_py_options(
options, reqs, LegacySetupPyOptionsCheckMode.DOWNLOAD
)
check_legacy_setup_py_options(options, reqs)

preparer = self.make_requirement_preparer(
temp_build_dir=directory,
Expand Down
Loading