Bug 15393 - recipetool has poor python recipe failure mode
Summary: recipetool has poor python recipe failure mode
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: Scripts and Tools (show other bugs)
Version: 0.0.0
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 5.0 M3
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2024-02-09 09:36 UTC by Richard Purdie
Modified: 2024-04-11 14:55 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Purdie 2024-02-09 09:36:34 UTC
If tomllib doesn't exist and you run:

recipetool create -o /tmp https://github.com/mesonbuild/meson;rev=1.3.1

NOTE: Tasks Summary: Attempted 3 tasks of which 0 didn't need to be rerun and all succeeded.
ERROR: Neither 'tomllib' nor 'tomli' could be imported. Please use python3.11 or above or install tomli module
Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/scripts/lib/recipetool/create_buildsys_python.py", line 814, in process
    import tomllib
ModuleNotFoundError: No module named 'tomllib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-ubuntu/build/scripts/lib/recipetool/create_buildsys_python.py", line 817, in process
    import tomli as tomllib
ModuleNotFoundError: No module named 'tomli'
INFO: Scanning paths for packages & dependencies: .
INFO: Please add the following line for 'docs/markdown/legal.md' to a 'lib/recipetool/licenses.csv' and replace `Unknown` with the license:
000fe0dead3c0d575839e9d2bcfe2d5e,Unknown
INFO: Please add the following line for 'packaging/License.rtf' to a 'lib/recipetool/licenses.csv' and replace `Unknown` with the license:
074ef868ead2735d006e564c24e059c7,Unknown
INFO: Recipe /tmp/python3-meson_git.bb has been created; further editing may be required to make it fully functional

It fails, fine, but it says it did create a recipe when the file doesn't exist and exit code is zero.

We should fail if a file isn't written and not say one was when it was not.
Comment 1 Adrian 2024-02-09 11:20:40 UTC
The related oe-selftest failure came in with 5206056589ca6b0671b0009393f526828e2c665a.
I can confirm that this commit was tested on a host where import tomllib in Python works.

Improving recipetool so that it exits with a correct error code should be done, I agree.

But that will not fix the error of the oe-selftest on the AB. The selftest checks if the bb file has been created. But this is not the case if recipetool has no tomllib or tomli available.

I see different possible solutions:
- Make tomllib a host dependency and fix the AB by installing this Python package
- Keep tomllib optional and let recipe tool ask the user for installing it when it is required. If this is the preferred solution, I need to improve the two test cases.
Comment 2 Adrian 2024-02-09 12:10:38 UTC
Just saw the patches from RP on master-next. Looks like this problem is already solved. Thank you.
Comment 3 Ross Burton 2024-02-09 15:41:47 UTC
I've sent a patch to clean up the horrible exception dumping.
Comment 4 Adrian 2024-02-12 07:46:38 UTC
Tested master-next with Python 3.12 on Fedora 39 again. Looks good! Thank you.
Comment 5 Ross Burton 2024-04-11 14:55:25 UTC
Fixed in 1a3ba4c312844d80ae382912b319e60ad8b30737.