Skip to content

Commit

Permalink
Merge branch 'main' into release/24.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Jul 7, 2024
2 parents 412211e + af00870 commit a5b2e5c
Show file tree
Hide file tree
Showing 19 changed files with 450 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
rev: v0.5.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 2 additions & 0 deletions news/12683.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Disable pip's self version check when invoking a pip subprocess to install
PEP 517 build requirements.
2 changes: 2 additions & 0 deletions news/12712.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improve dependency resolution performance by caching platform compatibility
tags during wheel cache lookup.
1 change: 1 addition & 0 deletions news/12781.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix finding hardlink targets in tar files with an ignored top-level directory.
2 changes: 2 additions & 0 deletions news/12791.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improve pip install performance. The installed packages printout is
now calculated in linear time instead of quadratic time.
1 change: 1 addition & 0 deletions news/12796.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the preload list for the ``DEBUNDLED`` case, to replace ``pep517`` that has been renamed to ``pyproject_hooks``.
1 change: 1 addition & 0 deletions news/12797.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use tomllib from the stdlib if available, rather than tomli
1 change: 1 addition & 0 deletions news/12805.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update ruff to 0.5.0
1 change: 1 addition & 0 deletions news/typing_extensions.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade typing_extensions to 4.12.2
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ distlib = "https://bitbucket.org/pypa/distlib/raw/master/LICENSE.txt"

[tool.ruff]
src = ["src"]
target-version = "py38"
line-length = 88
extend-exclude = [
"_vendor",
Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def _install_requirements(
"--prefix",
prefix.path,
"--no-warn-script-location",
"--disable-pip-version-check",
]
if logger.getEffectiveLevel() <= logging.DEBUG:
args.append("-vv")
Expand Down
27 changes: 16 additions & 11 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from optparse import SUPPRESS_HELP, Values
from typing import List, Optional

from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.rich import print_json

from pip._internal.cache import WheelCache
Expand Down Expand Up @@ -472,25 +473,29 @@ def run(self, options: Values, args: List[str]) -> int:
)
env = get_environment(lib_locations)

# Display a summary of installed packages, with extra care to
# display a package name as it was requested by the user.
installed.sort(key=operator.attrgetter("name"))
items = []
for result in installed:
item = result.name
try:
installed_dist = env.get_distribution(item)
if installed_dist is not None:
item = f"{item}-{installed_dist.version}"
except Exception:
pass
items.append(item)
summary = []
installed_versions = {}
for distribution in env.iter_all_distributions():
installed_versions[distribution.canonical_name] = distribution.version
for package in installed:
display_name = package.name
version = installed_versions.get(canonicalize_name(display_name), None)
if version:
text = f"{display_name}-{version}"
else:
text = display_name
summary.append(text)

if conflicts is not None:
self._warn_about_conflicts(
conflicts,
resolver_variant=self.determine_resolver_variant(options),
)

installed_desc = " ".join(items)
installed_desc = " ".join(summary)
if installed_desc:
write_output(
"Successfully installed %s",
Expand Down
3 changes: 2 additions & 1 deletion src/pip/_internal/metadata/importlib/_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ def _iter_distributions(self) -> Iterator[BaseDistribution]:
yield from finder.find_linked(location)

def get_distribution(self, name: str) -> Optional[BaseDistribution]:
canonical_name = canonicalize_name(name)
matches = (
distribution
for distribution in self.iter_all_distributions()
if distribution.canonical_name == canonicalize_name(name)
if distribution.canonical_name == canonical_name
)
return next(matches, None)
9 changes: 7 additions & 2 deletions src/pip/_internal/pyproject.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import importlib.util
import os
import sys
from collections import namedtuple
from typing import Any, List, Optional

from pip._vendor import tomli
if sys.version_info >= (3, 11):
import tomllib
else:
from pip._vendor import tomli as tomllib

from pip._vendor.packaging.requirements import InvalidRequirement, Requirement

from pip._internal.exceptions import (
Expand Down Expand Up @@ -61,7 +66,7 @@ def load_pyproject_toml(

if has_pyproject:
with open(pyproject_toml, encoding="utf-8") as f:
pp_toml = tomli.loads(f.read())
pp_toml = tomllib.loads(f.read())
build_system = pp_toml.get("build-system")
else:
build_system = None
Expand Down
3 changes: 2 additions & 1 deletion src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(
self._extras_candidate_cache: Dict[
Tuple[int, FrozenSet[NormalizedName]], ExtrasCandidate
] = {}
self._supported_tags_cache = get_supported()

if not ignore_installed:
env = get_default_environment()
Expand Down Expand Up @@ -608,7 +609,7 @@ def get_wheel_cache_entry(
return self._wheel_cache.get_cache_entry(
link=link,
package_name=name,
supported_tags=get_supported(),
supported_tags=self._supported_tags_cache,
)

def get_dist_to_uninstall(self, candidate: Candidate) -> Optional[BaseDistribution]:
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _onerror_ignore(*_args: Any) -> None:


def _onerror_reraise(*_args: Any) -> None:
raise
raise # noqa: PLE0704 - Bare exception used to reraise existing exception


def rmtree_errorhandler(
Expand Down
5 changes: 3 additions & 2 deletions src/pip/_vendor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def vendored(modulename):
vendored("packaging")
vendored("packaging.version")
vendored("packaging.specifiers")
vendored("pep517")
vendored("pkg_resources")
vendored("platformdirs")
vendored("progress")
vendored("pyproject_hooks")
vendored("requests")
vendored("requests.exceptions")
vendored("requests.packages")
Expand Down Expand Up @@ -111,6 +111,7 @@ def vendored(modulename):
vendored("rich.text")
vendored("rich.traceback")
vendored("tenacity")
vendored("tomli")
if sys.version_info < (3, 11):
vendored("tomli")
vendored("truststore")
vendored("urllib3")
Loading

0 comments on commit a5b2e5c

Please sign in to comment.