python3-pydantic: Enable test_docs.py

We now have Rust 1.71+ version in oe-core so we can build ruff,
add it to the ptest runtime dependencies, install docs and fix
paths in test_docs.py.

There is a known jemallocator issue on aarch64 that affects ruff
and some of the pydantic tests from test_docs.py:

E           <jemalloc>: Unsupported system page size                                                                                                       E           memory allocation of 4 bytes failed

More details about JEMALLOC_SYS_WITH_LG_PAGE:
https://github.com/gnzlbg/jemallocator/issues/170#issuecomment-1503228963

This work was sponsored by GOVCERT.LU.

Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Leon Anavi
2026-07-28 14:45:32 +03:00
committed by Khem Raj
parent 97dc08e351
commit ff28575a46
@@ -58,13 +58,24 @@ RDEPENDS:${PN}-ptest += "\
python3-rich \
python3-sqlalchemy \
python3-unixadmin \
python3-ruff \
python3-pytest-examples \
python3-devtools \
${PN}-doc \
"
do_install:append() {
install -d ${D}${docdir}/${PN}/
cp -rf ${S}/docs/* ${D}${docdir}/${PN}/
}
do_install_ptest:append() {
cp -rf ${S}/tests/ ${D}${PTEST_PATH}/
# Requires 'ruff' (python3-ruff) which we cannot build
# until we have Rust 1.71+ in oe-core
rm -f ${D}${PTEST_PATH}/tests/test_docs.py
# Fix paths in test_docs.py
sed -i \
-e "s|^DOCS_ROOT = Path(__file__).parent.parent / 'docs'|DOCS_ROOT = Path('${docdir}/${PN}')|" \
-e "s|^SOURCES_ROOT = Path(__file__).parent.parent / 'pydantic'|SOURCES_ROOT = Path('${PYTHON_SITEPACKAGES_DIR}/pydantic')|" \
${D}${PTEST_PATH}/tests/test_docs.py
# We are not trying to support mypy
rm -f ${D}${PTEST_PATH}/tests/test_mypy.py
# We are not trying to run benchmarks
@@ -72,4 +83,6 @@ do_install_ptest:append() {
sed -i -e "/--automake/ s/$/ -k 'not test_config_validation_error_cause and not test_dataclass_config_validate_default and not test_annotated_validator_nested and not test_use_bare and not test_use_no_fields and not test_validator_bad_fields_throws_configerror and not test_assert_raises_validation_error and not test_model_config_validate_default and not test_readonly_qualifier_warning'/" ${D}${PTEST_PATH}/run-ptest
}
FILES:${PN}-doc += "${docdir}/${PN}"
BBCLASSEXTEND = "native nativesdk"