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
>>> import nose
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.10/site-packages/nose/_init_.py", line 1, in
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
Signed-off-by: Yi Zhao
---
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
diff --git a/meta/recipes-devtools/python/python-nose.inc
b/meta/recipes-devtools/python/python-nose.inc
index dfae202299..1a19cb96cf 100644
--- a/meta/recipes-devtools/python/python-nose.inc
+++ b/meta/recipes-devtools/python/python-nose.inc
@@ -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"
diff --git
a/meta/recipes-devtools/python/python3-nose/0001-Remove-use_2to3.patch
b/meta/recipes-devtools/python/python3-nose/0001-Remove-use_2to3.patch
new file mode 100644
index 00..1a0aabef75
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-nose/0001-Remove-use_2to3.patch
@@ -0,0 +1,71 @@
+From 4307868e31065c56456ddbf03325fc03643cd33f Mon Sep 17 00:00:00 2001
+From: Yi Zhao
+Date: Fri, 5 Nov 2021 10:12:16 +0800
+Subject: [PATCH] Remove use_2to3
+
+Since version 58, setuptools removed support for 2to3 during builds.
+
+Upstream-Status: Pending
+
+Signed-off-by: Yi Zhao
+---
+ setup.py | 3 +--
+ setup3lib.py | 7 +--
+ 2 files changed, 2 insertions(+), 8 deletions(-)
+
+diff --git a/setup.py b/setup.py
+index a2091c0..7e01bba 100644
+--- a/setup.py
b/setup.py
+@@ -13,8 +13,7 @@ if sys.version_info >= (3,):
+ from distribute_setup import use_setuptools
+ use_setuptools()
+
+-extra = {'use_2to3': True,
+- 'test_dirs': test_dirs,
++extra = {'test_dirs': test_dirs,
+ 'test_build_dir': 'build/tests',
+ 'pyversion_patching': True,
+ }
+diff --git a/setup3lib.py b/setup3lib.py
+index 27bdb93..761b74f 100644
+--- a/setup3lib.py
b/setup3lib.py
+@@ -18,7 +18,6 @@ else:
+ import logging
+ from setuptools import Distribution as _Distribution
+ from distutils.core import Command
+-from setuptools.command.build_py import Mixin2to3
+ from distutils import dir_util, file_util, log
+ import setuptools.command.test
+ from pkg_resources import normalize_path
+@@ -68,7 +67,7 @@ else:
+ self.pyversion_patching = False
+ _Distribution.__init__(self, attrs)
+
+-class BuildTestsCommand (Command, Mixin2to3):
++class BuildTestsCommand (Command):
+ # Create mirror copy of tests, convert all .py files using 2to3
+ user_options = []
+
+@@ -83,7 +82,6 @@ else:
+ self.test_base = test_base
+
+ def run(self):
+-use_2to3 = getattr(self.distribution, 'use_2to3', False)
+ test_dirs = getattr(self.distribution, 'test_dirs', [])
+ test_base = self.test_base
+ bpy_cmd = self.get_finalized_command("build_py")
+@@ -112,9 +110,6 @@ else:
+ if fn.endswith(ext):
+ doc_modified.append(dstfile)
+ break
+-if use_2to3:
+-self.run_2to3(py_modified)
+-self.run_2to3(doc_modified, True)
+ if self.distribution.pyversion_patching:
+ if patch is not None:
+ for file in modified:
+--
+2.17.1
+
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#157965):
https://lists.openembedded.org/g/openembedded-core/message/157965
Mute This Topic: https://lists.openembedded.org/mt/86900770/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: