Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle dlopen(NULL) failure in glibc fallback #12716

Merged
merged 4 commits into from
Jul 9, 2024

Conversation

charliermarsh
Copy link
Contributor

Summary

This PR applies the same exception handling to ctypes.CDLL(None) that already exists for the analogous method in packaging: pypa/packaging#294 (and, similarly, in pip's vendored packaging -- see src/pip/_vendor/packaging/_manylinux.py).

The basic idea is that if you're using a Python distribution built against musl libc, dlopen will fail (in addition to import ctypes itself failing).

Also relevant is indygreg@5139dc4 and #6543, where @indeygreg added the original try-except for ctypes.

@@ -50,7 +63,7 @@ def glibc_version_string_ctypes() -> Optional[str]:

# Call gnu_get_libc_version, which returns a string like "2.5"
gnu_get_libc_version.restype = ctypes.c_char_p
version_str = gnu_get_libc_version()
version_str: str = gnu_get_libc_version()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied over the full _glibc_version_string_ctypes from _manylinux.py, and this was the only other change. I can back it out if desired.

@ichard26 ichard26 added this to the 24.2 milestone Jun 10, 2024
Co-authored-by: Richard Si <sichard26@gmail.com>
@pradyunsg pradyunsg merged commit 601bcf8 into pypa:main Jul 9, 2024
7 of 8 checks passed
@pradyunsg
Copy link
Member

Thanks @charliermarsh!

jsirois pushed a commit to pex-tool/pip that referenced this pull request Jul 23, 2024
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
jsirois added a commit to pex-tool/pex that referenced this pull request Jul 24, 2024
This pulls in a new vendored version of Pip with
the recent fix in pypa/pip#12716 applied in
pex-tool/pip#13. As a result, Pex can run using
vendored Pip under statically linked musl libc CPython interpreters.
This opens the door to bootstrapping newer unpatched Pip's that also
have this same fix (versions 24.2 and later; see: #2471).

Fixes #2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants