Skip to content

Commit

Permalink
Add support for --pip-version 25.0. (#2652)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois authored Jan 26, 2025
1 parent d365641 commit 157eada
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 21 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ jobs:
- tox-env: py27-pip20
- tox-env: py38-pip22_3_1
- tox-env: py311-pip23_3_2
- tox-env: py313-pip24_3_1
- tox-env: py314-pip24_3_1
- tox-env: py313-pip25_0
- tox-env: py314-pip25_0
- tox-env: pypy310-pip24_3_1

# Integration tests, split most into two shards:
Expand All @@ -94,14 +94,14 @@ jobs:
- tox-env: py311-pip23_3_2-integration
pex-test-pos-args: --shard 2/2

- tox-env: py313-pip24_3_1-integration
- tox-env: py313-pip25_0-integration
pex-test-pos-args: --shard 1/2
- tox-env: py313-pip24_3_1-integration
- tox-env: py313-pip25_0-integration
pex-test-pos-args: --shard 2/2

- tox-env: py314-pip24_3_1-integration
- tox-env: py314-pip25_0-integration
pex-test-pos-args: --shard 1/2
- tox-env: py314-pip24_3_1-integration
- tox-env: py314-pip25_0-integration
pex-test-pos-args: --shard 2/2

- tox-env: pypy310-pip24_3_1-integration
Expand Down Expand Up @@ -149,14 +149,14 @@ jobs:
matrix:
include:
- python-version: [ 3, 13 ]
tox-env: py313-pip24_3_1
tox-env: py313-pip25_0
tox-env-python: python3.11
- python-version: [ 3, 13 ]
tox-env: py313-pip24_3_1-integration
tox-env: py313-pip25_0-integration
tox-env-python: python3.11
pex-test-pos-args: --shard 1/2
- python-version: [ 3, 13 ]
tox-env: py313-pip24_3_1-integration
tox-env: py313-pip25_0-integration
tox-env-python: python3.11
pex-test-pos-args: --shard 2/2
steps:
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## 2.32.0

This release adds support for Pip 25.0.

* Add support for `--pip-version 25.0`. (#2652)

## 2.31.0

This release adds `pex3 lock subset <reqs...> --lock existing.lock` for
Expand Down
17 changes: 11 additions & 6 deletions pex/pip/dependencies/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import absolute_import, print_function

import logging
import sys

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -78,10 +79,14 @@ def patch_requires_dists(dist_type, requires_dists_function_name):
# `pkg_resources.Distribution` objects to a `pip._internal.metadata` interface. The
# `pip._internal.metadata.pkg_resources.Distribution` type delegates to
# `pip._vendor.pkg_resources.Distribution`, which we've patched above, but the
# `pip._internal.metadata.importlib.Distribution` type needs its own patching.
try:
from pip._internal.metadata.importlib import Distribution # type: ignore[import]
# `pip._internal.metadata.importlib.Distribution` type needs its own patching. N.B.: Pip only
# uses the pip._internal.metadata.importlib package for Python >=3.11 and code in that package
# relies on that fact, using some syntax not supported in earlier Python versions; so we guard
# this patch. See discussion here: https://github.com/pypa/pip/pull/11685/files#r1929802395
if sys.version_info[:2] >= (3, 11):
try:
from pip._internal.metadata.importlib import Distribution # type: ignore[import]

patch_requires_dists(Distribution, "iter_dependencies")
except ImportError:
pass
patch_requires_dists(Distribution, "iter_dependencies")
except ImportError:
pass
4 changes: 2 additions & 2 deletions pex/pip/foreign_platform/requires_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# N.B.: The following environment variable is used by the Pex runtime to control Pip and must be
# kept in-sync with `__init__.py`.
with open(os.environ.pop("_PEX_PYTHON_VERSIONS_FILE")) as fp:
PYTHON_FULL_VERSIONS = json.load(fp)
PYTHON_VERSIONS = sorted(set((version[0], version[1]) for version in PYTHON_FULL_VERSIONS))
PYTHON_FULL_VERSIONS = sorted(tuple(version) for version in json.load(fp))
PYTHON_VERSIONS = sorted(set(version[:2] for version in PYTHON_FULL_VERSIONS))


def patch():
Expand Down
8 changes: 6 additions & 2 deletions pex/pip/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@ def _spawn_pip_isolated(
pip_args = [
# We vendor the version of pip we want so pip should never check for updates.
"--disable-pip-version-check",
# If we want to warn about a version of python we support, we should do it, not pip.
"--no-python-version-warning",
# If pip encounters a duplicate file path during its operations we don't want it to
# prompt and we'd also like to know about this since it should never occur. We leverage
# the pip global option:
Expand All @@ -387,6 +385,12 @@ def _spawn_pip_isolated(
# We are not interactive.
"--no-input",
]
if self.version < PipVersion.v25_0:
# If we want to warn about a version of python we support, we should do it, not pip.
# That said, the option does nothing in Pip 25.0 and is deprecated and slated for
# removal.
pip_args.append("--no-python-version-warning")

python_interpreter = interpreter or PythonInterpreter.get()
pip_args.extend(
self._calculate_resolver_version_args(
Expand Down
9 changes: 9 additions & 0 deletions pex/pip/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ def values(cls):
requires_python=">=3.8,<3.15",
)

v25_0 = PipVersionValue(
version="25.0",
# N.B.: The setuptools 75.8.0 release was available on 1/026/2025 (the Pip 25.0 release
# date) but 75.3.0 is the last setuptools version to support 3.8.
setuptools_version="75.3.0",
wheel_version="0.45.1",
requires_python=">=3.8,<3.15",
)

VENDORED = v20_3_4_patched
LATEST = LatestPipVersion()
DEFAULT = DefaultPipVersion(preferred=(VENDORED, v23_2, v24_1))
Expand Down
2 changes: 1 addition & 1 deletion pex/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2015 Pex project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

__version__ = "2.31.0"
__version__ = "2.32.0"
6 changes: 5 additions & 1 deletion tests/integration/test_issue_1560.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ def test_build_isolation(
touch(os.path.join(project_dir, "foo.py"))

python, pip = venv_factory.create_venv()
# N.B.: Pip 25.0 introduces a new message to check for here.
run_pex_command(args=[project_dir, "--no-build-isolation"], python=python).assert_failure(
expected_error_re=r".*ModuleNotFoundError: No module named 'flit_core'.*",
expected_error_re=r".*(?:{old_message}|{new_message}).*".format(
old_message=re.escape("ModuleNotFoundError: No module named 'flit_core'"),
new_message=re.escape("BackendUnavailable: Cannot import 'flit_core.buildapi'"),
),
re_flags=re.DOTALL,
)

Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ setenv =
pip24_2: _PEX_PIP_VERSION=24.2
pip24_3: _PEX_PIP_VERSION=24.3
pip24_3_1: _PEX_PIP_VERSION=24.3.1
pip25_0: _PEX_PIP_VERSION=25.0
py314: _PEX_REQUIRES_PYTHON=>=2.7,<3.15,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*

# Python 3 (until a fix here in 3.9: https://bugs.python.org/issue13601) switched from stderr
Expand Down

0 comments on commit 157eada

Please sign in to comment.