File tree Expand file tree Collapse file tree 1 file changed +27
-14
lines changed Expand file tree Collapse file tree 1 file changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -143,24 +143,37 @@ impl PythonProcessInfo {
143
143
144
144
// likewise handle libpython for python versions compiled with --enabled-shared
145
145
let libpython_binary = {
146
- let libmap = maps. iter ( ) . find ( |m| {
147
- if let Some ( pathname) = m. filename ( ) {
148
- if let Some ( pathname) = pathname. to_str ( ) {
149
- #[ cfg( not( windows) ) ]
150
- {
151
- return is_python_lib ( pathname) && m. is_exec ( ) ;
152
- }
153
- #[ cfg( windows) ]
154
- {
155
- return is_python_lib ( pathname) ;
146
+ let libmaps: Vec < _ > = maps
147
+ . iter ( )
148
+ . filter ( |m| {
149
+ if let Some ( pathname) = m. filename ( ) {
150
+ if let Some ( pathname) = pathname. to_str ( ) {
151
+ #[ cfg( not( windows) ) ]
152
+ {
153
+ return is_python_lib ( pathname) && m. is_exec ( ) ;
154
+ }
155
+ #[ cfg( windows) ]
156
+ {
157
+ return is_python_lib ( pathname) ;
158
+ }
156
159
}
157
160
}
158
- }
159
- false
160
- } ) ;
161
+ false
162
+ } )
163
+ . collect ( ) ;
161
164
162
165
let mut libpython_binary: Option < BinaryInfo > = None ;
163
- if let Some ( libpython) = libmap {
166
+
167
+ #[ cfg( not( target_os = "linux" ) ) ]
168
+ let libpython_option = if !libmaps. is_empty ( ) {
169
+ Some ( & libmaps[ 0 ] )
170
+ } else {
171
+ None
172
+ } ;
173
+ #[ cfg( target_os = "linux" ) ]
174
+ let libpython_option = libmaps. iter ( ) . min_by_key ( |m| m. offset ) ;
175
+
176
+ if let Some ( libpython) = libpython_option {
164
177
if let Some ( filename) = & libpython. filename ( ) {
165
178
info ! ( "Found libpython binary @ {}" , filename. display( ) ) ;
166
179
You can’t perform that action at this time.
0 commit comments