From ae6ae35b5666ad22da528cd01aff7c680276eca5 Mon Sep 17 00:00:00 2001
From: Andreas Wacknitz <A.Wacknitz@gmx.de>
Date: Fri, 05 Apr 2024 17:27:21 +0200
Subject: [PATCH] clang-18: update to 18.1.3

---
 tools/python-requires |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/python-requires b/tools/python-requires
index 73dec05..eb027b7 100755
--- a/tools/python-requires
+++ b/tools/python-requires
@@ -15,21 +15,21 @@
 #
 
 #
-# Print requirements for a package.
-# Evaluated and normalized.
-# With optional EXTRA parameter passed print requirements for such extra only.
+# Usage:
+#   python-requires PACKAGE [EXTRA]
+#
+# Print requirements for PACKAGE.  Evaluated and normalized.
+# If PACKAGE is - evaluate and normalize stdin.
+# With optional EXTRA argument passed print requirements for such extra only.
 #
 
 import sys
 import re
 
 try:
-    try:
-        from importlib.metadata import requires
-    except ImportError:
-        from importlib_metadata import requires
+    from importlib.metadata import requires
     from packaging.requirements import Requirement
-    from packaging.markers import UndefinedEnvironmentName
+    import subprocess
 except:
     exit()
 
@@ -37,18 +37,18 @@
     exit()
 
 e = {'extra': sys.argv[2]} if len(sys.argv) > 2 else None
-# packaging up to 21.3 raises UndefinedEnvironmentName when extra is not
-# defined in environment, but marker contains it.  This should change in new
-# packaging once released.  See https://github.com/pypa/packaging/pull/550.  To
-# workaround this (so we do not need to handle exceptions) we pass empty extra
-# in environment when we do not want any extra.
-noe = {'extra': ''}
+reqs = requires(sys.argv[1]) if sys.argv[1] != "-" else sys.stdin.readlines()
 
 try:
-    for req in requires(sys.argv[1]):
-        r = Requirement(req)
+    for req in reqs:
+        try:
+            r = Requirement(re.sub(r"#.*", "", req))
+        except:
+            continue
         m = r.marker
-        if (not m and not e) or m and ((not e and m.evaluate(noe)) or (e and not m.evaluate(noe) and m.evaluate(e))):
+        if (not m and not e) or (m and m.evaluate(e) and (not e or not m.evaluate())):
             print(re.sub(r"[-_.]+", "-", r.name).lower())
+            for extra in r.extras:
+                subprocess.run([sys.argv[0], r.name, extra])
 except:
     pass

--
Gitblit v1.9.3