Skip to content

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

docs/notes/2.31.x.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ used by Pants itself works.
4949

5050
Added the `[python].default_to_resolve_interpreter_constraints` option which when set the true, allows Python targets with both `interpreter_constraints` and `resolve` fields to fallback on their resolve's interpreter constraints before the global constraints if no interpreter constraints are set on the actual target.
5151

52-
The version of [Pex](https://github.com/pex-tool/pex) used by the Python backend has been upgraded to [`v2.73.1`](https://github.com/pex-tool/pex/releases/tag/v2.73.1). This fixes two issues:
52+
The version of [Pex](https://github.com/pex-tool/pex) used by the Python backend has been upgraded to [`v2.77.0`](https://github.com/pex-tool/pex/releases/tag/v2.77.0). This fixes two issues of particular note for Pants users:
5353
- A [bug](https://github.com/pantsbuild/pants/issues/22886) that hindered the use of multiple custom package indexes
5454
- A [bug](https://github.com/pex-tool/pex/issues/3032) that prevented invalidation of a lockfile when the URL of a URL-based requirement changed.
5555

src/python/pants/backend/python/util_rules/pex_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
logger = logging.getLogger(__name__)
3838

3939

40-
_PEX_VERSION = "v2.73.1"
41-
_PEX_BINARY_HASH = "e6907e079a3f7c917dc88b41d892f732d4b8dbe388abfefc064d19c4a9f3c7e8"
42-
_PEX_BINARY_SIZE = 4939987
40+
_PEX_VERSION = "v2.77.0"
41+
_PEX_BINARY_HASH = "08f3dfcc9f07be2f789d1abb2248fa38e595c2d48093e1d1b29277ae67c1e7a6"
42+
_PEX_BINARY_SIZE = 4944069
4343

4444

4545
class PexCli(TemplatedExternalTool):

src/python/pants/backend/python/util_rules/pex_from_targets_test.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import importlib.resources
77
import os
8+
import re
89
import subprocess
910
from collections.abc import Iterable
1011
from dataclasses import dataclass
@@ -537,6 +538,15 @@ def requirements(rule_runner: PythonRuleRunner, pex: Pex) -> list[str]:
537538
return cast(list[str], get_all_data(rule_runner, pex).info["requirements"])
538539

539540

541+
def _normalize_url_req(s: str) -> str:
542+
"""See https://github.com/pypa/packaging/issues/935.
543+
544+
Several tests here are brittle and rely on Pex/Pants being on the same packaging version. These
545+
are pretty low value. Back this out after upgrading packaging.
546+
"""
547+
return re.sub(r"\s*@\s*", "@ ", s)
548+
549+
540550
def test_constraints_validation(tmp_path: Path, rule_runner: PythonRuleRunner) -> None:
541551
sdists = tmp_path / "sdists"
542552
sdists.mkdir()
@@ -563,7 +573,7 @@ def test_constraints_validation(tmp_path: Path, rule_runner: PythonRuleRunner) -
563573

564574
# This string won't parse as a Requirement if it doesn't contain a netloc,
565575
# so we explicitly mention localhost.
566-
url_req = f"foorl@ git+file://localhost{foorl_dir.as_posix()}@9.8.7"
576+
url_req = f"foorl @ git+file://localhost{foorl_dir.as_posix()}@9.8.7"
567577

568578
rule_runner.write_files(
569579
{
@@ -634,7 +644,12 @@ def get_pex_request(
634644
assert isinstance(pex_req1.requirements, PexRequirements)
635645
assert pex_req1.requirements.constraints_strings == FrozenOrderedSet(constraints1_strings)
636646
req_strings_obj1 = rule_runner.request(PexRequirementsInfo, (pex_req1.requirements,))
637-
assert req_strings_obj1.req_strings == ("bar==5.5.5", "baz", "foo-bar>=0.1.2", url_req)
647+
assert tuple(_normalize_url_req(s) for s in req_strings_obj1.req_strings) == (
648+
"bar==5.5.5",
649+
"baz",
650+
"foo-bar>=0.1.2",
651+
_normalize_url_req(url_req),
652+
)
638653

639654
pex_req2 = get_pex_request(
640655
constraints1_filename,
@@ -645,13 +660,22 @@ def get_pex_request(
645660
pex_req2_reqs = pex_req2.requirements
646661
assert isinstance(pex_req2_reqs, PexRequirements)
647662
req_strings_obj2 = rule_runner.request(PexRequirementsInfo, (pex_req2_reqs,))
648-
assert req_strings_obj2.req_strings == ("bar==5.5.5", "baz", "foo-bar>=0.1.2", url_req)
663+
assert tuple(_normalize_url_req(s) for s in req_strings_obj2.req_strings) == (
664+
"bar==5.5.5",
665+
"baz",
666+
"foo-bar>=0.1.2",
667+
_normalize_url_req(url_req),
668+
)
649669
assert isinstance(pex_req2_reqs.from_superset, Pex)
650670
repository_pex = pex_req2_reqs.from_superset
651671
assert not get_all_data(rule_runner, repository_pex).info["strip_pex_env"]
652-
assert ["Foo._-BAR==1.0.0", "bar==5.5.5", "baz==2.2.2", url_req, "qux==3.4.5"] == requirements(
653-
rule_runner, repository_pex
654-
)
672+
assert [
673+
"Foo._-BAR==1.0.0",
674+
"bar==5.5.5",
675+
"baz==2.2.2",
676+
_normalize_url_req(url_req),
677+
"qux==3.4.5",
678+
] == [_normalize_url_req(r) for r in requirements(rule_runner, repository_pex)]
655679

656680
with engine_error(
657681
ValueError,

0 commit comments

Comments
 (0)