mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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>
This commit is contained in:
parent
0e4c79a7c4
commit
bb59bcd016
|
@ -435,7 +435,45 @@ class RecipetoolTests(RecipetoolBase):
|
||||||
checkvars = {}
|
checkvars = {}
|
||||||
checkvars['LICENSE'] = set(['Apache-2.0'])
|
checkvars['LICENSE'] = set(['Apache-2.0'])
|
||||||
checkvars['SRC_URI'] = 'git://github.com/mesonbuild/meson;protocol=https'
|
checkvars['SRC_URI'] = 'git://github.com/mesonbuild/meson;protocol=https'
|
||||||
inherits = ['setuptools']
|
inherits = ['setuptools3']
|
||||||
|
self._test_recipe_contents(recipefile, checkvars, inherits)
|
||||||
|
|
||||||
|
def test_recipetool_create_python3_setuptools(self):
|
||||||
|
# Test creating python3 package from tarball (using setuptools3 class)
|
||||||
|
temprecipe = os.path.join(self.tempdir, 'recipe')
|
||||||
|
os.makedirs(temprecipe)
|
||||||
|
pn = 'python-magic'
|
||||||
|
pv = '0.4.15'
|
||||||
|
recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
|
||||||
|
srcuri = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-%s.tar.gz' % pv
|
||||||
|
result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
|
||||||
|
self.assertTrue(os.path.isfile(recipefile))
|
||||||
|
checkvars = {}
|
||||||
|
checkvars['LICENSE'] = set(['MIT'])
|
||||||
|
checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=16a934f165e8c3245f241e77d401bb88'
|
||||||
|
checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/30/80932401906eaf787f2e9bd86dc458f1d2e75b064b4c187341f29516945c/python-magic-${PV}.tar.gz'
|
||||||
|
checkvars['SRC_URI[md5sum]'] = 'e384c95a47218f66c6501cd6dd45ff59'
|
||||||
|
checkvars['SRC_URI[sha256sum]'] = 'f3765c0f582d2dfc72c15f3b5a82aecfae9498bd29ca840d72f37d7bd38bfcd5'
|
||||||
|
inherits = ['setuptools3']
|
||||||
|
self._test_recipe_contents(recipefile, checkvars, inherits)
|
||||||
|
|
||||||
|
def test_recipetool_create_python3_distutils(self):
|
||||||
|
# Test creating python3 package from tarball (using distutils3 class)
|
||||||
|
temprecipe = os.path.join(self.tempdir, 'recipe')
|
||||||
|
os.makedirs(temprecipe)
|
||||||
|
pn = 'docutils'
|
||||||
|
pv = '0.14'
|
||||||
|
recipefile = os.path.join(temprecipe, '%s_%s.bb' % (pn, pv))
|
||||||
|
srcuri = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-%s.tar.gz' % pv
|
||||||
|
result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
|
||||||
|
self.assertTrue(os.path.isfile(recipefile))
|
||||||
|
checkvars = {}
|
||||||
|
checkvars['LICENSE'] = set(['PSF', '&', 'BSD', 'GPL'])
|
||||||
|
checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.txt;md5=35a23d42b615470583563132872c97d6'
|
||||||
|
checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/84/f4/5771e41fdf52aabebbadecc9381d11dea0fa34e4759b4071244fa094804c/docutils-${PV}.tar.gz'
|
||||||
|
checkvars['SRC_URI[md5sum]'] = 'c53768d63db3873b7d452833553469de'
|
||||||
|
checkvars['SRC_URI[sha256sum]'] = '51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274'
|
||||||
|
inherits = ['distutils3']
|
||||||
self._test_recipe_contents(recipefile, checkvars, inherits)
|
self._test_recipe_contents(recipefile, checkvars, inherits)
|
||||||
|
|
||||||
def test_recipetool_create_github_tarball(self):
|
def test_recipetool_create_github_tarball(self):
|
||||||
|
@ -450,7 +488,7 @@ class RecipetoolTests(RecipetoolBase):
|
||||||
checkvars = {}
|
checkvars = {}
|
||||||
checkvars['LICENSE'] = set(['Apache-2.0'])
|
checkvars['LICENSE'] = set(['Apache-2.0'])
|
||||||
checkvars['SRC_URI'] = 'https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz'
|
checkvars['SRC_URI'] = 'https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz'
|
||||||
inherits = ['setuptools']
|
inherits = ['setuptools3']
|
||||||
self._test_recipe_contents(recipefile, checkvars, inherits)
|
self._test_recipe_contents(recipefile, checkvars, inherits)
|
||||||
|
|
||||||
def test_recipetool_create_git_http(self):
|
def test_recipetool_create_git_http(self):
|
||||||
|
|
|
@ -31,11 +31,11 @@ def tinfoil_init(instance):
|
||||||
|
|
||||||
|
|
||||||
class PythonRecipeHandler(RecipeHandler):
|
class PythonRecipeHandler(RecipeHandler):
|
||||||
base_pkgdeps = ['python-core']
|
base_pkgdeps = ['python3-core']
|
||||||
excluded_pkgdeps = ['python-dbg']
|
excluded_pkgdeps = ['python3-dbg']
|
||||||
# os.path is provided by python-core
|
# os.path is provided by python3-core
|
||||||
assume_provided = ['builtins', 'os.path']
|
assume_provided = ['builtins', 'os.path']
|
||||||
# Assumes that the host python builtin_module_names is sane for target too
|
# Assumes that the host python3 builtin_module_names is sane for target too
|
||||||
assume_provided = assume_provided + list(sys.builtin_module_names)
|
assume_provided = assume_provided + list(sys.builtin_module_names)
|
||||||
|
|
||||||
bbvar_map = {
|
bbvar_map = {
|
||||||
|
@ -215,9 +215,9 @@ class PythonRecipeHandler(RecipeHandler):
|
||||||
self.apply_info_replacements(info)
|
self.apply_info_replacements(info)
|
||||||
|
|
||||||
if uses_setuptools:
|
if uses_setuptools:
|
||||||
classes.append('setuptools')
|
classes.append('setuptools3')
|
||||||
else:
|
else:
|
||||||
classes.append('distutils')
|
classes.append('distutils3')
|
||||||
|
|
||||||
if license_str:
|
if license_str:
|
||||||
for i, line in enumerate(lines_before):
|
for i, line in enumerate(lines_before):
|
||||||
|
@ -282,7 +282,7 @@ class PythonRecipeHandler(RecipeHandler):
|
||||||
for feature, feature_reqs in extras_req.items():
|
for feature, feature_reqs in extras_req.items():
|
||||||
unmapped_deps.difference_update(feature_reqs)
|
unmapped_deps.difference_update(feature_reqs)
|
||||||
|
|
||||||
feature_req_deps = ('python-' + r.replace('.', '-').lower() for r in sorted(feature_reqs))
|
feature_req_deps = ('python3-' + r.replace('.', '-').lower() for r in sorted(feature_reqs))
|
||||||
lines_after.append('PACKAGECONFIG[{}] = ",,,{}"'.format(feature.lower(), ' '.join(feature_req_deps)))
|
lines_after.append('PACKAGECONFIG[{}] = ",,,{}"'.format(feature.lower(), ' '.join(feature_req_deps)))
|
||||||
|
|
||||||
inst_reqs = set()
|
inst_reqs = set()
|
||||||
|
@ -293,7 +293,7 @@ class PythonRecipeHandler(RecipeHandler):
|
||||||
if inst_reqs:
|
if inst_reqs:
|
||||||
unmapped_deps.difference_update(inst_reqs)
|
unmapped_deps.difference_update(inst_reqs)
|
||||||
|
|
||||||
inst_req_deps = ('python-' + r.replace('.', '-').lower() for r in sorted(inst_reqs))
|
inst_req_deps = ('python3-' + r.replace('.', '-').lower() for r in sorted(inst_reqs))
|
||||||
lines_after.append('# WARNING: the following rdepends are from setuptools install_requires. These')
|
lines_after.append('# WARNING: the following rdepends are from setuptools install_requires. These')
|
||||||
lines_after.append('# upstream names may not correspond exactly to bitbake package names.')
|
lines_after.append('# upstream names may not correspond exactly to bitbake package names.')
|
||||||
lines_after.append('RDEPENDS_${{PN}} += "{}"'.format(' '.join(inst_req_deps)))
|
lines_after.append('RDEPENDS_${{PN}} += "{}"'.format(' '.join(inst_req_deps)))
|
||||||
|
@ -356,7 +356,7 @@ class PythonRecipeHandler(RecipeHandler):
|
||||||
return info, 'setuptools' in imported_modules, non_literals, extensions
|
return info, 'setuptools' in imported_modules, non_literals, extensions
|
||||||
|
|
||||||
def get_setup_args_info(self, setupscript='./setup.py'):
|
def get_setup_args_info(self, setupscript='./setup.py'):
|
||||||
cmd = ['python', setupscript]
|
cmd = ['python3', setupscript]
|
||||||
info = {}
|
info = {}
|
||||||
keys = set(self.bbvar_map.keys())
|
keys = set(self.bbvar_map.keys())
|
||||||
keys |= set(self.setuparg_list_fields)
|
keys |= set(self.setuparg_list_fields)
|
||||||
|
@ -390,7 +390,7 @@ class PythonRecipeHandler(RecipeHandler):
|
||||||
def get_setup_byline(self, fields, setupscript='./setup.py'):
|
def get_setup_byline(self, fields, setupscript='./setup.py'):
|
||||||
info = {}
|
info = {}
|
||||||
|
|
||||||
cmd = ['python', setupscript]
|
cmd = ['python3', setupscript]
|
||||||
cmd.extend('--' + self.setuparg_map.get(f, f.lower()) for f in fields)
|
cmd.extend('--' + self.setuparg_map.get(f, f.lower()) for f in fields)
|
||||||
try:
|
try:
|
||||||
info_lines = self.run_command(cmd, cwd=os.path.dirname(setupscript)).splitlines()
|
info_lines = self.run_command(cmd, cwd=os.path.dirname(setupscript)).splitlines()
|
||||||
|
@ -527,7 +527,7 @@ class PythonRecipeHandler(RecipeHandler):
|
||||||
pkgdata_dir = tinfoil.config_data.getVar('PKGDATA_DIR')
|
pkgdata_dir = tinfoil.config_data.getVar('PKGDATA_DIR')
|
||||||
|
|
||||||
ldata = tinfoil.config_data.createCopy()
|
ldata = tinfoil.config_data.createCopy()
|
||||||
bb.parse.handle('classes/python-dir.bbclass', ldata, True)
|
bb.parse.handle('classes/python3-dir.bbclass', ldata, True)
|
||||||
python_sitedir = ldata.getVar('PYTHON_SITEPACKAGES_DIR')
|
python_sitedir = ldata.getVar('PYTHON_SITEPACKAGES_DIR')
|
||||||
|
|
||||||
dynload_dir = os.path.join(os.path.dirname(python_sitedir), 'lib-dynload')
|
dynload_dir = os.path.join(os.path.dirname(python_sitedir), 'lib-dynload')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user