-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Reduce dependency on ctypes when discovering glibc version. #6678
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our current tests are lacking for this function in particular. We should add a few tests, at least checking:
os.confstr
throwing an expected exceptions falls back toctypes
-derived versionctypes
import failure causesNone
to be returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! Just a few small followup comments.
src/pip/_internal/utils/glibc.py
Outdated
|
||
# This strategy is used in the standard library platform module: | ||
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c9d0921ff3d70e1127ca1b71/Lib/platform.py#L175-L183 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick note: you don't need any of these three empty lines. Also, the three sentences can follow each other like a paragraph, with the link on its own line at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments.
tests/unit/test_utils.py
Outdated
@@ -701,6 +704,31 @@ def test_manylinux_check_glibc_version(self): | |||
# Didn't find the warning we were expecting | |||
assert False | |||
|
|||
def test_glibc_version_string_confstr_fail(self, monkeypatch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a successful case, too? In addition, it would probably be good to have at least one successful test of glibc_version_string()
, which you also modified. (The code for this test can be basically the same as the one for glibc_version_string_confstr()
.)
Thanks for the feedback, @cjerdonek! Tests are passing, ready for another review. |
Is there anything else that this needs before merging? @cjerdonek |
I'm gonna take the liberty of merging this without waiting on Chris to approve this PR -- if there's any more issues, we can address them in a follow up. |
Thanks @pradyunsg! |
Favor
os.confstr
when possible, falling back on the oldctypes
implementation otherwise. Gracefully handle a missingctypes
module.Closes #6543. Closes #6675. Supersedes and closes #6544.