diff options
Diffstat (limited to 'scripts/lib/recipetool/create_buildsys_python.py')
-rw-r--r-- | scripts/lib/recipetool/create_buildsys_python.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/scripts/lib/recipetool/create_buildsys_python.py b/scripts/lib/recipetool/create_buildsys_python.py index 60c5903450..a589343cfb 100644 --- a/scripts/lib/recipetool/create_buildsys_python.py +++ b/scripts/lib/recipetool/create_buildsys_python.py | |||
@@ -573,12 +573,15 @@ class PythonSetupPyRecipeHandler(PythonRecipeHandler): | |||
573 | if 'buildsystem' in handled: | 573 | if 'buildsystem' in handled: |
574 | return False | 574 | return False |
575 | 575 | ||
576 | logger.debug("Trying setup.py parser") | ||
577 | |||
576 | # Check for non-zero size setup.py files | 578 | # Check for non-zero size setup.py files |
577 | setupfiles = RecipeHandler.checkfiles(srctree, ['setup.py']) | 579 | setupfiles = RecipeHandler.checkfiles(srctree, ['setup.py']) |
578 | for fn in setupfiles: | 580 | for fn in setupfiles: |
579 | if os.path.getsize(fn): | 581 | if os.path.getsize(fn): |
580 | break | 582 | break |
581 | else: | 583 | else: |
584 | logger.debug("No setup.py found") | ||
582 | return False | 585 | return False |
583 | 586 | ||
584 | # setup.py is always parsed to get at certain required information, such as | 587 | # setup.py is always parsed to get at certain required information, such as |
@@ -799,12 +802,15 @@ class PythonPyprojectTomlRecipeHandler(PythonRecipeHandler): | |||
799 | if 'buildsystem' in handled: | 802 | if 'buildsystem' in handled: |
800 | return False | 803 | return False |
801 | 804 | ||
805 | logger.debug("Trying pyproject.toml parser") | ||
806 | |||
802 | # Check for non-zero size setup.py files | 807 | # Check for non-zero size setup.py files |
803 | setupfiles = RecipeHandler.checkfiles(srctree, ["pyproject.toml"]) | 808 | setupfiles = RecipeHandler.checkfiles(srctree, ["pyproject.toml"]) |
804 | for fn in setupfiles: | 809 | for fn in setupfiles: |
805 | if os.path.getsize(fn): | 810 | if os.path.getsize(fn): |
806 | break | 811 | break |
807 | else: | 812 | else: |
813 | logger.debug("No pyproject.toml found") | ||
808 | return False | 814 | return False |
809 | 815 | ||
810 | setupscript = os.path.join(srctree, "pyproject.toml") | 816 | setupscript = os.path.join(srctree, "pyproject.toml") |
@@ -816,14 +822,16 @@ class PythonPyprojectTomlRecipeHandler(PythonRecipeHandler): | |||
816 | try: | 822 | try: |
817 | import tomli as tomllib | 823 | import tomli as tomllib |
818 | except ImportError: | 824 | except ImportError: |
819 | logger.exception("Neither 'tomllib' nor 'tomli' could be imported. Please use python3.11 or above or install tomli module") | 825 | logger.error("Neither 'tomllib' nor 'tomli' could be imported, cannot scan pyproject.toml.") |
820 | return False | ||
821 | except Exception: | ||
822 | logger.exception("Failed to parse pyproject.toml") | ||
823 | return False | 826 | return False |
824 | 827 | ||
825 | with open(setupscript, "rb") as f: | 828 | try: |
826 | config = tomllib.load(f) | 829 | with open(setupscript, "rb") as f: |
830 | config = tomllib.load(f) | ||
831 | except Exception: | ||
832 | logger.exception("Failed to parse pyproject.toml") | ||
833 | return False | ||
834 | |||
827 | build_backend = config["build-system"]["build-backend"] | 835 | build_backend = config["build-system"]["build-backend"] |
828 | if build_backend in self.build_backend_map: | 836 | if build_backend in self.build_backend_map: |
829 | classes.append(self.build_backend_map[build_backend]) | 837 | classes.append(self.build_backend_map[build_backend]) |