pseudo: fix build for python3 based distros
This patch brings the support for python3 to pseudo, and it remains compatible with python2 (to keep compatibility).
The patches has been tested on BR and the generated C files (.h and .c) are identical for those three cases:
- original source using python2,
- patched source using python2, and
- patched source using python3.
Damien Riegel and Alexandre Leblanc helped me to for the last patch because my knowledge in python are basics.
PS: Those patches are also been sent to the maintainer (Peter Seebach in CC).
Regards,
Ga?l
Ga?l PORTAY (1):
pseudo: fix build for python3 based distros
.../0001-Fix-mixed-tab-space-indentation.patch | 105 ++++++++++ .../0002-Fix-missing-parentheses-at-print.patch | 190 ++++++++++++++++++ .../0003-Make-it-compatible-with-python3.patch | 215 +++++++++++++++++++++ 3 files changed, 510 insertions(+) create mode 100644 package/pseudo/0001-Fix-mixed-tab-space-indentation.patch create mode 100644 package/pseudo/0002-Fix-missing-parentheses-at-print.patch create mode 100644 package/pseudo/0003-Make-it-compatible-with-python3.patch
Signature · 1 line
2.10.1
PATCH 1/1 pseudo: fix build for python3 based distros
Pseudo is not python3 friendly. It causes build failure on distros using python3 as default python interpretor.
./maketables enums/*.in
File "./makewrappers", line 327
return """/* This function is not called if pseudo is configured --enable-force-async */
^
TabError: inconsistent use of tabs and spaces in indentation
File "./maketables", line 76
print "Flags: set for %s" % self.name
^
SyntaxError: Missing parentheses in call to 'print'
make[2]: *** [Makefile:150: wrappers] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:147: tables] Error 1
Those patches make pseudo works with python2 and python3.
--- .../0001-Fix-mixed-tab-space-indentation.patch | 105 ++++++++++ .../0002-Fix-missing-parentheses-at-print.patch | 190 ++++++++++++++++++ .../0003-Make-it-compatible-with-python3.patch | 215 +++++++++++++++++++++ 3 files changed, 510 insertions(+) create mode 100644 package/pseudo/0001-Fix-mixed-tab-space-indentation.patch create mode 100644 package/pseudo/0002-Fix-missing-parentheses-at-print.patch create mode 100644 package/pseudo/0003-Make-it-compatible-with-python3.patch
package/pseudo/0001-Fix-mixed-tab-space-indentation.patch new file +105 -0
@@ -0,0 +1,105 @@ +From bf4e5310547603bf36e67dc4cba027963f16508e Mon Sep 17 00:00:00 2001 +From: =?utf-8?q?Ga=C3=ABl=20PORTAY?= <[email protected]> +Date: Fri, 4 Nov 2016 11:53:48 -0400 +Subject: [PATCH 1/3] Fix mixed tab/space indentation +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit + +CC="cc -pipe -std=gnu99 -Wall -W -Wextra -fPIC -D_LARGEFILE64_SOURCE -D_ATFILE_SOURCE -DPSEUDO_PREFIX='"/usr/local"' -DPSEUDO_SUFFIX='""' -DPSEUDO_BINDIR='"bin"' -DPSEUDO_LIBDIR='"lib64"' -DPSEUDO_LOCALSTATEDIR='"var/pseudo"' -DPSEUDO_VERSION='"1.8.1"' -DUSE_MEMORY_DB -DPSEUDO_PASSWD_FALLBACK='""' -DPSEUDO_XATTR_SUPPORT -O2 -g " ./makewrappers "xattr=true" + File "./makewrappers", line 327 + return """/* This function is not called if pseudo is configured --enable-force-async */ + ^ +TabError: inconsistent use of tabs and spaces in indentation + +Signed-off-by: Ga?l PORTAY <[email protected]> +--- + makewrappers | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +diff --git a/makewrappers b/makewrappers +index e9191ed..303e2cc 100755 +--- a/makewrappers ++++ b/makewrappers +@@ -324,7 +324,7 @@ class Function: + + def maybe_async_skip(self): + if self.async_skip: +- return """/* This function is not called if pseudo is configured --enable-force-async */ ++ return """/* This function is not called if pseudo is configured --enable-force-async */ + #ifdef PSEUDO_FORCE_ASYNC + if (!pseudo_allow_fsync) { + PROFILE_DONE; +@@ -333,7 +333,7 @@ class Function: + #endif + """ % self.async_skip + else: +- return "" ++ return "" + + def comment(self): + """declare self (in a comment)""" +@@ -393,11 +393,11 @@ class Function: + + def rc_format(self): + """the format string to use for the return value""" +- return typedata.get(self.type, { 'format': '[%s]', 'value': '"' + self.type + '"' })['format'] ++ return typedata.get(self.type, { 'format': '[%s]', 'value': '"' + self.type + '"' })['format'] + + def rc_value(self): + """the value to pass for the format string for the return value""" +- return typedata.get(self.type, { 'format': '[%s]', 'value': '"' + self.type + '"' })['value'] ++ return typedata.get(self.type, { 'format': '[%s]', 'value': '"' + self.type + '"' })['value'] + + def rc_decl(self): + """declare rc (if needed)""" +@@ -456,7 +456,7 @@ additional ports to include. + self.name = port + self.subports = [] + self.preports = [] +- print port ++ print port + + if os.path.exists(self.portfile("pseudo_wrappers.c")): + self.wrappers = self.portfile("pseudo_wrappers.c") +@@ -522,11 +522,11 @@ additional ports to include. + return '#define PSEUDO_PORT_%s 1' % string.upper(self.name).replace('/', '_') + + def portdeps(self): +- deps = [] +- if self.wrappers: +- deps.append(self.wrappers) +- if self.portdef_file: +- deps.append(self.portdef_file) ++ deps = [] ++ if self.wrappers: ++ deps.append(self.wrappers) ++ if self.portdef_file: ++ deps.append(self.portdef_file) + if deps: + return 'pseudo_wrappers.o: %s' % ' '.join(deps) + else: +@@ -590,7 +590,7 @@ def main(argv): + + for arg in argv: + name, value = arg.split('=') +- os.environ["port_" + name] = value ++ os.environ["port_" + name] = value + + # error checking helpfully provided by the exception handler + copyright_file = open('guts/COPYRIGHT') +@@ -599,9 +599,9 @@ def main(argv): + + for path in glob.glob('templates/*'): + try: +- print "Considering template: " + path ++ print "Considering template: " + path + source = TemplateFile(path) +- if source.name.endswith('.c') or source.name.endswith('.h'): ++ if source.name.endswith('.c') or source.name.endswith('.h'): + source.emit('copyright') + source.emit('header') + sources.append(source) +-- +2.10.1 +
package/pseudo/0002-Fix-missing-parentheses-at-print.patch new file +190 -0
190 lines not on this page · raw message
package/pseudo/0003-Make-it-compatible-with-python3.patch new file +215 -0
215 lines not on this page · raw message
Signature · 1 line
2.10.1
PATCH 1/1 pseudo: fix build for python3 based distros
Ga?l, All,
On 2016-11-04 23:55 -0400, Ga?l PORTAY spake thusly:
Quoted 16 lines
Pseudo is not python3 friendly. It causes build failure on distros using python3 as default python interpretor.
./maketables enums/*.in
File "./makewrappers", line 327
return """/* This function is not called if pseudo is configured --enable-force-async */
^
TabError: inconsistent use of tabs and spaces in indentation
File "./maketables", line 76
print "Flags: set for %s" % self.name
^
SyntaxError: Missing parentheses in call to 'print'
make[2]: *** [Makefile:150: wrappers] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:147: tables] Error 1
Quoted 3 lines
Those patches make pseudo works with python2 and python3.
Signed-off-by Ga?l PORTAY <[email protected]>
My python is python2, and it still work.
Then I switched 'python' to 'python3' as the interpreter to use in both scripts, and it indeed work too.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 pseudo: fix build for python3 based distros
Yann,
Quoted 19 lines · Yann E. MORIN
Ga?l, All,
On 2016-11-04 23:55 -0400, Ga?l PORTAY spake thusly:
Quoted 16 lines
Pseudo is not python3 friendly. It causes build failure on distros using python3 as default python interpretor.
./maketables enums/*.in
File "./makewrappers", line 327
return """/* This function is not called if pseudo is configured --enable-force-async */
^
TabError: inconsistent use of tabs and spaces in indentation
File "./maketables", line 76
print "Flags: set for %s" % self.name
^
SyntaxError: Missing parentheses in call to 'print'
make[2]: *** [Makefile:150: wrappers] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:147: tables] Error 1
Quoted 8 lines
Quoted 3 lines
Those patches make pseudo works with python2 and python3.
Signed-off-by Ga?l PORTAY <[email protected]>My python is python2, and it still work.
Then I switched 'python' to 'python3' as the interpreter to use in both scripts, and it indeed work too.
Great! Thank you for the test.
Quoted 14 lines
Reviewed-by "Yann E. MORIN" <[email protected]>Tested-by "Yann E. MORIN" <[email protected]>Regards,
Yann E. MORIN.Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
Regards,
Ga?l PORTAY
Thomas Petazzoni
AppliedPATCH 1/1 pseudo: fix build for python3 based distros
In reply to Gaël PORTAYHello,
Quoted 19 lines · Ga?l PORTAY
Pseudo is not python3 friendly. It causes build failure on distros using python3 as default python interpretor.
./maketables enums/*.in
File "./makewrappers", line 327
return """/* This function is not called if pseudo is configured --enable-force-async */
^
TabError: inconsistent use of tabs and spaces in indentation
File "./maketables", line 76
print "Flags: set for %s" % self.name
^
SyntaxError: Missing parentheses in call to 'print'
make[2]: *** [Makefile:150: wrappers] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:147: tables] Error 1Those patches make pseudo works with python2 and python3.
Signed-off-by Ga?l PORTAY <[email protected]>
Quoted 8 lines
--- .../0001-Fix-mixed-tab-space-indentation.patch | 105 ++++++++++ .../0002-Fix-missing-parentheses-at-print.patch | 190 ++++++++++++++++++ .../0003-Make-it-compatible-with-python3.patch | 215 +++++++++++++++++++++ 3 files changed, 510 insertions(+) create mode 100644 package/pseudo/0001-Fix-mixed-tab-space-indentation.patch create mode 100644 package/pseudo/0002-Fix-missing-parentheses-at-print.patch create mode 100644 package/pseudo/0003-Make-it-compatible-with-python3.patch
Applied to master, thanks. My understanding is that you are already in touch with upstream to get them merged, right?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 pseudo: fix build for python3 based distros
Hi,
Quoted 31 lines · Thomas Petazzoni
Hello,
Quoted 19 lines · Ga?l PORTAY
Pseudo is not python3 friendly. It causes build failure on distros using python3 as default python interpretor.
./maketables enums/*.in
File "./makewrappers", line 327
return """/* This function is not called if pseudo is configured --enable-force-async */
^
TabError: inconsistent use of tabs and spaces in indentation
File "./maketables", line 76
print "Flags: set for %s" % self.name
^
SyntaxError: Missing parentheses in call to 'print'
make[2]: *** [Makefile:150: wrappers] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:147: tables] Error 1Those patches make pseudo works with python2 and python3.
Signed-off-by Ga?l PORTAY <[email protected]>Quoted 8 lines
--- .../0001-Fix-mixed-tab-space-indentation.patch | 105 ++++++++++ .../0002-Fix-missing-parentheses-at-print.patch | 190 ++++++++++++++++++ .../0003-Make-it-compatible-with-python3.patch | 215 +++++++++++++++++++++ 3 files changed, 510 insertions(+) create mode 100644 package/pseudo/0001-Fix-mixed-tab-space-indentation.patch create mode 100644 package/pseudo/0002-Fix-missing-parentheses-at-print.patch create mode 100644 package/pseudo/0003-Make-it-compatible-with-python3.patch
Quoted 3 lines
Applied to master, thanks. My understanding is that you are already in touch with upstream to get them merged, right?
Okay, perfect. Thanks!
Indeed, I am in touch with Seebs. He is in cc.
Quoted 7 lines
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com