vcpkg/ports/glib/0005-pr-4133-4143-avoid-package-packaging.patch
2024-10-09 15:15:20 -04:00

60 lines
1.7 KiB
Diff

diff --git a/gio/gdbus-2.0/codegen/utils.py b/gio/gdbus-2.0/codegen/utils.py
index 08f1ba9..af803c0 100644
--- a/gio/gdbus-2.0/codegen/utils.py
+++ b/gio/gdbus-2.0/codegen/utils.py
@@ -19,10 +19,9 @@
#
# Author: David Zeuthen <davidz@redhat.com>
-import packaging.version
import os
import sys
-
+import re
# pylint: disable=too-few-public-methods
class Color:
@@ -166,4 +165,28 @@ def version_cmp_key(key):
v = str(key[0])
else:
v = "0"
- return (packaging.version.Version(v), key[1])
+ 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 --git a/meson.build b/meson.build
index a400965..576a939 100644
--- a/meson.build
+++ b/meson.build
@@ -2420,7 +2420,7 @@ endif
glib_conf.set('HAVE_PROC_SELF_CMDLINE', have_proc_self_cmdline)
-python = import('python').find_installation(modules: ['packaging'])
+python = import('python').find_installation()
# used for '#!/usr/bin/env <name>'
python_name = 'python3'