]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141600: Fix musl version detection on Void Linux (GH-141602)
authorAndrew J. Hesford <ajh@sideband.org>
Sat, 22 Nov 2025 18:17:40 +0000 (13:17 -0500)
committerGitHub <noreply@github.com>
Sat, 22 Nov 2025 18:17:40 +0000 (12:17 -0600)
Lib/platform.py
Lib/test/test_platform.py
Lib/test/test_support.py
Misc/NEWS.d/next/Library/2025-11-15-14-58-12.gh-issue-141600.XY2BXg.rst [new file with mode: 0644]

index 4db93bea2a39e1ed6fab10e5b182573d3cac876d..b5017dbdb022524959ec9db75fc21a701ec85e3e 100644 (file)
@@ -197,7 +197,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
         | (GLIBC_([0-9.]+))
         | (libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)
         | (musl-([0-9.]+))
-        | (libc.musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
+        | ((?:libc\.|ld-)musl(?:-\w+)?.so(?:\.(\d[0-9.]*))?)
         """,
         re.ASCII | re.VERBOSE)
 
@@ -236,7 +236,7 @@ def libc_ver(executable=None, lib='', version='', chunksize=16384):
                 elif V(glibcversion) > V(ver):
                     ver = glibcversion
             elif so:
-                if lib != 'glibc':
+                if lib not in ('glibc', 'musl'):
                     lib = 'libc'
                     if soversion and (not ver or V(soversion) > V(ver)):
                         ver = soversion
index c07f96aecf4a7849a45b7b83590df9ee7a45682a..9ee97b922ad48e1c73e790e0b18a3d9180666fe3 100644 (file)
@@ -569,6 +569,8 @@ class PlatformTest(unittest.TestCase):
                 (b'/aports/main/musl/src/musl-1.2.5.7', ('musl', '1.2.5.7')),
                 (b'libc.musl.so.1', ('musl', '1')),
                 (b'libc.musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
+                (b'ld-musl.so.1', ('musl', '1')),
+                (b'ld-musl-x86_64.so.1.2.5', ('musl', '1.2.5')),
                 (b'', ('', '')),
             ):
                 with open(filename, 'wb') as fp:
@@ -591,6 +593,10 @@ class PlatformTest(unittest.TestCase):
                     b'libc.musl-x86_64.so.1.4.1\0libc.musl-x86_64.so.2.1.1\0libc.musl-x86_64.so.2.0.1',
                     ('musl', '2.1.1'),
                 ),
+                (
+                    b'ld-musl-x86_64.so.1.4.1\0ld-musl-x86_64.so.2.1.1\0ld-musl-x86_64.so.2.0.1',
+                    ('musl', '2.1.1'),
+                ),
                 (b'no match here, so defaults are used', ('test', '100.1.0')),
             ):
             with open(filename, 'wb') as f:
index d69328a6a6ac90c67471419ded6aa731184d83ce..667fcc81d8e378ca952003d9baa3f54c5da6998b 100644 (file)
@@ -798,10 +798,10 @@ class TestSupport(unittest.TestCase):
             self.assertTrue(linked)
         # The value is cached, so make sure it returns the same value again.
         self.assertIs(linked, support.linked_to_musl())
-        # The unlike libc, the musl version is a triple.
+        # The musl version is either triple or just a major version number.
         if linked:
             self.assertIsInstance(linked, tuple)
-            self.assertEqual(3, len(linked))
+            self.assertIn(len(linked), (1, 3))
             for v in linked:
                 self.assertIsInstance(v, int)
 
diff --git a/Misc/NEWS.d/next/Library/2025-11-15-14-58-12.gh-issue-141600.XY2BXg.rst b/Misc/NEWS.d/next/Library/2025-11-15-14-58-12.gh-issue-141600.XY2BXg.rst
new file mode 100644 (file)
index 0000000..8071246
--- /dev/null
@@ -0,0 +1 @@
+Fix musl version detection on Void Linux.