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

Pip 23.0.1 #5614

Merged
merged 8 commits into from
Feb 18, 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
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ gunicorn = {version = "*", markers="sys_platform == 'linux'"}
parse = "*"
importlib-metadata = {version = "*", markers="python_version < '3.8'"}
colorama= {version = "*", markers="sys_platform == 'win32'"}
invoke = "==2.0.0"
exceptiongroup = "==1.1.0"
tomli = "*"

[packages]

Expand Down
471 changes: 292 additions & 179 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions news/5614.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vendor in ``pip==23.0.1`` minor pt release. Updates ``pythonfinder==1.3.2``.
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
pip==23.0.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"
__version__ = "23.0.1"


def main(args: Optional[List[str]] = None) -> int:
Expand Down
18 changes: 9 additions & 9 deletions pipenv/patched/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@
import textwrap
from collections import OrderedDict
from types import TracebackType
from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type
from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type, Union

from pipenv.patched.pip._vendor.certifi import where
from pipenv.patched.pip._vendor.packaging.requirements import Requirement
from pipenv.patched.pip._vendor.packaging.version import Version

from pipenv.patched.pip import __file__ as pip_location
from pipenv.patched.pip._internal.cli.spinners import open_spinner
from pipenv.patched.pip._internal.locations import (
get_isolated_environment_bin_path,
get_isolated_environment_lib_paths,
get_platlib,
get_purelib,
)
from pipenv.patched.pip._internal.locations import get_platlib, get_purelib, get_scheme
from pipenv.patched.pip._internal.metadata import get_default_environment, get_environment
from pipenv.patched.pip._internal.utils.subprocess import call_subprocess
from pipenv.patched.pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
Expand All @@ -33,12 +28,17 @@
logger = logging.getLogger(__name__)


def _dedup(a: str, b: str) -> Union[Tuple[str], Tuple[str, str]]:
return (a, b) if a != b else (a,)


class _Prefix:
def __init__(self, path: str) -> None:
self.path = path
self.setup = False
self.bin_dir = get_isolated_environment_bin_path(path)
self.lib_dirs = get_isolated_environment_lib_paths(path)
scheme = get_scheme("", prefix=path)
self.bin_dir = scheme.scripts
self.lib_dirs = _dedup(scheme.purelib, scheme.platlib)


def get_runnable_pip() -> str:
Expand Down
8 changes: 8 additions & 0 deletions pipenv/patched/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ class PipOption(Option):
),
)

override_externally_managed: Callable[..., Option] = partial(
Option,
"--break-system-packages",
dest="override_externally_managed",
action="store_true",
help="Allow pip to modify an EXTERNALLY-MANAGED Python installation",
)

