From d8cdb7c1999f1610801302ea2273f6465d21f541 Mon Sep 17 00:00:00 2001 From: Alessandro De Maria Date: Sat, 5 Jul 2025 23:52:37 +0000 Subject: [PATCH] fix: add missing requires_python field to top-level PEX lock structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add requires_python field as Vec to PexLock struct - Populate with lock file's Python version requirement - Update test to include the new field - Fixes PEX parser error: "did not have the expected key 'requires_python'" Aligns with pants-generated PEX lock format which includes this field at the root level. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- crates/uv-resolver/src/lock/export/pex_lock.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/uv-resolver/src/lock/export/pex_lock.rs b/crates/uv-resolver/src/lock/export/pex_lock.rs index 711004065..867286958 100644 --- a/crates/uv-resolver/src/lock/export/pex_lock.rs +++ b/crates/uv-resolver/src/lock/export/pex_lock.rs @@ -50,6 +50,8 @@ pub struct PexLock { pub prefer_older_binary: bool, /// Direct requirements. pub requirements: Vec, + /// Python version requirements. + pub requires_python: Vec, /// The resolver version used. pub resolver_version: String, /// The style of resolution. @@ -247,6 +249,7 @@ impl PexLock { pip_version: Self::DEFAULT_PIP_VERSION.to_string(), prefer_older_binary: false, requirements, + requires_python: vec![lock.requires_python().to_string()], resolver_version: "pip-2020-resolver".to_string(), style: "universal".to_string(), target_systems: vec!["linux".to_string(), "mac".to_string()], @@ -294,6 +297,7 @@ mod tests { pip_version: PexLock::DEFAULT_PIP_VERSION.to_string(), prefer_older_binary: false, requirements: vec!["requests==2.31.0".to_string()], + requires_python: vec![">=3.8".to_string()], resolver_version: "pip-2020-resolver".to_string(), style: "universal".to_string(), target_systems: vec!["linux".to_string(), "mac".to_string()],