diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index f09b08660e7..f39564897ec 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -34,3 +34,4 @@ c7ee560e00b85f7486b452c14ff49e4737996eda # Blacken tools/ 94999255d5ede440c37137d210666fdf64302e75 # Reformat the codebase, with black 585037a80a1177f1fa92e159a7079855782e543e # Cleanup implicit string concatenation 8a6f6ac19b80a6dc35900a47016c851d9fcd2ee2 # Blacken src/pip/_internal/resolution directory +acfcae8941bb12ecfc372a05c875a7b414992604 # Reformat with Black's 2025 code style diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ebbd323b389..279884b1446 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: exclude: .patch - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.10.0 + rev: 25.1.0 hooks: - id: black diff --git a/news/13156.bugfix.rst b/news/13156.bugfix.rst new file mode 100644 index 00000000000..e0553030070 --- /dev/null +++ b/news/13156.bugfix.rst @@ -0,0 +1 @@ +Show the correct path to the interpreter also when it's a symlink in a venv in the pip upgrade prompt. diff --git a/news/13186.bugfix.rst b/news/13186.bugfix.rst new file mode 100644 index 00000000000..0c60275d2b8 --- /dev/null +++ b/news/13186.bugfix.rst @@ -0,0 +1 @@ +Fix regression where truststore would never be used while installing build dependencies. diff --git a/noxfile.py b/noxfile.py index 70e24a01142..80c7358e034 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,5 +1,4 @@ -"""Automation using nox. -""" +"""Automation using nox.""" import argparse import glob diff --git a/src/pip/_internal/build_env.py b/src/pip/_internal/build_env.py index e820dc3d5fb..2612d4d14e8 100644 --- a/src/pip/_internal/build_env.py +++ b/src/pip/_internal/build_env.py @@ -1,5 +1,4 @@ -"""Build Environment used for isolation during sdist building -""" +"""Build Environment used for isolation during sdist building""" import logging import os @@ -11,7 +10,6 @@ from types import TracebackType from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type, Union -from pip._vendor.certifi import where from pip._vendor.packaging.version import Version from pip import __file__ as pip_location @@ -246,8 +244,6 @@ def _install_requirements( # target from config file or env var should be ignored "--target", "", - "--cert", - finder.custom_cert or where(), ] if logger.getEffectiveLevel() <= logging.DEBUG: args.append("-vv") @@ -276,6 +272,8 @@ def _install_requirements( args.extend(["--proxy", finder.proxy]) for host in finder.trusted_hosts: args.extend(["--trusted-host", host]) + if finder.custom_cert: + args.extend(["--cert", finder.custom_cert]) if finder.client_cert: args.extend(["--client-cert", finder.client_cert]) if finder.allow_all_prereleases: diff --git a/src/pip/_internal/cache.py b/src/pip/_internal/cache.py index 6b4512672db..97d917193d3 100644 --- a/src/pip/_internal/cache.py +++ b/src/pip/_internal/cache.py @@ -1,5 +1,4 @@ -"""Cache Management -""" +"""Cache Management""" import hashlib import json diff --git a/src/pip/_internal/cli/__init__.py b/src/pip/_internal/cli/__init__.py index e589bb917e2..5fcddf5d81e 100644 --- a/src/pip/_internal/cli/__init__.py +++ b/src/pip/_internal/cli/__init__.py @@ -1,4 +1,3 @@ -"""Subpackage containing all of pip's command line interface related code -""" +"""Subpackage containing all of pip's command line interface related code""" # This file intentionally does not import submodules diff --git a/src/pip/_internal/cli/autocompletion.py b/src/pip/_internal/cli/autocompletion.py index f3f70ac8553..4fa461293c7 100644 --- a/src/pip/_internal/cli/autocompletion.py +++ b/src/pip/_internal/cli/autocompletion.py @@ -1,5 +1,4 @@ -"""Logic that powers autocompletion installed by ``pip completion``. -""" +"""Logic that powers autocompletion installed by ``pip completion``.""" import optparse import os diff --git a/src/pip/_internal/cli/main.py b/src/pip/_internal/cli/main.py index 563ac79c984..377476c18c3 100644 --- a/src/pip/_internal/cli/main.py +++ b/src/pip/_internal/cli/main.py @@ -1,5 +1,4 @@ -"""Primary application entrypoint. -""" +"""Primary application entrypoint.""" import locale import logging diff --git a/src/pip/_internal/cli/main_parser.py b/src/pip/_internal/cli/main_parser.py index 5ade356b9c2..c52684a81fe 100644 --- a/src/pip/_internal/cli/main_parser.py +++ b/src/pip/_internal/cli/main_parser.py @@ -1,5 +1,4 @@ -"""A single place for constructing and exposing the main parser -""" +"""A single place for constructing and exposing the main parser""" import os import subprocess diff --git a/src/pip/_internal/index/__init__.py b/src/pip/_internal/index/__init__.py index 7a17b7b3b6a..197dd757de9 100644 --- a/src/pip/_internal/index/__init__.py +++ b/src/pip/_internal/index/__init__.py @@ -1,2 +1 @@ -"""Index interaction code -""" +"""Index interaction code""" diff --git a/src/pip/_internal/models/__init__.py b/src/pip/_internal/models/__init__.py index 7855226e4b5..7b1fc295032 100644 --- a/src/pip/_internal/models/__init__.py +++ b/src/pip/_internal/models/__init__.py @@ -1,2 +1 @@ -"""A package that contains models that represent entities. -""" +"""A package that contains models that represent entities.""" diff --git a/src/pip/_internal/models/direct_url.py b/src/pip/_internal/models/direct_url.py index fc5ec8d4aa9..8f990dd0ca1 100644 --- a/src/pip/_internal/models/direct_url.py +++ b/src/pip/_internal/models/direct_url.py @@ -1,4 +1,4 @@ -""" PEP 610 """ +"""PEP 610""" import json import re diff --git a/src/pip/_internal/network/__init__.py b/src/pip/_internal/network/__init__.py index b51bde91b2e..0ae1f5626bc 100644 --- a/src/pip/_internal/network/__init__.py +++ b/src/pip/_internal/network/__init__.py @@ -1,2 +1 @@ -"""Contains purely network-related utilities. -""" +"""Contains purely network-related utilities.""" diff --git a/src/pip/_internal/network/cache.py b/src/pip/_internal/network/cache.py index fca04e6945f..2fe00f40263 100644 --- a/src/pip/_internal/network/cache.py +++ b/src/pip/_internal/network/cache.py @@ -1,5 +1,4 @@ -"""HTTP cache implementation. -""" +"""HTTP cache implementation.""" import os from contextlib import contextmanager diff --git a/src/pip/_internal/network/download.py b/src/pip/_internal/network/download.py index 5c3bce3d2fd..9c6d7016579 100644 --- a/src/pip/_internal/network/download.py +++ b/src/pip/_internal/network/download.py @@ -1,5 +1,4 @@ -"""Download files with progress indicators. -""" +"""Download files with progress indicators.""" import email.message import logging diff --git a/src/pip/_internal/network/xmlrpc.py b/src/pip/_internal/network/xmlrpc.py index 22ec8d2f4a6..ba5caf337e2 100644 --- a/src/pip/_internal/network/xmlrpc.py +++ b/src/pip/_internal/network/xmlrpc.py @@ -1,5 +1,4 @@ -"""xmlrpclib.Transport implementation -""" +"""xmlrpclib.Transport implementation""" import logging import urllib.parse diff --git a/src/pip/_internal/operations/build/metadata.py b/src/pip/_internal/operations/build/metadata.py index c66ac354deb..a546809ecd5 100644 --- a/src/pip/_internal/operations/build/metadata.py +++ b/src/pip/_internal/operations/build/metadata.py @@ -1,5 +1,4 @@ -"""Metadata generation logic for source distributions. -""" +"""Metadata generation logic for source distributions.""" import os diff --git a/src/pip/_internal/operations/build/metadata_editable.py b/src/pip/_internal/operations/build/metadata_editable.py index 3397ccf0f92..27ecd7d3d80 100644 --- a/src/pip/_internal/operations/build/metadata_editable.py +++ b/src/pip/_internal/operations/build/metadata_editable.py @@ -1,5 +1,4 @@ -"""Metadata generation logic for source distributions. -""" +"""Metadata generation logic for source distributions.""" import os diff --git a/src/pip/_internal/operations/build/metadata_legacy.py b/src/pip/_internal/operations/build/metadata_legacy.py index c01dd1c678a..e385b5ddf76 100644 --- a/src/pip/_internal/operations/build/metadata_legacy.py +++ b/src/pip/_internal/operations/build/metadata_legacy.py @@ -1,5 +1,4 @@ -"""Metadata generation logic for legacy source distributions. -""" +"""Metadata generation logic for legacy source distributions.""" import logging import os diff --git a/src/pip/_internal/operations/check.py b/src/pip/_internal/operations/check.py index 4b6fbc4c375..c6d676d6e61 100644 --- a/src/pip/_internal/operations/check.py +++ b/src/pip/_internal/operations/check.py @@ -1,5 +1,4 @@ -"""Validation of dependencies of packages -""" +"""Validation of dependencies of packages""" import logging from contextlib import suppress diff --git a/src/pip/_internal/operations/install/__init__.py b/src/pip/_internal/operations/install/__init__.py index 24d6a5dd31f..2645a4acad0 100644 --- a/src/pip/_internal/operations/install/__init__.py +++ b/src/pip/_internal/operations/install/__init__.py @@ -1,2 +1 @@ -"""For modules related to installing packages. -""" +"""For modules related to installing packages.""" diff --git a/src/pip/_internal/operations/install/editable_legacy.py b/src/pip/_internal/operations/install/editable_legacy.py index 9aaa699a645..644bcec111f 100644 --- a/src/pip/_internal/operations/install/editable_legacy.py +++ b/src/pip/_internal/operations/install/editable_legacy.py @@ -1,5 +1,4 @@ -"""Legacy editable installation process, i.e. `setup.py develop`. -""" +"""Legacy editable installation process, i.e. `setup.py develop`.""" import logging from typing import Optional, Sequence diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py index aef42aa9eef..769c433d043 100644 --- a/src/pip/_internal/operations/install/wheel.py +++ b/src/pip/_internal/operations/install/wheel.py @@ -1,5 +1,4 @@ -"""Support for installing and building the "wheel" binary package format. -""" +"""Support for installing and building the "wheel" binary package format.""" import collections import compileall diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index e6aa3447200..a1c02d7dba9 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -1,5 +1,4 @@ -"""Prepares a distribution for installation -""" +"""Prepares a distribution for installation""" # The following comment should be removed at some point in the future. # mypy: strict-optional=False diff --git a/src/pip/_internal/req/req_uninstall.py b/src/pip/_internal/req/req_uninstall.py index 26df20844b3..e48c53eb1e4 100644 --- a/src/pip/_internal/req/req_uninstall.py +++ b/src/pip/_internal/req/req_uninstall.py @@ -38,7 +38,7 @@ def _script_names( def _unique( - fn: Callable[..., Generator[Any, None, None]] + fn: Callable[..., Generator[Any, None, None]], ) -> Callable[..., Generator[Any, None, None]]: @functools.wraps(fn) def unique(*args: Any, **kw: Any) -> Generator[Any, None, None]: diff --git a/src/pip/_internal/utils/compatibility_tags.py b/src/pip/_internal/utils/compatibility_tags.py index 2e7b7450dce..43d6a4aa4bd 100644 --- a/src/pip/_internal/utils/compatibility_tags.py +++ b/src/pip/_internal/utils/compatibility_tags.py @@ -1,5 +1,4 @@ -"""Generate and work with PEP 425 Compatibility Tags. -""" +"""Generate and work with PEP 425 Compatibility Tags.""" import re from typing import List, Optional, Tuple diff --git a/src/pip/_internal/utils/datetime.py b/src/pip/_internal/utils/datetime.py index 8668b3b0ec1..776e49898f7 100644 --- a/src/pip/_internal/utils/datetime.py +++ b/src/pip/_internal/utils/datetime.py @@ -1,5 +1,4 @@ -"""For when pip wants to check the date or time. -""" +"""For when pip wants to check the date or time.""" import datetime diff --git a/src/pip/_internal/utils/entrypoints.py b/src/pip/_internal/utils/entrypoints.py index 15013693854..696148c5097 100644 --- a/src/pip/_internal/utils/entrypoints.py +++ b/src/pip/_internal/utils/entrypoints.py @@ -77,7 +77,10 @@ def get_best_invocation_for_this_python() -> str: # Try to use the basename, if it's the first executable. found_executable = shutil.which(exe_name) - if found_executable and os.path.samefile(found_executable, exe): + # Virtual environments often symlink to their parent Python binaries, but we don't + # want to treat the Python binaries as equivalent when the environment's Python is + # not on PATH (not activated). Thus, we don't follow symlinks. + if found_executable and os.path.samestat(os.lstat(found_executable), os.lstat(exe)): return exe_name # Use the full executable name, because we couldn't find something simpler. diff --git a/src/pip/_internal/utils/filetypes.py b/src/pip/_internal/utils/filetypes.py index 5948570178f..5644638222c 100644 --- a/src/pip/_internal/utils/filetypes.py +++ b/src/pip/_internal/utils/filetypes.py @@ -1,5 +1,4 @@ -"""Filetype information. -""" +"""Filetype information.""" from typing import Tuple diff --git a/src/pip/_internal/utils/unpacking.py b/src/pip/_internal/utils/unpacking.py index 87a6d19ab5a..9a4ad8a334f 100644 --- a/src/pip/_internal/utils/unpacking.py +++ b/src/pip/_internal/utils/unpacking.py @@ -1,5 +1,4 @@ -"""Utilities related archives. -""" +"""Utilities related archives.""" import logging import os diff --git a/src/pip/_internal/utils/wheel.py b/src/pip/_internal/utils/wheel.py index f85aee8a3f9..70e186cdfd1 100644 --- a/src/pip/_internal/utils/wheel.py +++ b/src/pip/_internal/utils/wheel.py @@ -1,5 +1,4 @@ -"""Support functions for working with wheel files. -""" +"""Support functions for working with wheel files.""" import logging from email.message import Message diff --git a/src/pip/_internal/wheel_builder.py b/src/pip/_internal/wheel_builder.py index 93f8e1f5b2f..00319cb5673 100644 --- a/src/pip/_internal/wheel_builder.py +++ b/src/pip/_internal/wheel_builder.py @@ -1,5 +1,4 @@ -"""Orchestrator for building wheels from InstallRequirements. -""" +"""Orchestrator for building wheels from InstallRequirements.""" import logging import os.path diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py index 5be66d88eac..65946a1f46a 100644 --- a/tests/functional/test_cli.py +++ b/tests/functional/test_cli.py @@ -1,5 +1,4 @@ -"""Basic CLI functionality checks. -""" +"""Basic CLI functionality checks.""" import subprocess import sys diff --git a/tests/functional/test_configuration.py b/tests/functional/test_configuration.py index 56cac572c4f..f049adf6b21 100644 --- a/tests/functional/test_configuration.py +++ b/tests/functional/test_configuration.py @@ -1,5 +1,4 @@ -"""Tests for the config command -""" +"""Tests for the config command""" import re import textwrap diff --git a/tests/lib/configuration_helpers.py b/tests/lib/configuration_helpers.py index b6e398c5bf1..a802c569878 100644 --- a/tests/lib/configuration_helpers.py +++ b/tests/lib/configuration_helpers.py @@ -1,5 +1,4 @@ -"""Helpers for tests that check configuration -""" +"""Helpers for tests that check configuration""" import contextlib import functools diff --git a/tests/lib/filesystem.py b/tests/lib/filesystem.py index e05e2703e9c..363220e1129 100644 --- a/tests/lib/filesystem.py +++ b/tests/lib/filesystem.py @@ -1,5 +1,4 @@ -"""Helpers for filesystem-dependent tests. -""" +"""Helpers for filesystem-dependent tests.""" import os from contextlib import contextmanager diff --git a/tests/lib/options_helpers.py b/tests/lib/options_helpers.py index 4444fa3e97b..92325dddbd1 100644 --- a/tests/lib/options_helpers.py +++ b/tests/lib/options_helpers.py @@ -1,5 +1,4 @@ -"""Provides helper classes for testing option handling in pip -""" +"""Provides helper classes for testing option handling in pip""" from optparse import Values from typing import List, Tuple diff --git a/tests/lib/requests_mocks.py b/tests/lib/requests_mocks.py index a70a9b2b048..971afaed027 100644 --- a/tests/lib/requests_mocks.py +++ b/tests/lib/requests_mocks.py @@ -1,5 +1,4 @@ -"""Helper classes as mocks for requests objects. -""" +"""Helper classes as mocks for requests objects.""" from io import BytesIO from typing import Any, Callable, Dict, Iterator, List, Optional diff --git a/tests/lib/server.py b/tests/lib/server.py index 96ac5930dc9..faeaa66eb1d 100644 --- a/tests/lib/server.py +++ b/tests/lib/server.py @@ -48,7 +48,7 @@ def make_environ(self) -> Dict[str, Any]: def _mock_wsgi_adapter( - mock: Callable[["WSGIEnvironment", "StartResponse"], "WSGIApplication"] + mock: Callable[["WSGIEnvironment", "StartResponse"], "WSGIApplication"], ) -> "WSGIApplication": """Uses a mock to record function arguments and provide the actual function that should respond. diff --git a/tests/lib/test_wheel.py b/tests/lib/test_wheel.py index abbfaf77ef5..ebf448ff503 100644 --- a/tests/lib/test_wheel.py +++ b/tests/lib/test_wheel.py @@ -1,5 +1,4 @@ -"""Tests for wheel helper. -""" +"""Tests for wheel helper.""" import csv from email import message_from_string diff --git a/tests/lib/wheel.py b/tests/lib/wheel.py index e2634e72c86..43b382919f6 100644 --- a/tests/lib/wheel.py +++ b/tests/lib/wheel.py @@ -1,5 +1,4 @@ -"""Helper for building wheels as would be in test cases. -""" +"""Helper for building wheels as would be in test cases.""" import csv import itertools diff --git a/tests/unit/resolution_resolvelib/test_resolver.py b/tests/unit/resolution_resolvelib/test_resolver.py index 18238eef134..9a0e4c90825 100644 --- a/tests/unit/resolution_resolvelib/test_resolver.py +++ b/tests/unit/resolution_resolvelib/test_resolver.py @@ -35,7 +35,7 @@ def resolver(preparer: RequirementPreparer, finder: PackageFinder) -> Resolver: def _make_graph( - edges: List[Tuple[Optional[str], Optional[str]]] + edges: List[Tuple[Optional[str], Optional[str]]], ) -> "DirectedGraph[Optional[str]]": """Build graph from edge declarations.""" diff --git a/tests/unit/test_appdirs.py b/tests/unit/test_appdirs.py index 6e6521dd5c0..51bd6828e2a 100644 --- a/tests/unit/test_appdirs.py +++ b/tests/unit/test_appdirs.py @@ -66,7 +66,7 @@ def test_user_cache_dir_unicode(self, monkeypatch: pytest.MonkeyPatch) -> None: return def my_get_win_folder(csidl_name: str) -> str: - return "\u00DF\u00E4\u03B1\u20AC" + return "\u00df\u00e4\u03b1\u20ac" monkeypatch.setattr( platformdirs.windows, # type: ignore diff --git a/tests/unit/test_base_command.py b/tests/unit/test_base_command.py index f9fae651422..87665fbde43 100644 --- a/tests/unit/test_base_command.py +++ b/tests/unit/test_base_command.py @@ -56,8 +56,8 @@ class FakeCommandWithUnicode(FakeCommand): _name = "fake_unicode" def run(self, options: Values, args: List[str]) -> int: - logging.getLogger("pip.tests").info(b"bytes here \xE9") - logging.getLogger("pip.tests").info(b"unicode here \xC3\xA9".decode("utf-8")) + logging.getLogger("pip.tests").info(b"bytes here \xe9") + logging.getLogger("pip.tests").info(b"unicode here \xc3\xa9".decode("utf-8")) return SUCCESS diff --git a/tests/unit/test_configuration.py b/tests/unit/test_configuration.py index 29a268c7875..73b7d68c399 100644 --- a/tests/unit/test_configuration.py +++ b/tests/unit/test_configuration.py @@ -1,5 +1,4 @@ -"""Tests for all things related to the configuration -""" +"""Tests for all things related to the configuration""" import re from unittest.mock import MagicMock diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py index 2550cae412d..c09314e50cf 100644 --- a/tests/unit/test_models.py +++ b/tests/unit/test_models.py @@ -1,5 +1,4 @@ -"""Tests for various classes in pip._internal.models -""" +"""Tests for various classes in pip._internal.models""" from pip._vendor.packaging.version import parse as parse_version diff --git a/tools/release/check_version.py b/tools/release/check_version.py index de3658faacd..f5c880533e7 100644 --- a/tools/release/check_version.py +++ b/tools/release/check_version.py @@ -1,5 +1,4 @@ -"""Checks if the version is acceptable, as per this project's release process. -""" +"""Checks if the version is acceptable, as per this project's release process.""" import sys from datetime import datetime