projects/guix·blob python-team · refs

132 lines · 4.7 KiB

1From: Thomas Nagy <[email protected]>
2Date: Tue, 7 Oct 2025 09:01:31 +0200
3Subject: Conceal imp warnings in Python3
4
5Origin: vendor, https://gitlab.com/ita1024/waf/-/commit/d2060dfd8af4edb5824153ff24e207b39ecd67a2
6Bug: https://github.com/aubio/aubio/issues/394
7Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1061736
8Bug-Ubuntu: https://bugs.launchpad.net/debian/+source/aubio/+bug/2051990
9Last-Update: 2024-02-02
10
11Workaround removal of imp module in Python 3.12
12
13IOhannes m zmölnig: also work around some warnings like
14> SyntaxWarning: invalid escape sequence '\s'
15
16due to non-raw strings.
17
18---
19 waflib/Context.py | 10 +++++++++-
20 waflib/Tools/python.py | 2 +-
21 2 files changed, 10 insertions(+), 2 deletions(-)
22
23--- aubio.orig/waflib/Context.py
24+++ aubio/waflib/Context.py
25@@ -2,9 +2,17 @@
26 # encoding: utf-8
27 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
28
29-import os,re,imp,sys
30+import os,re,sys
31 from waflib import Utils,Errors,Logs
32 import waflib.Node
33+
34+if sys.hexversion > 0x3040000:
35+ import types
36+ class imp(object):
37+ new_module = lambda x: types.ModuleType(x)
38+else:
39+ import imp
40+
41 HEXVERSION=0x2000e00
42 WAFVERSION="2.0.14"
43 WAFREVISION="907519cab9c1c8c7e4f7d4e468ed6200b9250d58"
44--- aubio.orig/waflib/Tools/python.py
45+++ aubio/waflib/Tools/python.py
46@@ -399,7 +399,7 @@
47 v.PYC=getattr(Options.options,'pyc',1)
48 v.PYO=getattr(Options.options,'pyo',1)
49 try:
50- v.PYTAG=conf.cmd_and_log(conf.env.PYTHON+['-c',"import imp;print(imp.get_tag())"]).strip()
51+ v.PYTAG = conf.cmd_and_log(conf.env.PYTHON + ['-c', "import sys\ntry:\n print(sys.implementation.cache_tag)\nexcept AttributeError:\n import imp\n print(imp.get_tag())\n"]).strip()
52 except Errors.WafError:
53 pass
54 def options(opt):
55--- aubio.orig/waflib/ConfigSet.py
56+++ aubio/waflib/ConfigSet.py
57@@ -4,7 +4,7 @@
58
59 import copy,re,os
60 from waflib import Logs,Utils
61-re_imp=re.compile('^(#)*?([^#=]*?)\ =\ (.*?)$',re.M)
62+re_imp=re.compile(r'^(#)*?([^#=]*?)\ =\ (.*?)$',re.M)
63 class ConfigSet(object):
64 __slots__=('table','parent')
65 def __init__(self,filename=None):
66--- aubio.orig/waflib/Task.py
67+++ aubio/waflib/Task.py
68@@ -567,7 +567,7 @@
69 dc={}
70 exec(c,dc)
71 return dc['f']
72-re_cond=re.compile('(?P<var>\w+)|(?P<or>\|)|(?P<and>&)')
73+re_cond=re.compile(r'(?P<var>\w+)|(?P<or>\|)|(?P<and>&)')
74 re_novar=re.compile(r'^(SRC|TGT)\W+.*?$')
75 reg_act=re.compile(r'(?P<backslash>\\)|(?P<dollar>\$\$)|(?P<subst>\$\{(?P<var>\w+)(?P<code>.*?)\})',re.M)
76 def compile_fun_shell(line):
77--- aubio.orig/waflib/TaskGen.py
78+++ aubio/waflib/TaskGen.py
79@@ -351,7 +351,7 @@
80 for y in self.tasks:
81 y.set_run_after(x)
82 self.bld.prev=self
83-re_m4=re.compile('@(\w+)@',re.M)
84+re_m4=re.compile(r'@(\w+)@',re.M)
85 class subst_pc(Task.Task):
86 def force_permissions(self):
87 if getattr(self.generator,'chmod',None):
88--- aubio.orig/waflib/Tools/c_preproc.py
89+++ aubio/waflib/Tools/c_preproc.py
90@@ -18,9 +18,9 @@
91 strict_quotes=0
92 g_optrans={'not':'!','not_eq':'!','and':'&&','and_eq':'&=','or':'||','or_eq':'|=','xor':'^','xor_eq':'^=','bitand':'&','bitor':'|','compl':'~',}
93 re_lines=re.compile('^[ \t]*(?:#|%:)[ \t]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef|pragma)[ \t]*(.*)\r*$',re.IGNORECASE|re.MULTILINE)
94-re_mac=re.compile("^[a-zA-Z_]\w*")
95+re_mac=re.compile(r"^[a-zA-Z_]\w*")
96 re_fun=re.compile('^[a-zA-Z_][a-zA-Z0-9_]*[(]')
97-re_pragma_once=re.compile('^\s*once\s*',re.IGNORECASE)
98+re_pragma_once=re.compile(r'^\s*once\s*',re.IGNORECASE)
99 re_nl=re.compile('\\\\\r*\n',re.MULTILINE)
100 re_cpp=re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',re.DOTALL|re.MULTILINE)
101 trig_def=[('??'+a,b)for a,b in zip("=-/!'()<>",r'#~\|^[]{}')]
102@@ -391,7 +391,7 @@
103 return(v,[[],t[1:]])
104 else:
105 return(v,[[],[('T','')]])
106-re_include=re.compile('^\s*(<(?:.*)>|"(?:.*)")')
107+re_include=re.compile(r'^\s*(<(?:.*)>|"(?:.*)")')
108 def extract_include(txt,defs):
109 m=re_include.search(txt)
110 if m:
111--- aubio.orig/waflib/Utils.py
112+++ aubio/waflib/Utils.py
113@@ -440,7 +440,7 @@
114 return s
115 if s=='cli'and os.name=='nt':
116 return'win32'
117- return re.split('\d+$',s)[0]
118+ return re.split(r'\d+$',s)[0]
119 def nada(*k,**kw):
120 pass
121 class Timer(object):
122--- aubio.orig/waflib/ansiterm.py
123+++ aubio/waflib/ansiterm.py
124@@ -175,7 +175,7 @@
125 self._csinfo.bVisible=0
126 windll.kernel32.SetConsoleCursorInfo(self.hconsole,byref(self._csinfo))
127 ansi_command_table={'A':move_up,'B':move_down,'C':move_right,'D':move_left,'E':next_line,'F':prev_line,'G':set_column,'H':set_cursor,'f':set_cursor,'J':clear_screen,'K':clear_line,'h':show_cursor,'l':hide_cursor,'m':set_color,'s':push_cursor,'u':pop_cursor,}
128- ansi_tokens=re.compile('(?:\x1b\[([0-9?;]*)([a-zA-Z])|([^\x1b]+))')
129+ ansi_tokens=re.compile(r'(?:\x1b\[([0-9?;]*)([a-zA-Z])|([^\x1b]+))')
130 def write(self,text):
131 try:
132 wlock.acquire()