python: Callable[..., Option] = partial(
Option,
"--python",
Expand Down
1 change: 1 addition & 0 deletions pipenv/patched/pip/_internal/commands/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class IndexCommand(IndexGroupCommand):
Inspect information available from package indexes.
"""

ignore_require_venv = True
usage = """
%prog versions <package>
"""
Expand Down
6 changes: 5 additions & 1 deletion pipenv/patched/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def add_options(self) -> None:
self.cmd_opts.add_option(cmdoptions.use_pep517())
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
self.cmd_opts.add_option(cmdoptions.check_build_deps())
self.cmd_opts.add_option(cmdoptions.override_externally_managed())

self.cmd_opts.add_option(cmdoptions.config_settings())
self.cmd_opts.add_option(cmdoptions.install_options())
Expand Down Expand Up @@ -296,7 +297,10 @@ def run(self, options: Values, args: List[str]) -> int:
and options.target_dir is None
and options.prefix_path is None
)
if installing_into_current_environment:
if (
installing_into_current_environment
and not options.override_externally_managed
):
check_externally_managed()

upgrade_strategy = "to-satisfy-only"
Expand Down
4 changes: 3 additions & 1 deletion pipenv/patched/pip/_internal/commands/uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def add_options(self) -> None:
help="Don't ask for confirmation of uninstall deletions.",
)
self.cmd_opts.add_option(cmdoptions.root_user_action())
self.cmd_opts.add_option(cmdoptions.override_externally_managed())
self.parser.insert_option_group(0, self.cmd_opts)

def run(self, options: Values, args: List[str]) -> int:
Expand Down Expand Up @@ -93,7 +94,8 @@ def run(self, options: Values, args: List[str]) -> int:
f'"pip help {self.name}")'
)

check_externally_managed()
if not options.override_externally_managed:
check_externally_managed()

protect_pip_from_modification_on_windows(
modifying_pip="pip" in reqs_to_uninstall
Expand Down
4 changes: 3 additions & 1 deletion pipenv/patched/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,9 @@ def __init__(self, error: Optional[str]) -> None:
context=context,
note_stmt=(
"If you believe this is a mistake, please contact your "
"Python installation or OS distribution provider."
"Python installation or OS distribution provider. "
"You can override this, at the risk of breaking your Python "
"installation or OS, by passing --break-system-packages."
),
hint_stmt=Text("See PEP 668 for the detailed specification."),
)
Expand Down
68 changes: 1 addition & 67 deletions pipenv/patched/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pathlib
import sys
import sysconfig
from typing import Any, Dict, Generator, List, Optional, Tuple
from typing import Any, Dict, Generator, Optional, Tuple

from pipenv.patched.pip._internal.models.scheme import SCHEME_KEYS, Scheme
from pipenv.patched.pip._internal.utils.compat import WINDOWS
Expand All @@ -25,8 +25,6 @@
"USER_CACHE_DIR",
"get_bin_prefix",
"get_bin_user",
"get_isolated_environment_bin_path",
"get_isolated_environment_lib_paths",
"get_major_minor_version",
"get_platlib",
"get_purelib",
Expand Down Expand Up @@ -467,67 +465,3 @@ def get_platlib() -> str:
if _warn_if_mismatch(pathlib.Path(old), pathlib.Path(new), key="platlib"):
_log_context()
return old


def _deduplicated(v1: str, v2: str) -> List[str]:
"""Deduplicate values from a list."""
if v1 == v2:
return [v1]
return [v1, v2]


def _looks_like_apple_library(path: str) -> bool:
"""Apple patches sysconfig to *always* look under */Library/Python*."""
if sys.platform[:6] != "darwin":
return False
return path == f"/Library/Python/{get_major_minor_version()}/site-packages"


def get_isolated_environment_lib_paths(prefix: str) -> List[str]:
"""Return the lib locations under ``prefix``."""
new_pure, new_plat = _sysconfig.get_isolated_environment_lib_paths(prefix)
if _USE_SYSCONFIG:
return _deduplicated(new_pure, new_plat)

old_pure, old_plat = _distutils.get_isolated_environment_lib_paths(prefix)
old_lib_paths = _deduplicated(old_pure, old_plat)

# Apple's Python (shipped with Xcode and Command Line Tools) hard-code
# platlib and purelib to '/Library/Python/X.Y/site-packages'. This will
# cause serious build isolation bugs when Apple starts shipping 3.10 because
# pip will install build backends to the wrong location. This tells users
# who is at fault so Apple may notice it and fix the issue in time.
if all(_looks_like_apple_library(p) for p in old_lib_paths):
deprecated(
reason=(
"Python distributed by Apple's Command Line Tools incorrectly "
"patches sysconfig to always point to '/Library/Python'. This "
"will cause build isolation to operate incorrectly on Python "
"3.10 or later. Please help report this to Apple so they can "
"fix this. https://developer.apple.com/bug-reporting/"
),
replacement=None,
gone_in=None,
)
return old_lib_paths

warned = [
_warn_if_mismatch(
pathlib.Path(old_pure),
pathlib.Path(new_pure),
key="prefixed-purelib",
),
_warn_if_mismatch(
pathlib.Path(old_plat),
pathlib.Path(new_plat),
key="prefixed-platlib",
),
]
if any(warned):
_log_context(prefix=prefix)

return old_lib_paths


def get_isolated_environment_bin_path(prefix: str) -> str:
return _sysconfig.get_isolated_environment_paths(prefix)["scripts"]
9 changes: 1 addition & 8 deletions pipenv/patched/pip/_internal/locations/_distutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from distutils.command.install import SCHEME_KEYS
from distutils.command.install import install as distutils_install_command
from distutils.sysconfig import get_python_lib
from typing import Dict, List, Optional, Tuple, Union, cast
from typing import Dict, List, Optional, Union, cast

from pipenv.patched.pip._internal.models.scheme import Scheme
from pipenv.patched.pip._internal.utils.compat import WINDOWS
Expand Down Expand Up @@ -171,10 +171,3 @@ def get_purelib() -> str:

def get_platlib() -> str:
return get_python_lib(plat_specific=True)


def get_isolated_environment_lib_paths(prefix: str) -> Tuple[str, str]:
return (
get_python_lib(plat_specific=False, prefix=prefix),
get_python_lib(plat_specific=True, prefix=prefix),
)
12 changes: 0 additions & 12 deletions pipenv/patched/pip/_internal/locations/_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,3 @@ def get_purelib() -> str:

def get_platlib() -> str:
return sysconfig.get_paths()["platlib"]


def get_isolated_environment_paths(prefix: str) -> typing.Dict[str, str]:
variables = {"base": prefix, "platbase": prefix}
if "venv" in sysconfig.get_scheme_names():
return sysconfig.get_paths(vars=variables, scheme="venv")
return sysconfig.get_paths(vars=variables)


def get_isolated_environment_lib_paths(prefix: str) -> typing.Tuple[str, str]:
paths = get_isolated_environment_paths(prefix)
return (paths["purelib"], paths["platlib"])
7 changes: 6 additions & 1 deletion pipenv/patched/pip/_internal/models/direct_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ def __init__(
if hash is not None:
# Auto-populate the hashes key to upgrade to the new format automatically.
# We don't back-populate the legacy hash key.
hash_name, hash_value = hash.split("=", 1)
try:
hash_name, hash_value = hash.split("=", 1)
except ValueError:
raise DirectUrlValidationError(
f"invalid archive_info.hash format: {hash!r}"
)
if hashes is None:
hashes = {hash_name: hash_value}
elif hash_name not in hash:
Expand Down
19 changes: 0 additions & 19 deletions pipenv/patched/pip/_vendor/pkg_resources/LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion pipenv/vendor/pythonfinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .models import SystemPath, WindowsFinder
from .pythonfinder import Finder

__version__ = "1.3.1"
__version__ = "1.3.2"


logger = logging.getLogger(__name__)
Expand Down
11 changes: 7 additions & 4 deletions pipenv/vendor/pythonfinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from threading import Timer

import pipenv.vendor.attr as attr
from pipenv.patched.pip._vendor.packaging.version import LegacyVersion, Version
from pipenv.patched.pip._vendor.packaging.version import Version, InvalidVersion

from .compat import Path, TimeoutError, lru_cache # noqa
from .environment import MYPY_RUNNING, PYENV_ROOT, SUBPROCESS_TIMEOUT
Expand Down Expand Up @@ -130,12 +130,15 @@ def parse_python_version(version_str):
is_devrelease = True if version_dict.get("dev") else False
if patch:
patch = int(patch)
version = None # type: Optional[Union[Version, LegacyVersion]]

version = None # type: Optional[Version]

try:
version = parse_version(version_str)
except TypeError:
except (TypeError, InvalidVersion):
version = None
if isinstance(version, LegacyVersion) or version is None:

if version is None:
v_dict = version_dict.copy()
pre = ""
if v_dict.get("prerel") and v_dict.get("prerelversion"):
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plette[validation]==0.4.4
ptyprocess==0.7.0
pyparsing==3.0.9
python-dotenv==0.19.0
pythonfinder==1.3.1
pythonfinder==1.3.2
requirementslib==2.2.3
ruamel.yaml==0.17.21
shellingham==1.5.0
Expand Down
6 changes: 3 additions & 3 deletions tasks/vendoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ def rewrite_file_imports(item, vendored_libs):

for lib, to_lib in vendored_libs.items():
text = re.sub(
r"^(?m)(\s*)import %s((?:\.\S*)?\s+as)" % lib,
r"(?m)^(\s*)import %s((?:\.\S*)?\s+as)" % lib,
r"\1import %s\2" % to_lib,
text,
)
text = re.sub(r"^(?m)(\s*)from %s([\s\.]+)" % lib, r"\1from %s\2" % to_lib, text)
text = re.sub(r"(?m)^(\s*)from %s([\s\.]+)" % lib, r"\1from %s\2" % to_lib, text)
text = re.sub(
r"^(?m)(\s*)import %s(\s*[,\n#])" % lib,
r"(?m)^(\s*)import %s(\s*[,\n#])" % lib,
r"\1import %s as %s\2" % (to_lib, lib),
text,
)
Expand Down