Skip to content

Reintroduce testing linked libpython - #32

Merged
ktbarrett merged 3 commits into
masterfrom
dl_info
Mar 17, 2021
Merged

ktbarrett merged 3 commits into
masterfrom
dl_info

Conversation

@ktbarrett

@ktbarrett ktbarrett commented Mar 3, 2021 •

Copy link
Copy Markdown
Owner

Reverts #15.

@filmor Looks like it's still returning the executable on Ubuntu... I would think ctypes.pythonapi would be the executable even if it's --enable-shared because why load another library?

I think I'll come back to this by doing trial loading of candidate library names with ctypes.CDLL and passing the handle of libraries that succeed loading to this function. And not test ctypes.pythonapi.

It also almost works in msys2. Msys2 assumes dl_info.fname field is a unicode buffer unlike Unix where that info is static. I still get an empty name back after accounting for that, it requires more testing.

@ktbarrett

Copy link
Copy Markdown
Owner Author

@filmor The latest commit tries what I mentioned. Ubuntu now passes. I don't think your fix quite works. I'll merge this soon. I have to do some work in cygwin to get this same procedure with dl_info to work in msys2 environments.

The previous implementation only checked `ctypes.pythonapi`, which
depending on how the Python was configured could return a handle to the
executable or libpython. Attempts to filter out the executable and fall
back on other methods didn't work. Instead, we use the candidate names
to try loading the library and use dladdr to obtain the filepath.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant