Skip to content
Open
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
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.107.4

This release fixes `pex3 lock sync` when using requirement files as the source of requirements.

* Fix parsed requirement equality. (#3341)

## 2.107.3

This release updates vendored Pip's vendored certifi's cacert.pem to that from certifi 2026.11.20.
Expand Down
2 changes: 1 addition & 1 deletion pex/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def create_parse_error(msg):

@attr.s(frozen=True)
class _ParsedItem(object):
line = attr.ib() # type: LogicalLine
line = attr.ib(eq=False) # type: LogicalLine

def __str__(self):
# type: () -> str
Expand Down
11 changes: 6 additions & 5 deletions pex/resolve/requirement_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from pex.fetcher import URLFetcher
from pex.network_configuration import NetworkConfiguration
from pex.orderedset import OrderedSet
from pex.requirements import (
Constraint,
LocalProjectRequirement,
Expand All @@ -16,7 +17,7 @@
from pex.typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Iterable, List, Optional, Tuple
from typing import Iterable, Optional, Tuple

import attr # vendor:skip

Expand Down Expand Up @@ -49,11 +50,11 @@ class RequirementConfiguration(object):

def parse_requirements(self, network_configuration=None):
# type: (Optional[NetworkConfiguration]) -> Tuple[ParsedRequirement, ...]
parsed_requirements = list(self.requirements) # type: List[ParsedRequirement]
parsed_requirements = OrderedSet(self.requirements) # type: OrderedSet[ParsedRequirement]
if self.requirement_files:
fetcher = URLFetcher(network_configuration=network_configuration)
for requirement_file in self.requirement_files:
parsed_requirements.extend(
parsed_requirements.update(
requirement_or_constraint
for requirement_or_constraint in parse_requirement_file(
requirement_file, is_constraints=False, fetcher=fetcher
Expand All @@ -67,11 +68,11 @@ def parse_requirements(self, network_configuration=None):

def parse_constraints(self, network_configuration=None):
# type: (Optional[NetworkConfiguration]) -> Tuple[Constraint, ...]
parsed_constraints = [] # type: List[Constraint]
parsed_constraints = OrderedSet() # type: OrderedSet[Constraint]
if self.constraint_files:
fetcher = URLFetcher(network_configuration=network_configuration)
for constraint_file in self.constraint_files:
parsed_constraints.extend(
parsed_constraints.update(
requirement_or_constraint
for requirement_or_constraint in parse_requirement_file(
constraint_file, is_constraints=True, fetcher=fetcher
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.107.3"
__version__ = "2.107.4"
74 changes: 74 additions & 0 deletions tests/integration/resolve/test_issue_3333.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2026 Pex project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import absolute_import, print_function

from pex.typing import TYPE_CHECKING
from testing import PY311, ensure_python_interpreter
from testing.cli import run_pex3
from testing.pytest_utils.tmp import Tempdir

if TYPE_CHECKING:
from typing import List


ORIGINAL_REQUIREMENTS = [
'six==1.16.0; sys_platform == "linux"',
'six==1.17.0; sys_platform == "darwin"',
"psycopg-binary==3.2.4",
]
UPDATED_REQUIREMENTS = [
'six==1.16.0; sys_platform == "linux"',
'six==1.17.0; sys_platform == "darwin"',
"psycopg-binary==3.2.5",
]


def assert_sync(
tmpdir, # type: Tempdir
original_requirements_args, # type: List[str]
updated_requirements_args, # type: List[str]
):
# type: (...) -> None

py311 = ensure_python_interpreter(PY311)
lock_file = tmpdir.join("lock.json")

common_args = [
"--style",
"universal",
"--interpreter-constraint",
"==3.11.*",
"--target-system",
"linux",
"--target-system",
"mac",
"--indent",
"2",
]

create_args = ["lock", "create", "-o", lock_file] + common_args + original_requirements_args
run_pex3(*create_args, python=py311).assert_success()

sync_args = ["lock", "sync", "--lock", lock_file] + common_args + updated_requirements_args
run_pex3(*sync_args, python=py311).assert_success()


def test_sync_via_positional_requirements(tmpdir):
# type: (Tempdir) -> None

assert_sync(tmpdir, ORIGINAL_REQUIREMENTS, UPDATED_REQUIREMENTS)


def test_sync_via_requirements_files(tmpdir):
# type: (Tempdir) -> None

with open(tmpdir.join("before.txt"), "w") as before_fp:
for req in ORIGINAL_REQUIREMENTS:
print(req, file=before_fp)

with open(tmpdir.join("after.txt"), "w") as after_fp:
for req in UPDATED_REQUIREMENTS:
print(req, file=after_fp)

assert_sync(tmpdir, ["-r", before_fp.name], ["-r", after_fp.name])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B.: test_sync_via_positional_requirements passed before the fix, but test_sync_via_requirements_files failed here similar to the OP issue with:

E       AssertionError: integration test failed: return_code=1, output=, error=Encountered 1 error updating /tmp/pytest-of-jsirois/pytest-2/popen-gw0/test_sync_via_requiremen-0cdb00/lock.json:
E       1.) cp311-cp311-manylinux_2_44_x86_64: Pin(project_name=ProjectName(raw='six', validated=False, normalized='six'), version=Version(raw='1.17.0', normalized='1.17'))

29 changes: 12 additions & 17 deletions tests/integration/test_issue_1017.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
# Copyright 2021 Pex project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import os
from __future__ import absolute_import

import pytest
import os

from pex.common import temporary_dir
from testing import IS_ARM_64, PY39, ensure_python_interpreter, run_pex_command
from testing import PY310, ensure_python_interpreter, run_pex_command


@pytest.mark.skipif(
IS_ARM_64,
reason=(
"Pandas 1.0.5 requires Cython<3 to build from source, but its build_requires does not "
"constrain an upper bound and Cython 3 was released in the intervening time."
),
)
def test_resolve_python_requires_full_version():
# type: () -> None
python39 = ensure_python_interpreter(PY39)

# N.B.: Pandas 1.3.4 has `python_requires = >=3.7.1`.
python310 = ensure_python_interpreter(PY310)
with temporary_dir() as tmpdir:
constraints_file = os.path.join(tmpdir, "constraints.txt")
with open(constraints_file, "w") as fp:
# pandas 1.0.5 has an open-ended requirement on numpy, but is in practice
# incompatible with numpy>=1.24.0 because it drops np.bool support.
fp.write("numpy==1.23.5")
# pandas 1.3.4 wheels were compiled against numpy 1.x; so we need to keep that
# constraint.
fp.write("numpy<2")
result = run_pex_command(
python=python39,
python=python310,
args=[
"pandas==1.1.5",
"pandas==1.3.4",
"--constraints",
constraints_file,
"--",
Expand All @@ -38,4 +33,4 @@ def test_resolve_python_requires_full_version():
quiet=True,
)
result.assert_success()
assert "1.1.5" == result.output.strip()
assert "1.3.4" == result.output.strip()
Loading