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 13, 2023
1 parent 492b41c commit 3498254
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.14
current_version = 0.3.14.1
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>(a|b|rc|\.dev)\d+))?
Expand Down
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 3498254

Please sign in to comment.