Browse Source

Add a forgotten (not mandatory file)

The file is the pyconfoigure m4 macros patch that solves tyhe python3 bug and add macro to check a module version number ( refs #140 )
Yann Weber 7 years ago
parent
commit
bfcb2a6b96
1 changed files with 124 additions and 0 deletions
  1. 124
    0
      m4/python_pyconfigure.m4.patch

+ 124
- 0
m4/python_pyconfigure.m4.patch View File

@@ -0,0 +1,124 @@
1
+--- /usr/share/pyconfigure/m4/python.m4	2016-04-27 05:19:12.000000000 +0200
2
++++ python_pyconfigure.m4	2016-09-01 11:59:49.690623000 +0200
3
+@@ -475,7 +475,10 @@ except:
4
+ else:
5
+     can_use_sysconfig = True
6
+ if can_use_sysconfig:
7
+-    if python_implementation() == "CPython" and sys.version[[:3]] == '2.7':
8
++    # Can't use sysconfig in CPython > 3.0 in debian since it's broken :
9
++    # <https://bugs.launchpad.net/ubuntu/+source/python3-defaults/+bug/1408092>
10
++    if python_implementation() == "CPython" (
11
++            float(sys.version[[:3]]) > 3.0 or sys.version[[:3]] == '2.7'):
12
+         can_use_sysconfig = False
13
+ if not can_use_sysconfig:        
14
+     from distutils import sysconfig
15
+@@ -644,3 +647,109 @@ m4_ifnblank([$1], [
16
+     ])
17
+ AS_IF([test "$[pc_cv_python_func_]pc_python_safe_mod[_$2]" = "no"], [$5], [$4])
18
+ ])# PC_PYTHON_CHECK_FUNC
19
++
20
++# PC_PYTHON_CHECK_MODULE_MATCH_VERSION(LIBRARY, VERSION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND)
21
++# -------------------------------------------------
22
++# Macro for checking if a Python library with this version is installed
23
++#
24
++AC_DEFUN([PC_PYTHON_CHECK_MODULE_MATCH_VERSION],
25
++[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
26
++m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
27
++AC_CACHE_CHECK([for Python '$1' library version '$2'],
28
++    [[pc_cv_python_module_version]pc_python_safe_mod],
29
++    [AC_LANG_PUSH(Python)[]dnl
30
++     AC_LINK_IFELSE(
31
++	[AC_LANG_PROGRAM([dnl
32
++import sys
33
++try:
34
++    import $1
35
++except:
36
++    version='no'
37
++else:
38
++    for vers_attr in ('__version__', 'version', 'version_info'):
39
++        if hasattr($1, vers_attr):
40
++            version = getattr($1, vers_attr)
41
++            break
42
++    else:
43
++        version = 'unknown'
44
++sys.stdout.write(version)
45
++], [])], 
46
++	[[pc_cv_python_module_version]pc_python_safe_mod=`./conftest`],
47
++	[AC_MSG_FAILURE([failed to run Python program])])
48
++	AC_LANG_POP(Python)[]dnl
49
++	])
50
++
51
++AS_IF([test "x$[pc_cv_python_module_version]pc_python_safe_mod" = "x$2" ],
52
++	[$3],
53
++	[	AS_IF(
54
++			[test "x$[pc_cv_python_module_version]pc_python_safe_mod" = 'unknown'],
55
++			AC_MSG_WARN([Unable to fetch version of Python module $1]))
56
++		[$4]
57
++	])
58
++])# PC_PYTHON_CHECK_MODULE_VERSION
59
++
60
++
61
++# PC_PYTHON_CHECK_MODULE_VERSION(LIBRARY, MIN-VERSION, MAX-VERSION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND)
62
++# -------------------------------------------------
63
++# Macro for checking if a Python library with this version is installed
64
++#
65
++AC_DEFUN([PC_PYTHON_CHECK_MODULE_VERSION],
66
++[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
67
++m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
68
++m4_append([pc_python_safe_mod], m4_bpatsubsts($2, [\.], [_]))
69
++m4_append([pc_python_safe_mod], m4_bpatsubsts($3, [\.], [_]))
70
++AC_CACHE_CHECK(
71
++    [for Python '$1' library m4_ifnblank([$2],['$2' <= ]) version m4_ifnblank([$3], [<= '$3'])],
72
++    [[pc_cv_python_module_version]pc_python_safe_mod],
73
++    [AC_LANG_PUSH(Python)[]dnl
74
++     AC_LINK_IFELSE(
75
++	[AC_LANG_PROGRAM([dnl
76
++import sys
77
++def cmp_vers(v1,v2):
78
++    v1 = v1.split('.')
79
++    v2 = v2.split('.')
80
++    for i in range(max([len](v1), [len](v2))):
81
++        v1v = int(v1[[i]] if i < [len](v1) else 0)
82
++        v2v = int(v2[[i]] if i < [len](v2) else 0)
83
++        if v1v > v2v:
84
++            return 1
85
++        if v1v < v2v:
86
++            return -1
87
++    return 0
88
++try:
89
++    import $1
90
++except:
91
++    result='not found'
92
++else:
93
++    result='yes'
94
++    vmin = '$2'
95
++    vmax = '$3'
96
++    for vers_attr in ('__version__', 'version', 'version_info'):
97
++        if hasattr($1, vers_attr):
98
++            version = getattr($1, vers_attr)
99
++            break
100
++    else:
101
++        result = 'unknown'
102
++    if version not in ('unknonwn', 'no'):
103
++        failmsg = "but "+ version + " found"
104
++        if [len](vmin) > 0:
105
++            if cmp_vers(version, vmin) < 0:
106
++                result = failmsg
107
++        if [len](vmax) > 0:
108
++            if cmp_vers(version, vmax) > 0:
109
++                result = failmsg
110
++
111
++sys.stdout.write(result)
112
++], [])], 
113
++	[[pc_cv_python_module_version]pc_python_safe_mod=`./conftest`],
114
++	[AC_MSG_FAILURE([failed to run Python program])])
115
++	AC_LANG_POP(Python)[]dnl
116
++	])
117
++AS_IF(	[test "$[pc_cv_python_module_version]pc_python_safe_mod" = "yes"],
118
++	[$4],
119
++	[	AS_IF(
120
++			[test "x$[pc_cv_python_module_version]pc_python_safe_mod" = 'unknown'],
121
++			AC_MSG_WARN([Unable to fetch version of Python module $1]))
122
++		[$5]
123
++	])
124
++])# PC_PYTHON_CHECK_MODULE_VERSION

Loading…
Cancel
Save