1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
--- a/pygnulib/functions.py
+++ b/pygnulib/functions.py
@@ -16,6 +16,8 @@
from __future__ import annotations
import os.path
+import re
+import subprocess as sp
from .constants import substart
from .GLConfig import GLConfig
@@ -50,3 +52,15 @@ def rewrite_file_name(file_name: str, co
else: # file is not a special file
result = file_name
return os.path.normpath(result)
+
+def get_version(app: str) -> str:
+ result = sp.run([app, '--version'], capture_output=True, text=True)
+ version = re.sub(r".*[v ]([0-9])", r"\1", result.stdout)
+ version_lines = [line for line in version.splitlines() if re.search(r"^[0-9]", line)]
+ version = '\n'.join(version_lines) + "\n"
+ version = re.sub(r"[^.a-z0-9-\n].*", r"", version)
+ version = re.sub(r"^([0-9]*)[a-z-].*", r"\1", version, 1)
+ version = re.sub(r"\.0*([1-9])", r".\1", version)
+ version_lines = [line for line in version.splitlines() if line.strip()]
+ version = ''.join(version_lines[0]) + "\n"
+ return version.strip()
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -40,6 +40,7 @@ from .constants import (
rmtree,
)
from .functions import rewrite_file_name
+from .functions import get_version
from .GLError import GLError
from .GLConfig import GLConfig
from .GLModuleSystem import GLModuleTable
@@ -125,7 +126,8 @@ class GLImport:
for version in versions })
self.config.setAutoconfVersion(version)
if version < 2.64:
- raise GLError(4, version)
+ # If the version of autoconf in use is high enough, do not error.
+ if float(get_version('autoconf')) < 2.64: raise GLError(4, version)
# Get other cached variables.
path = joinpath(self.config['m4base'], 'gnulib-cache.m4')
|