If we are on Linux and `path` is softlink and points to a shared library for which `objdump -p` contains 'SONAME', return the pointee. Otherwise return `path`. Useful if Linux shared libraries have been created with `-Wl,-soname,...`, where we need to embed the versioned library.
(path)
| 3164 | |
| 3165 | |
| 3166 | def get_soname(path): |
| 3167 | ''' |
| 3168 | If we are on Linux and `path` is softlink and points to a shared library |
| 3169 | for which `objdump -p` contains 'SONAME', return the pointee. Otherwise |
| 3170 | return `path`. Useful if Linux shared libraries have been created with |
| 3171 | `-Wl,-soname,...`, where we need to embed the versioned library. |
| 3172 | ''' |
| 3173 | if linux() and os.path.islink(path): |
| 3174 | path2 = os.path.realpath(path) |
| 3175 | if subprocess.run(f'objdump -p {path2}|grep SONAME', shell=1, check=0).returncode == 0: |
| 3176 | return path2 |
| 3177 | elif openbsd(): |
| 3178 | # Return newest .so with version suffix. |
| 3179 | sos = glob.glob(f'{path}.*') |
| 3180 | log1(f'{sos=}') |
| 3181 | sos2 = list() |
| 3182 | for so in sos: |
| 3183 | suffix = so[len(path):] |
| 3184 | if not suffix or re.match('^[.][0-9.]*[0-9]$', suffix): |
| 3185 | sos2.append(so) |
| 3186 | sos2.sort(key=lambda p: os.path.getmtime(p)) |
| 3187 | log1(f'{sos2=}') |
| 3188 | return sos2[-1] |
| 3189 | return path |
| 3190 | |
| 3191 | |
| 3192 | def current_py_limited_api(): |