Skip to content

Commit 8296b5a

Browse files
fix: ignore Python install manager target files (Fixes #483) (#484)
## Summary - require Windows Python executable matches to end at the `.exe` suffix - exclude Python Install Manager `.__target__` metadata files from discovery - add regression coverage for unversioned and versioned target files ## Validation - `cargo test -p pet-python-utils executable::tests::is_` - `.\scripts\rust-precommit.ps1` Fixes #483 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0469b16 commit 8296b5a

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎crates/pet-python-utils/src/executable.rs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212

1313
lazy_static! {
1414
static ref WINDOWS_EXE: Regex =
15-
Regex::new(r"python(\d+\.?)*.exe").expect("error parsing Windows executable regex");
15+
Regex::new(r"python(\d+\.?)*\.exe$").expect("error parsing Windows executable regex");
1616
static ref UNIX_EXE: Regex =
1717
Regex::new(r"python(\d+\.?)*$").expect("error parsing Unix executable regex");
1818
}
@@ -342,6 +342,18 @@ mod tests {
342342
assert!(!is_python_executable_name(
343343
PathBuf::from("pythonw3.exe").as_path()
344344
));
345+
#[cfg(windows)]
346+
assert!(!is_python_executable_name(
347+
PathBuf::from("python.exe.__target__").as_path()
348+
));
349+
#[cfg(windows)]
350+
assert!(!is_python_executable_name(
351+
PathBuf::from("python3.exe.__target__").as_path()
352+
));
353+
#[cfg(windows)]
354+
assert!(!is_python_executable_name(
355+
PathBuf::from("python3.12.exe.__target__").as_path()
356+
));
345357
}
346358

347359
#[test]

0 commit comments

Comments
 (0)