Skip to content

Commit 001ac99

Browse files
committed
Remove unused glibc functions
1 parent ba9f8e5 commit 001ac99

File tree

2 files changed

+0
-62
lines changed

2 files changed

+0
-62
lines changed

src/pip/_internal/utils/glibc.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from __future__ import absolute_import
55

66
import os
7-
import re
8-
import warnings
97

108
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
119

@@ -66,32 +64,6 @@ def glibc_version_string_ctypes():
6664
return version_str
6765

6866

69-
# Separated out from have_compatible_glibc for easier unit testing
70-
def check_glibc_version(version_str, required_major, minimum_minor):
71-
# type: (str, int, int) -> bool
72-
# Parse string and check against requested version.
73-
#
74-
# We use a regexp instead of str.split because we want to discard any
75-
# random junk that might come after the minor version -- this might happen
76-
# in patched/forked versions of glibc (e.g. Linaro's version of glibc
77-
# uses version strings like "2.20-2014.11"). See gh-3588.
78-
m = re.match(r"(?P<major>[0-9]+)\.(?P<minor>[0-9]+)", version_str)
79-
if not m:
80-
warnings.warn("Expected glibc version with 2 components major.minor,"
81-
" got: %s" % version_str, RuntimeWarning)
82-
return False
83-
return (int(m.group("major")) == required_major and
84-
int(m.group("minor")) >= minimum_minor)
85-
86-
87-
def have_compatible_glibc(required_major, minimum_minor):
88-
# type: (int, int) -> bool
89-
version_str = glibc_version_string()
90-
if version_str is None:
91-
return False
92-
return check_glibc_version(version_str, required_major, minimum_minor)
93-
94-
9567
# platform.libc_ver regularly returns completely nonsensical glibc
9668
# versions. E.g. on my computer, platform says:
9769
#

tests/unit/test_utils.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import stat
1111
import sys
1212
import time
13-
import warnings
1413
from io import BytesIO
1514

1615
import pytest
@@ -24,7 +23,6 @@
2423
from pip._internal.utils.deprecation import PipDeprecationWarning, deprecated
2524
from pip._internal.utils.encoding import BOMS, auto_decode
2625
from pip._internal.utils.glibc import (
27-
check_glibc_version,
2826
glibc_version_string,
2927
glibc_version_string_confstr,
3028
glibc_version_string_ctypes,
@@ -537,38 +535,6 @@ def raises(error):
537535

538536

539537
class TestGlibc(object):
540-
def test_manylinux_check_glibc_version(self):
541-
"""
542-
Test that the check_glibc_version function is robust against weird
543-
glibc version strings.
544-
"""
545-
for two_twenty in ["2.20",
546-
# used by "linaro glibc", see gh-3588
547-
"2.20-2014.11",
548-
# weird possibilities that I just made up
549-
"2.20+dev",
550-
"2.20-custom",
551-
"2.20.1",
552-
]:
553-
assert check_glibc_version(two_twenty, 2, 15)
554-
assert check_glibc_version(two_twenty, 2, 20)
555-
assert not check_glibc_version(two_twenty, 2, 21)
556-
assert not check_glibc_version(two_twenty, 3, 15)
557-
assert not check_glibc_version(two_twenty, 1, 15)
558-
559-
# For strings that we just can't parse at all, we should warn and
560-
# return false
561-
for bad_string in ["asdf", "", "foo.bar"]:
562-
with warnings.catch_warnings(record=True) as ws:
563-
warnings.filterwarnings("always")
564-
assert not check_glibc_version(bad_string, 2, 5)
565-
for w in ws:
566-
if "Expected glibc version with" in str(w.message):
567-
break
568-
else:
569-
# Didn't find the warning we were expecting
570-
assert False
571-
572538
def test_glibc_version_string(self, monkeypatch):
573539
monkeypatch.setattr(
574540
os, "confstr", lambda x: "glibc 2.20", raising=False,

0 commit comments

Comments
 (0)