Skip to content

Commit

Permalink
Support pyston based libpython
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-jeong committed Sep 12, 2023
1 parent 492b41c commit 4626585
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/python_process_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,15 +659,16 @@ pub fn get_windows_python_symbols(
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
pub fn is_python_lib(pathname: &str) -> bool {
lazy_static! {
static ref RE: Regex = Regex::new(r"/libpython\d.\d\d?(m|d|u)?.so").unwrap();
static ref RE: Regex = Regex::new(r"/libpython\d.\d\d?(m|d|u)?(-pyston\d.\d)?.so").unwrap();
}
RE.is_match(pathname)
}

#[cfg(target_os = "macos")]
pub fn is_python_lib(pathname: &str) -> bool {
lazy_static! {
static ref RE: Regex = Regex::new(r"/libpython\d.\d\d?(m|d|u)?.(dylib|so)$").unwrap();
static ref RE: Regex =
Regex::new(r"/libpython\d.\d\d?(m|d|u)?(-pyston\d.\d)?.(dylib|so)$").unwrap();
}
RE.is_match(pathname) || is_python_framework(pathname)
}
Expand Down Expand Up @@ -714,7 +715,10 @@ mod tests {
#[test]
fn test_is_python_lib() {
// libpython bundled by pyinstaller https://github.com/benfred/py-spy/issues/42
assert!(is_python_lib("/tmp/_MEIOqzg01/libpython2.7.so.1.0"));
assert!(is_python_lib("/usr/lib/libpython3.8-pyston2.3.so.1.0"));

// test pyston based libpython
assert!(is_python_lib("/usr/lib/libpython2.7u.so"));

// test debug/malloc/unicode flags
assert!(is_python_lib("./libpython2.7.so"));
Expand Down

0 comments on commit 4626585

Please sign in to comment.