summaryrefslogtreecommitdiff
path: root/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/glibc.py
diff options
context:
space:
mode:
authorShubham Saini <shubham6405@gmail.com>2019-08-05 08:32:33 +0000
committerShubham Saini <shubham6405@gmail.com>2019-08-05 08:32:33 +0000
commit227b2d30a8675b44918f9d9ca89b24144a938215 (patch)
tree9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/glibc.py
parent842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff)
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/glibc.py')
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/glibc.py84
1 files changed, 0 insertions, 84 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/glibc.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/glibc.py
deleted file mode 100644
index 5900a10..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/glibc.py
+++ /dev/null
@@ -1,84 +0,0 @@
1from __future__ import absolute_import
2
3import ctypes
4import re
5import warnings
6
7
8def glibc_version_string():
9 "Returns glibc version string, or None if not using glibc."
10
11 # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
12 # manpage says, "If filename is NULL, then the returned handle is for the
13 # main program". This way we can let the linker do the work to figure out
14 # which libc our process is actually using.
15 process_namespace = ctypes.CDLL(None)
16 try:
17 gnu_get_libc_version = process_namespace.gnu_get_libc_version
18 except AttributeError:
19 # Symbol doesn't exist -> therefore, we are not linked to
20 # glibc.
21 return None
22
23 # Call gnu_get_libc_version, which returns a string like "2.5"
24 gnu_get_libc_version.restype = ctypes.c_char_p
25 version_str = gnu_get_libc_version()
26 # py2 / py3 compatibility:
27 if not isinstance(version_str, str):
28 version_str = version_str.decode("ascii")
29
30 return version_str
31
32
33# Separated out from have_compatible_glibc for easier unit testing
34def check_glibc_version(version_str, required_major, minimum_minor):
35 # Parse string and check against requested version.
36 #
37 # We use a regexp instead of str.split because we want to discard any
38 # random junk that might come after the minor version -- this might happen
39 # in patched/forked versions of glibc (e.g. Linaro's version of glibc
40 # uses version strings like "2.20-2014.11"). See gh-3588.
41 m = re.match(r"(?P<major>[0-9]+)\.(?P<minor>[0-9]+)", version_str)
42 if not m:
43 warnings.warn("Expected glibc version with 2 components major.minor,"
44 " got: %s" % version_str, RuntimeWarning)
45 return False
46 return (int(m.group("major")) == required_major and
47 int(m.group("minor")) >= minimum_minor)
48
49
50def have_compatible_glibc(required_major, minimum_minor):
51 version_str = glibc_version_string()
52 if version_str is None:
53 return False
54 return check_glibc_version(version_str, required_major, minimum_minor)
55
56
57# platform.libc_ver regularly returns completely nonsensical glibc
58# versions. E.g. on my computer, platform says:
59#
60# ~$ python2.7 -c 'import platform; print(platform.libc_ver())'
61# ('glibc', '2.7')
62# ~$ python3.5 -c 'import platform; print(platform.libc_ver())'
63# ('glibc', '2.9')
64#
65# But the truth is:
66#
67# ~$ ldd --version
68# ldd (Debian GLIBC 2.22-11) 2.22
69#
70# This is unfortunate, because it means that the linehaul data on libc
71# versions that was generated by pip 8.1.2 and earlier is useless and
72# misleading. Solution: instead of using platform, use our code that actually
73# works.
74def libc_ver():
75 """Try to determine the glibc version
76
77 Returns a tuple of strings (lib, version) which default to empty strings
78 in case the lookup fails.
79 """
80 glibc_version = glibc_version_string()
81 if glibc_version is None:
82 return ("", "")
83 else:
84 return ("glibc", glibc_version)