From 34982540918c974ba28c5d2e2d10491a5c5c0946 Mon Sep 17 00:00:00 2001 From: "gavin.jeong" Date: Tue, 12 Sep 2023 23:12:14 +0900 Subject: [PATCH] Support pyston based libpython --- setup.cfg | 2 +- src/python_process_info.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index f57ac93a..96ebcacb 100755 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.3.14 +current_version = 0.3.14.1 commit = True tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)((?P(a|b|rc|\.dev)\d+))? diff --git a/src/python_process_info.rs b/src/python_process_info.rs index 4c6210cb..7b6ae6c4 100644 --- a/src/python_process_info.rs +++ b/src/python_process_info.rs @@ -659,7 +659,7 @@ 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) } @@ -667,7 +667,8 @@ pub fn is_python_lib(pathname: &str) -> bool { #[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) } @@ -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"));