summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Pijanowski <maciej.pijanowski@3mdeb.com>2019-06-08 21:13:03 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-10 17:38:10 +0100
commitbb59bcd016bdd815809ac10df45d61c364c46df0 (patch)
tree890829945e4524c11d0e296b140efc98da3504bc
parent0e4c79a7c4dae93fb1b12e8c0a59e8252e3f4b71 (diff)
downloadpoky-bb59bcd016bdd815809ac10df45d61c364c46df0.tar.gz
recipetool: add python3 support
Add support for generating python3 recipes using the recipetool / devtool. Drop python2 support at the same time. Tested with: oe-selftest -r recipetool.RecipetoolTest [YOCTO #13264] (From OE-Core rev: d8b2f58974482b3b1ccc65c5f93104d0d7ba87bc) Signed-off-by: Maciej Pijanowski <maciej.pijanowski@3mdeb.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/recipetool.py42
-rw-r--r--scripts/lib/recipetool/create_buildsys_python.py22
2 files changed, 51 insertions, 13 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index f1cb37b53f..e3f5c71666 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -435,7 +435,45 @@ class RecipetoolTests(RecipetoolBase):
435 checkvars = {} 435 checkvars = {}
436 checkvars['LICENSE'] = set(['Apache-2.0']) 436 checkvars['LICENSE'] = set(['Apache-2.0'])
437 checkvars['SRC_URI'] = 'git://github.com/mesonbuild/meson;protocol=https' 437 checkvars['SRC_URI'] = 'git://github.com/mesonbuild/meson;protocol=https'
438 inherits = ['setuptools'] 438 inherits = ['setuptools3']
439 self._test_recipe_contents(recipefile, checkvars, inherits)
440
441 def test_recipetool_create_python3_setuptools(self):
442 # Test creating python3 package from tarball (using setuptools3 class)
443 temprecipe = os.path.join(self.tempdir, 'recipe')
444 os.makedirs(temprecipe)
445 pn = 'python-magic'
446 pv = '0.4.15'
447 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
448 srcuri = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-%s.tar.gz' % pv
449 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
450 self.assertTrue(os.path.isfile(recipefile))
451 checkvars = {}
452 checkvars['LICENSE'] = set(['MIT'])
453 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88'
454 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-${PV}.tar.gz'
455 checkvars['SRC_URI[md5sum]'] = 'e384c95a47218f66c6501cd6dd45ff59'
456 checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5'
457 inherits = ['setuptools3']
458 self._test_recipe_contents(recipefile, checkvars, inherits)
459
460 def test_recipetool_create_python3_distutils(self):
461 # Test creating python3 package from tarball (using distutils3 class)
462 temprecipe = os.path.join(self.tempdir, 'recipe')
463 os.makedirs(temprecipe)
464 pn = 'docutils'
465 pv = '0.14'
466 recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
467 srcuri = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-%s.tar.gz' % pv
468 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
469 self.assertTrue(os.path.isfile(recipefile))
470 checkvars = {}
471 checkvars['LICENSE'] = set(['PSF', '&', 'BSD', 'GPL'])
472 checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6'
473 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz'
474 checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de'
475 checkvars['SRC_URI[sha256sum]'] = '51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274'
476 inherits = ['distutils3']
439 self._test_recipe_contents(recipefile, checkvars, inherits) 477 self._test_recipe_contents(recipefile, checkvars, inherits)
440 478
441 def test_recipetool_create_github_tarball(self): 479 def test_recipetool_create_github_tarball(self):
@@ -450,7 +488,7 @@ class RecipetoolTests(RecipetoolBase):
450 checkvars = {} 488 checkvars = {}
451 checkvars['LICENSE'] = set(['Apache-2.0']) 489 checkvars['LICENSE'] = set(['Apache-2.0'])
452 checkvars['SRC_URI'] = 'https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz' 490 checkvars['SRC_URI'] = 'https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz'
453 inherits = ['setuptools'] 491 inherits = ['setuptools3']
454 self._test_recipe_contents(recipefile, checkvars, inherits) 492 self._test_recipe_contents(recipefile, checkvars, inherits)
455 493
456 def test_recipetool_create_git_http(self): 494 def test_recipetool_create_git_http(self):
diff --git a/scripts/lib/recipetool/create_buildsys_python.py b/scripts/lib/recipetool/create_buildsys_python.py
index 1a38bd0b14..ac9bc9237c 100644
--- a/scripts/lib/recipetool/create_buildsys_python.py
+++ b/scripts/lib/recipetool/create_buildsys_python.py
@@ -31,11 +31,11 @@ def tinfoil_init(instance):
31 31
32 32
33class PythonRecipeHandler(RecipeHandler): 33class PythonRecipeHandler(RecipeHandler):
34 base_pkgdeps = ['python-core'] 34 base_pkgdeps = ['python3-core']
35 excluded_pkgdeps = ['python-dbg'] 35 excluded_pkgdeps = ['python3-dbg']
36 # os.path is provided by python-core 36 # os.path is provided by python3-core
37 assume_provided = ['builtins', 'os.path'] 37 assume_provided = ['builtins', 'os.path']
38 # Assumes that the host python builtin_module_names is sane for target too 38 # Assumes that the host python3 builtin_module_names is sane for target too
39 assume_provided = assume_provided + list(sys.builtin_module_names) 39 assume_provided = assume_provided + list(sys.builtin_module_names)
40 40
41 bbvar_map = { 41 bbvar_map = {
@@ -215,9 +215,9 @@ class PythonRecipeHandler(RecipeHandler):
215 self.apply_info_replacements(info) 215 self.apply_info_replacements(info)
216 216
217 if uses_setuptools: 217 if uses_setuptools:
218 classes.append('setuptools') 218 classes.append('setuptools3')
219 else: 219 else:
220 classes.append('distutils') 220 classes.append('distutils3')
221 221
222 if license_str: 222 if license_str:
223 for i, line in enumerate(lines_before): 223 for i, line in enumerate(lines_before):
@@ -282,7 +282,7 @@ class PythonRecipeHandler(RecipeHandler):
282 for feature, feature_reqs in extras_req.items(): 282 for feature, feature_reqs in extras_req.items():
283 unmapped_deps.difference_update(feature_reqs) 283 unmapped_deps.difference_update(feature_reqs)
284 284
285 feature_req_deps = ('python-' + r.replace('.', '-').lower() for r in sorted(feature_reqs)) 285 feature_req_deps = ('python3-' + r.replace('.', '-').lower() for r in sorted(feature_reqs))
286 lines_after.append('PACKAGECONFIG[{}] = ",,,{}"'.format(feature.lower(), ' '.join(feature_req_deps))) 286 lines_after.append('PACKAGECONFIG[{}] = ",,,{}"'.format(feature.lower(), ' '.join(feature_req_deps)))
287 287
288 inst_reqs = set() 288 inst_reqs = set()
@@ -293,7 +293,7 @@ class PythonRecipeHandler(RecipeHandler):
293 if inst_reqs: 293 if inst_reqs:
294 unmapped_deps.difference_update(inst_reqs) 294 unmapped_deps.difference_update(inst_reqs)
295 295
296 inst_req_deps = ('python-' + r.replace('.', '-').lower() for r in sorted(inst_reqs)) 296 inst_req_deps = ('python3-' + r.replace('.', '-').lower() for r in sorted(inst_reqs))
297 lines_after.append('# WARNING: the following rdepends are from setuptools install_requires. These') 297 lines_after.append('# WARNING: the following rdepends are from setuptools install_requires. These')
298 lines_after.append('# upstream names may not correspond exactly to bitbake package names.') 298 lines_after.append('# upstream names may not correspond exactly to bitbake package names.')
299 lines_after.append('RDEPENDS_${{PN}} += "{}"'.format(' '.join(inst_req_deps))) 299 lines_after.append('RDEPENDS_${{PN}} += "{}"'.format(' '.join(inst_req_deps)))
@@ -356,7 +356,7 @@ class PythonRecipeHandler(RecipeHandler):
356 return info, 'setuptools' in imported_modules, non_literals, extensions 356 return info, 'setuptools' in imported_modules, non_literals, extensions
357 357
358 def get_setup_args_info(self, setupscript='./setup.py'): 358 def get_setup_args_info(self, setupscript='./setup.py'):
359 cmd = ['python', setupscript] 359 cmd = ['python3', setupscript]
360 info = {} 360 info = {}
361 keys = set(self.bbvar_map.keys()) 361 keys = set(self.bbvar_map.keys())
362 keys |= set(self.setuparg_list_fields) 362 keys |= set(self.setuparg_list_fields)
@@ -390,7 +390,7 @@ class PythonRecipeHandler(RecipeHandler):
390 def get_setup_byline(self, fields, setupscript='./setup.py'): 390 def get_setup_byline(self, fields, setupscript='./setup.py'):
391 info = {} 391 info = {}
392 392
393 cmd = ['python', setupscript] 393 cmd = ['python3', setupscript]
394 cmd.extend('--' + self.setuparg_map.get(f, f.lower()) for f in fields) 394 cmd.extend('--' + self.setuparg_map.get(f, f.lower()) for f in fields)
395 try: 395 try:
396 info_lines = self.run_command(cmd, cwd=os.path.dirname(setupscript)).splitlines() 396 info_lines = self.run_command(cmd, cwd=os.path.dirname(setupscript)).splitlines()
@@ -527,7 +527,7 @@ class PythonRecipeHandler(RecipeHandler):
527 pkgdata_dir = tinfoil.config_data.getVar('PKGDATA_DIR') 527 pkgdata_dir = tinfoil.config_data.getVar('PKGDATA_DIR')
528 528
529 ldata = tinfoil.config_data.createCopy() 529 ldata = tinfoil.config_data.createCopy()
530 bb.parse.handle('classes/python-dir.bbclass', ldata, True) 530 bb.parse.handle('classes/python3-dir.bbclass', ldata, True)
531 python_sitedir = ldata.getVar('PYTHON_SITEPACKAGES_DIR') 531 python_sitedir = ldata.getVar('PYTHON_SITEPACKAGES_DIR')
532 532
533 dynload_dir = os.path.join(os.path.dirname(python_sitedir), 'lib-dynload') 533 dynload_dir = os.path.join(os.path.dirname(python_sitedir), 'lib-dynload')