Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6543.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Work around failure to import ctypes when resolving glibc version string.
10 changes: 9 additions & 1 deletion src/pip/_internal/utils/glibc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from __future__ import absolute_import

import ctypes
import re
import warnings

from pip._internal.utils.typing import MYPY_CHECK_RUNNING

# Work around https://bugs.python.org/issue37060.
try:
import ctypes
except (ImportError, OSError):
ctypes = None

if MYPY_CHECK_RUNNING:
from typing import Optional, Tuple

Expand All @@ -14,6 +19,9 @@ def glibc_version_string():
# type: () -> Optional[str]
"Returns glibc version string, or None if not using glibc."

if not ctypes:
return None

# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
# manpage says, "If filename is NULL, then the returned handle is for the
# main program". This way we can let the linker do the work to figure out
Expand Down