Skip to content

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.

# 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
@pradyunsg pradyunsg merged commit 601bcf8 into pypa:main Jul 9, 2024
@pradyunsg
Copy link
Member

Thanks @charliermarsh!

jsirois pushed a commit to pex-tool/pip that referenced this pull request Jul 23, 2024
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