Skip to contentSkip to conversation

python3-nose: translate to python3 code before build

PATCH In review Yi Zhao 2 participants 3 messages Nov 8, 2021 – Nov 9, 2021

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

PATCH 1/1 python3-nose: translate to python3 code before build

Setuptools has removed support for 2to3 during builds since version 58[1]. But the nose's setup.py relies on use_2to3 option in setuptools, it is failing an import and building without running 2to3 and generating valid python3 code. As a workaround, we use command line 2to3 tool to translate to Python3 code before build it.

Fixes:

$ python3
Quoted 1 line
Quoted 1 line
Quoted 1 line

import nose

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/nose/_init_.py", line 1, in <module> from nose.core import collector, main, run, run_exit, runmodule File "/usr/lib/python3.10/site-packages/nose/core.py", line 153 print "%s version %s" % (os.path.basename(sys.argv[0]), _version_) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

Quoted 1 line
Quoted 1 line
Quoted 1 line

[1] https://github.com/pypa/setuptools/issues/2086

---
 meta/recipes-devtools/python/python-nose.inc  |  6 ++
 .../python3-nose/0001-Remove-use_2to3.patch   | 71 +++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3-nose/0001-Remove-use_2to3.patch
meta/recipes-devtools/python/python-nose.inc +6 -0
index dfae202299..1a19cb96cf 100644
@@ -6,6 +6,8 @@ SECTION = "devel/python"
 LICENSE = "LGPLv2.1"
 LIC_FILES_CHKSUM = "file://lgpl.txt;md5=a6f89e2100d9b6cdffcea4f398e37343"
 
+SRC_URI += "file://0001-Remove-use_2to3.patch"
+
 SRC_URI[md5sum] = "4d3ad0ff07b61373d2cefc89c5d0b20b"
 SRC_URI[sha256sum] = "f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98"
 
@@ -15,4 +17,8 @@ RDEPENDS:${PN} = "\
   ${PYTHON_PN}-unittest \
   "
 
+do_compile:prepend() {
+    2to3 --write --nobackups --no-diffs ${S}
+}
+
 BBCLASSEXTEND = "native nativesdk"
meta/recipes-devtools/python/python3-nose/0001-Remove-use_2to3.patch new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw
Quoted 19 lines · Yi Zhao

Setuptools has removed support for 2to3 during builds since version 58[1]. But the nose's setup.py relies on use_2to3 option in setuptools, it is failing an import and building without running 2to3 and generating valid python3 code. As a workaround, we use command line 2to3 tool to translate to Python3 code before build it.

Fixes:

$ python3
Quoted 1 line
Quoted 1 line
Quoted 1 line

import nose

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/nose/_init_.py", line 1, in <module> from nose.core import collector, main, run, run_exit, runmodule File "/usr/lib/python3.10/site-packages/nose/core.py", line 153 print "%s version %s" % (os.path.basename(sys.argv[0]), _version_) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines

[1] https://github.com/pypa/setuptools/issues/2086

---
 meta/recipes-devtools/python/python-nose.inc  |  6 ++
 .../python3-nose/0001-Remove-use_2to3.patch   | 71 +++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3-nose/0001-Remove-use_2to3.patch

This failed in testing unfortunately:

https://autobuilder.yoctoproject.org/typhoon/#/builders/40/builds/4323/steps/14/logs/stdio

Cheers,

Richard

author
#2 lore raw
Quoted 26 lines · Richard Purdie
Quoted 19 lines · Yi Zhao

Setuptools has removed support for 2to3 during builds since version 58[1]. But the nose's setup.py relies on use_2to3 option in setuptools, it is failing an import and building without running 2to3 and generating valid python3 code. As a workaround, we use command line 2to3 tool to translate to Python3 code before build it.

Fixes:

$ python3
Quoted 1 line
Quoted 1 line
Quoted 1 line

import nose

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/nose/_init_.py", line 1, in <module> from nose.core import collector, main, run, run_exit, runmodule File "/usr/lib/python3.10/site-packages/nose/core.py", line 153 print "%s version %s" % (os.path.basename(sys.argv[0]), _version_) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
[1] https://github.com/pypa/setuptools/issues/2086

Quoted 6 lines
---
  meta/recipes-devtools/python/python-nose.inc  |  6 ++
  .../python3-nose/0001-Remove-use_2to3.patch   | 71 +++++++++++++++++++
  2 files changed, 77 insertions(+)

create mode 100644 meta/recipes-devtools/python/python3-nose/0001-Remove-use_2to3.patch

Quoted 3 lines

This failed in testing unfortunately:

https://autobuilder.yoctoproject.org/typhoon/#/builders/40/builds/4323/steps/14/logs/stdio

Hi Richard,

I can not reproduce this issue in my local. Is there any detail log that I can find ? Maybe it is a parallel build issue.

Thanks,

Yi

Quoted 4 lines

Cheers,

Richard