summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorTim Orling <ticotimo@gmail.com>2022-01-11 11:01:27 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-01-12 21:09:02 +0000
commitfe86a1464905b40a1e08868796e3a2dfab79813b (patch)
treefb8def78ddb618b98f01b28c9dc24aeae3c10919 /scripts
parentc92ab86550eeb022c7deadd0b5c0d2fb23bd211b (diff)
downloadpoky-fe86a1464905b40a1e08868796e3a2dfab79813b.tar.gz
recipetool/create_buildsys_python.py: less distutils
'distutils' is deprecated in Python 3.10 with removal in Python 3.12 (~October 2023). Replace 'distutils.command.build_py' with 'setuptools.command.build_py'. To avoid an AttributeError, we call super().__init__() which provides the missing 'distribution' attribute. However, for some reason, __init__() in 'setuptools.command.build_py.build_py' class requires a 'dist' positional argument which must be a 'Distribution' instance. It is not clear why 'distutils.command.build_py.build_py' class does not require this. There is still a check which decides to inherit setuptools3 vs distutils3 that will need to be refactored when we add pyproject.toml and setup.cfg support for more modern PEP 517 packaging. Once distutils3.bbclass is dropped, any recipe inheriting distutils3 will throw a parsing error. The plan is to move distutils*.bbclasses to meta-python. However if meta-python is not in bblayers, the parsing error would still occur. [YOCTO #14610] (From OE-Core rev: 619a3eb1266459daf16e10386113e9201fbf9cf5) Signed-off-by: Tim Orling <tim.orling@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/recipetool/create_buildsys_python.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/lib/recipetool/create_buildsys_python.py b/scripts/lib/recipetool/create_buildsys_python.py
index 0b6b042ed1..1a15011687 100644
--- a/scripts/lib/recipetool/create_buildsys_python.py
+++ b/scripts/lib/recipetool/create_buildsys_python.py
@@ -8,7 +8,7 @@
8import ast 8import ast
9import codecs 9import codecs
10import collections 10import collections
11import distutils.command.build_py 11import setuptools.command.build_py
12import email 12import email
13import imp 13import imp
14import glob 14import glob
@@ -459,9 +459,13 @@ class PythonRecipeHandler(RecipeHandler):
459 else: 459 else:
460 package_dir = {} 460 package_dir = {}
461 461
462 class PackageDir(distutils.command.build_py.build_py): 462 dist = setuptools.Distribution()
463
464 class PackageDir(setuptools.command.build_py.build_py):
463 def __init__(self, package_dir): 465 def __init__(self, package_dir):
464 self.package_dir = package_dir 466 self.package_dir = package_dir
467 self.dist = dist
468 super().__init__(self.dist)
465 469
466 pd = PackageDir(package_dir) 470 pd = PackageDir(package_dir)
467 to_scan = [] 471 to_scan = []