summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Stephan <jstephan@baylibre.com>2023-10-25 17:46:59 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-27 08:28:38 +0100
commit9f306937ba2cfb0de7d716e25c9ae103e97d78a8 (patch)
tree1eeb99bbb0e00aca1f06fc3f05f75bcdb9e05b4b
parentd4debbf5b7ff9e0f489530aa748c559d631eeb57 (diff)
downloadpoky-9f306937ba2cfb0de7d716e25c9ae103e97d78a8.tar.gz
oeqa/selftest/recipetool: add selftest for PEP-517 recipe creation
Add 3 tests to check the creation of PEP-517 project using the 3 backends supported by bitbake: - setuptools.build_meta - poetry.core.masonry.api - flit_core.buildapi Theses tests requires the tomllib python module, so skip theses tests if module is not present. tomllib module is part of python starting from 3.11 (From OE-Core rev: 54356c6f1290d0d4170ed52f7bb358bb9efc1aec) Signed-off-by: Julien Stephan <jstephan@baylibre.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/recipetool.py102
1 files changed, 102 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index d3aea74228..8e0fc995f7 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -474,6 +474,108 @@ class RecipetoolCreateTests(RecipetoolBase):
474 inherits = ['setuptools3'] 474 inherits = ['setuptools3']
475 self._test_recipe_contents(recipefile, checkvars, inherits) 475 self._test_recipe_contents(recipefile, checkvars, inherits)
476 476
477 def test_recipetool_create_python3_pep517_setuptools_build_meta(self):
478 # This test require python 3.11 or above for the tomllib module
479 # or tomli module to be installed
480 try:
481 import tomllib
482 except ImportError:
483 try:
484 import tomli
485 except ImportError:
486 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
487
488 # Test creating python3 package from tarball (using setuptools.build_meta class)
489 temprecipe = os.path.join(self.tempdir, 'recipe')
490 os.makedirs(temprecipe)
491 pn = 'webcolors'
492 pv = '1.13'
493 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
494 srcuri = 'https://files.pythonhosted.org/packages/a1/fb/f95560c6a5d4469d9c49e24cf1b5d4d21ffab5608251c6020a965fb7791c/%s-%s.tar.gz' % (pn, pv)
495 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
496 self.assertTrue(os.path.isfile(recipefile))
497 checkvars = {}
498 checkvars['SUMMARY'] = 'A library for working with the color formats defined by HTML and CSS.'
499 checkvars['LICENSE'] = set(['BSD-3-Clause'])
500 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=702b1ef12cf66832a88f24c8f2ee9c19'
501 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/a1/fb/f95560c6a5d4469d9c49e24cf1b5d4d21ffab5608251c6020a965fb7791c/webcolors-${PV}.tar.gz'
502 checkvars['SRC_URI[md5sum]'] = 'c9be30c5b0cf1cad32e4cbacbb2229e9'
503 checkvars['SRC_URI[sha1sum]'] = 'c90b84fb65eed9b4c9dea7f08c657bfac0e820a5'
504 checkvars['SRC_URI[sha256sum]'] = 'c225b674c83fa923be93d235330ce0300373d02885cef23238813b0d5668304a'
505 checkvars['SRC_URI[sha384sum]'] = '45652af349660f19f68d01361dd5bda287789e5ea63608f52a8cea526ac04465614db2ea236103fb8456b1fcaea96ed7'
506 checkvars['SRC_URI[sha512sum]'] = '074aaf135ac6b0025b88b731d1d6dfa4c539b4fff7195658cc58a4326bb9f0449a231685d312b4a1ec48ca535a838bfa5c680787fe0e61473a2a092c448937d0'
507 inherits = ['python_setuptools_build_meta']
508
509 self._test_recipe_contents(recipefile, checkvars, inherits)
510
511 def test_recipetool_create_python3_pep517_poetry_core_masonry_api(self):
512 # This test require python 3.11 or above for the tomllib module
513 # or tomli module to be installed
514 try:
515 import tomllib
516 except ImportError:
517 try:
518 import tomli
519 except ImportError:
520 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
521
522 # Test creating python3 package from tarball (using poetry.core.masonry.api class)
523 temprecipe = os.path.join(self.tempdir, 'recipe')
524 os.makedirs(temprecipe)
525 pn = 'iso8601'
526 pv = '2.1.0'
527 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
528 srcuri = 'https://files.pythonhosted.org/packages/b9/f3/ef59cee614d5e0accf6fd0cbba025b93b272e626ca89fb70a3e9187c5d15/%s-%s.tar.gz' % (pn, pv)
529 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
530 self.assertTrue(os.path.isfile(recipefile))
531 checkvars = {}
532 checkvars['SUMMARY'] = 'Simple module to parse ISO 8601 dates'
533 checkvars['LICENSE'] = set(['MIT'])
534 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=aab31f2ef7ba214a5a341eaa47a7f367'
535 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/b9/f3/ef59cee614d5e0accf6fd0cbba025b93b272e626ca89fb70a3e9187c5d15/iso8601-${PV}.tar.gz'
536 checkvars['SRC_URI[md5sum]'] = '6e33910eba87066b3be7fcf3d59d16b5'
537 checkvars['SRC_URI[sha1sum]'] = 'efd225b2c9fa7d9e4a1ec6ad94f3295cee982e61'
538 checkvars['SRC_URI[sha256sum]'] = '6b1d3829ee8921c4301998c909f7829fa9ed3cbdac0d3b16af2d743aed1ba8df'
539 checkvars['SRC_URI[sha384sum]'] = '255002433fe65c19adfd6b91494271b613cb25ef6a35ac77436de1e03d60cc07bf89fd716451b917f1435e4384860ef6'
540 checkvars['SRC_URI[sha512sum]'] = 'db57ab2a25ef91e3bc479c8539d27e853cf1fbf60986820b8999ae15d7e566425a1e0cfba47d0f3b23aa703db0576db368e6c110ba2a2f46c9a34e8ee3611fb7'
541 inherits = ['python_poetry_core']
542
543 self._test_recipe_contents(recipefile, checkvars, inherits)
544
545 def test_recipetool_create_python3_pep517_flit_core_buildapi(self):
546 # This test require python 3.11 or above for the tomllib module
547 # or tomli module to be installed
548 try:
549 import tomllib
550 except ImportError:
551 try:
552 import tomli
553 except ImportError:
554 self.skipTest('Test requires python 3.11 or above for tomllib module or tomli module')
555
556 # Test creating python3 package from tarball (using flit_core.buildapi class)
557 temprecipe = os.path.join(self.tempdir, 'recipe')
558 os.makedirs(temprecipe)
559 pn = 'typing-extensions'
560 pv = '4.8.0'
561 recipefile = os.path.join(temprecipe, 'python3-%s_%s.bb' % (pn, pv))
562 srcuri = 'https://files.pythonhosted.org/packages/1f/7a/8b94bb016069caa12fc9f587b28080ac33b4fbb8ca369b98bc0a4828543e/typing_extensions-%s.tar.gz' % pv
563 result = runCmd('recipetool create -o %s %s' % (temprecipe, srcuri))
564 self.assertTrue(os.path.isfile(recipefile))
565 checkvars = {}
566 checkvars['SUMMARY'] = 'Backported and Experimental Type Hints for Python 3.8+'
567 checkvars['LICENSE'] = set(['PSF-2.0'])
568 checkvars['LIC_FILES_CHKSUM'] = 'file://LICENSE;md5=fcf6b249c2641540219a727f35d8d2c2'
569 checkvars['SRC_URI'] = 'https://files.pythonhosted.org/packages/1f/7a/8b94bb016069caa12fc9f587b28080ac33b4fbb8ca369b98bc0a4828543e/typing_extensions-${PV}.tar.gz'
570 checkvars['SRC_URI[md5sum]'] = '74bafe841fbd1c27324afdeb099babdf'
571 checkvars['SRC_URI[sha1sum]'] = 'f8bed69cbad4a57a1a67bf8a31b62b657b47f7a3'
572 checkvars['SRC_URI[sha256sum]'] = 'df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef'
573 checkvars['SRC_URI[sha384sum]'] = '0bd0112234134d965c6884f3c1f95d27b6ae49cfb08108101158e31dff33c2dce729331628b69818850f1acb68f6c8d0'
574 checkvars['SRC_URI[sha512sum]'] = '5fbff10e085fbf3ac2e35d08d913608d8c8bca66903435ede91cdc7776d775689a53d64f5f0615fe687c6c228ac854c8651d99eb1cb96ec61c56b7ca01fdd440'
575 inherits = ['python_flit_core']
576
577 self._test_recipe_contents(recipefile, checkvars, inherits)
578
477 def test_recipetool_create_github_tarball(self): 579 def test_recipetool_create_github_tarball(self):
478 # Basic test to ensure github URL mangling doesn't apply to release tarballs 580 # Basic test to ensure github URL mangling doesn't apply to release tarballs
479 temprecipe = os.path.join(self.tempdir, 'recipe') 581 temprecipe = os.path.join(self.tempdir, 'recipe')