Fix building libglib with python-3.12 without distutils.

38faeca62e
This commit is contained in:
Jonas 'Sortie' Termansen 2024-09-30 22:04:04 +02:00
parent ed234ccf9d
commit 89669b16dc

View file

@ -133,6 +133,61 @@ diff -Paur --no-dereference -- libglib.upstream/gio/data-to-c.py libglib/gio/dat
import sys
diff -Paur --no-dereference -- libglib.upstream/gio/gdbus-2.0/codegen/utils.py libglib/gio/gdbus-2.0/codegen/utils.py
--- libglib.upstream/gio/gdbus-2.0/codegen/utils.py
+++ libglib/gio/gdbus-2.0/codegen/utils.py
@@ -19,9 +19,9 @@
#
# Author: David Zeuthen <davidz@redhat.com>
-import distutils.version
import os
import sys
+import re
# pylint: disable=too-few-public-methods
class Color:
@@ -138,11 +138,35 @@
def version_cmp_key(key):
# If the 'since' version is 'UNRELEASED', compare higher than anything else
# If it is empty put a 0 in its place as this will
- # allow LooseVersion to work and will always compare lower.
- if key[0] == 'UNRELEASED':
- v = '9999'
+ # allow _parse_version() to work and will always compare lower.
+ if key[0] == "UNRELEASED":
+ v = "9999"
elif key[0]:
v = str(key[0])
else:
- v = '0'
- return (distutils.version.LooseVersion(v), key[1])
+ v = "0"
+ return (_parse_version(v), key[1])
+
+
+def _parse_version(version):
+ """
+ Parse a version string into a list of integers and strings.
+
+ This function takes a version string and breaks it down into its component parts.
+ It separates numeric and non-numeric segments, converting numeric segments to integers.
+
+ Args:
+ version (str): The version string to parse.
+
+ Returns:
+ list: A list where each element is either an integer (for numeric parts)
+ or a string (for non-numeric parts).
+
+ Example:
+ >>> parseversion("1.2.3a")
+ [1, 2, 3, 'a']
+ >>> parseversion("2.0.0-rc1")
+ [2, 0, 0, 'rc1']
+ """
+ blocks = re.findall(r"(\d+|\w+)", version)
+ return [int(b) if b.isdigit() else b for b in blocks]
diff -Paur --no-dereference -- libglib.upstream/gio/ginetsocketaddress.c libglib/gio/ginetsocketaddress.c
--- libglib.upstream/gio/ginetsocketaddress.c
+++ libglib/gio/ginetsocketaddress.c