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

Reduce dependency on ctypes when discovering glibc version. #6678

Merged
merged 9 commits into from
Jul 21, 2019
Merged

Reduce dependency on ctypes when discovering glibc version. #6678

merged 9 commits into from
Jul 21, 2019

Conversation

brandtbucher
Copy link
Contributor

@brandtbucher brandtbucher commented Jul 3, 2019

Favor os.confstr when possible, falling back on the old ctypes implementation otherwise. Gracefully handle a missing ctypes module.

Closes #6543. Closes #6675. Supersedes and closes #6544.

Copy link
Member

@chrahunt chrahunt left a 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:

  1. os.confstr throwing an expected exceptions falls back to ctypes-derived version
  2. ctypes import failure causes None to be returned

src/pip/_internal/utils/glibc.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/glibc.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/glibc.py Outdated Show resolved Hide resolved
src/pip/_internal/utils/glibc.py Show resolved Hide resolved
Copy link
Member

@chrahunt chrahunt left a 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 Show resolved Hide resolved
src/pip/_internal/utils/glibc.py Outdated Show resolved Hide resolved
tests/unit/test_utils.py Outdated Show resolved Hide resolved

# This strategy is used in the standard library platform module:
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c9d0921ff3d70e1127ca1b71/Lib/platform.py#L175-L183

Copy link
Member

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.

Copy link
Member

@chrahunt chrahunt left a comment

Choose a reason for hiding this comment

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

LGTM. 👍

Copy link
Member

@cjerdonek cjerdonek left a 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 Show resolved Hide resolved
@@ -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):
Copy link
Member

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().)

news/6543.bugfix Outdated Show resolved Hide resolved
@brandtbucher
Copy link
Contributor Author

Thanks for the feedback, @cjerdonek! Tests are passing, ready for another review.

@brandtbucher
Copy link
Contributor Author

Is there anything else that this needs before merging? @cjerdonek

@pradyunsg pradyunsg added the type: enhancement Improvements to functionality label Jul 20, 2019
@pradyunsg
Copy link
Member

pradyunsg commented Jul 21, 2019

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.

@pradyunsg pradyunsg merged commit 8582f7e into pypa:master Jul 21, 2019
@brandtbucher
Copy link
Contributor Author

Thanks @pradyunsg!

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Aug 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: enhancement Improvements to functionality
Projects
None yet
5 participants