From 0d6d45f814a4ad5ac065c5aa786c903764873dc4 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Wed, 15 Jul 2026 16:45:53 -0700 Subject: [PATCH 1/2] Fix `pexrc inject` target platform detection. Previously compressed tag sets were not handled correctly leading to spurious errors auto-detecting the correct target. Fixes #135 --- CHANGES.md | 5 +++++ Cargo.lock | 2 +- Cargo.toml | 2 +- python/tests/test_issue_135.py | 32 ++++++++++++++++++++++++++++++++ src/commands/inject.rs | 18 +++++++++++++----- 5 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 python/tests/test_issue_135.py diff --git a/CHANGES.md b/CHANGES.md index 045b3ab..fde3027 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Release Notes +## 0.16.2 + +This release fixes `pexrc inject` target platform detection to handle wheels with compressed tag +sets. + ## 0.16.1 This release fixes interpreter detection for `pyenv` shims on unix. Previously the cache of diff --git a/Cargo.lock b/Cargo.lock index a42f6e4..f7d3575 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "pexrc" -version = "0.16.1" +version = "0.16.2" dependencies = [ "anstream", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 46c4439..f8f1144 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ cargo-features = ["profile-rustflags"] [package] name = "pexrc" -version = "0.16.1" +version = "0.16.2" edition = { workspace = true } publish = false diff --git a/python/tests/test_issue_135.py b/python/tests/test_issue_135.py new file mode 100644 index 0000000..18cfc1f --- /dev/null +++ b/python/tests/test_issue_135.py @@ -0,0 +1,32 @@ +# Copyright 2026 Pex project contributors. +# SPDX-License-Identifier: Apache-2.0 + +from __future__ import absolute_import + +import os.path +import subprocess + +import pytest +from testing import IS_WINDOWS, IS_X86_64, pexrc_inject + +TYPE_CHECKING = False +if TYPE_CHECKING: + # Ruff doesn't understand Python 2 and thus the type comment usages. + from typing import Any # noqa: F401 + + +@pytest.mark.skipif( + not (IS_WINDOWS and IS_X86_64), + reason=( + "The test requires the pythonnet dependency under test to be consumed as a win-amd64 wheel." + ), +) +def test_issue_135(tmpdir): + # type: (Any) -> None + + pex = os.path.join(tmpdir, "pex") + subprocess.check_call( + args=["pex", "--platform", "win-amd64-cp-314-cp314", "pythonnet==3.1.0", "-o", pex] + ) + injected_pex = pexrc_inject(pex) + subprocess.check_call(args=[injected_pex, "-c", "import pythonnet"]) diff --git a/src/commands/inject.rs b/src/commands/inject.rs index 1043cbb..dc7a63d 100644 --- a/src/commands/inject.rs +++ b/src/commands/inject.rs @@ -158,16 +158,24 @@ impl<'a> RequiredTargets<'a> { targets_by_project_name .entry(wheel.project_name) .or_insert_with(HashSet::new) - .extend( - wheel + .extend({ + let compatible = wheel .tags .iter() - .map(|tag| { + .filter_map(|tag| { SimplifiedTarget::for_platform_tag(tag.platform) .map(|targets| targets.map(|targets| (wheel.file_name, targets))) + .ok() }) - .collect::>>()?, - ); + .collect::>(); + if compatible.is_empty() { + bail!( + "There are no pexrc binaries available that support {wheel}.", + wheel = wheel.file_name + ) + } + compatible + }); } let mut required_targets = IndexSet::new(); for required in targets_by_project_name.values() { From fd71a8cb09c00ae4dc0e27382fff30835926d569 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Wed, 15 Jul 2026 18:09:29 -0700 Subject: [PATCH 2/2] Fix test. --- python/tests/test_issue_135.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/tests/test_issue_135.py b/python/tests/test_issue_135.py index 18cfc1f..20e5388 100644 --- a/python/tests/test_issue_135.py +++ b/python/tests/test_issue_135.py @@ -8,6 +8,7 @@ import pytest from testing import IS_WINDOWS, IS_X86_64, pexrc_inject +from testing.interpreter import ensure_python TYPE_CHECKING = False if TYPE_CHECKING: @@ -29,4 +30,5 @@ def test_issue_135(tmpdir): args=["pex", "--platform", "win-amd64-cp-314-cp314", "pythonnet==3.1.0", "-o", pex] ) injected_pex = pexrc_inject(pex) - subprocess.check_call(args=[injected_pex, "-c", "import pythonnet"]) + python = ensure_python(version=(3, 14)) + subprocess.check_call(args=[python, injected_pex, "-c", "import pythonnet"])