From 140ec4858165dda5ae8315eaa318028582a29154 Mon Sep 17 00:00:00 2001 From: Vatsal Ghelani <152916324+vatsalghelani-csa@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:08:55 -0400 Subject: [PATCH] Fix metadata_parser python module to make it wheel buildable. (#34322) * Fix the metadata module to make the wheel buildable * Added the fix for metadata import * Added fixes as per module build for metadata_testing_infrastructure * Restyled by shfmt * Make CI checks run * Update build_python.sh * Delete admin_storage.json * Make metadata_parser python module wheel buildable within src/python_testing/matter_testing_infrastructure/ (#1) * Adding metadata buildable wheel to src/python_testing/matter_testing_infrastructure * Update build_python.sh * Delete src/python_testing/matter_testing_infrastructure/build/lib/metadata_parser directory --------- Co-authored-by: Restyled.io --- BUILD.gn | 4 +++- scripts/build_python.sh | 3 +++ scripts/tests/run_python_test.py | 2 +- .../python_testing/matter_testing_infrastructure}/BUILD.gn | 6 +++--- .../matter_testing_infrastructure}/env_test.yaml | 0 .../metadata_parser}/__init__.py | 0 .../metadata_parser}/metadata.py | 0 .../metadata_parser}/test_metadata.py | 0 .../matter_testing_infrastructure}/pyproject.toml | 0 .../python_testing/matter_testing_infrastructure}/setup.cfg | 2 +- .../python_testing/matter_testing_infrastructure}/setup.py | 0 11 files changed, 11 insertions(+), 6 deletions(-) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure}/BUILD.gn (88%) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure}/env_test.yaml (100%) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure/metadata_parser}/__init__.py (100%) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure/metadata_parser}/metadata.py (100%) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure/metadata_parser}/test_metadata.py (100%) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure}/pyproject.toml (100%) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure}/setup.cfg (95%) rename {scripts/tests/py => src/python_testing/matter_testing_infrastructure}/setup.py (100%) diff --git a/BUILD.gn b/BUILD.gn index ecf710efdf8a15..4d76100fbe6d20 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -67,6 +67,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { "//examples/common/pigweed/rpc_console/py:chip_rpc", "//integrations/mobly:chip_mobly", "//scripts/py_matter_yamltests:matter_yamltests", + "//src/python_testing/matter_testing_infrastructure:metadata_parser", ] pw_python_venv("matter_build_venv") { @@ -107,6 +108,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { deps = [ "${chip_root}/scripts:matter_yamltests_distribution.wheel", "${chip_root}/src/controller/python:chip-repl", + "${chip_root}/src/python_testing/matter_testing_infrastructure:metadata_parser.wheel", ] if (enable_pylib) { deps += [ "${chip_root}/src/pybindings/pycontroller" ] @@ -234,8 +236,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { "//scripts/build:build_examples.tests", "//scripts/py_matter_idl:matter_idl.tests", "//scripts/py_matter_yamltests:matter_yamltests.tests", - "//scripts/tests/py:metadata_parser.tests", "//src:tests_run", + "//src/python_testing/matter_testing_infrastructure:metadata_parser.tests", ] if (current_os == "linux" || current_os == "mac") { diff --git a/scripts/build_python.sh b/scripts/build_python.sh index a946bb1b8f518b..e70b220130935d 100755 --- a/scripts/build_python.sh +++ b/scripts/build_python.sh @@ -212,6 +212,9 @@ else WHEEL=("$OUTPUT_ROOT"/controller/python/chip*.whl) fi +# Add the matter_testing_infrastructure wheel +WHEEL+=("$OUTPUT_ROOT"/python/obj/src/python_testing/matter_testing_infrastructure/metadata_parser._build_wheel/metadata_parser-*.whl) + if [ -n "$extra_packages" ]; then WHEEL+=("$extra_packages") fi diff --git a/scripts/tests/run_python_test.py b/scripts/tests/run_python_test.py index 91ee73e00d0e8d..61ec274bfc1c64 100755 --- a/scripts/tests/run_python_test.py +++ b/scripts/tests/run_python_test.py @@ -32,7 +32,7 @@ import click import coloredlogs from colorama import Fore, Style -from py.metadata import Metadata, MetadataReader +from metadata_parser.metadata import Metadata, MetadataReader DEFAULT_CHIP_ROOT = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..')) diff --git a/scripts/tests/py/BUILD.gn b/src/python_testing/matter_testing_infrastructure/BUILD.gn similarity index 88% rename from scripts/tests/py/BUILD.gn rename to src/python_testing/matter_testing_infrastructure/BUILD.gn index e77297ac4e0955..f972040a3e64b5 100644 --- a/scripts/tests/py/BUILD.gn +++ b/src/python_testing/matter_testing_infrastructure/BUILD.gn @@ -28,9 +28,9 @@ pw_python_package("metadata_parser") { inputs = [ "env_test.yaml" ] sources = [ - "__init__.py", - "metadata.py", + "metadata_parser/__init__.py", + "metadata_parser/metadata.py", ] - tests = [ "test_metadata.py" ] + tests = [ "metadata_parser/test_metadata.py" ] } diff --git a/scripts/tests/py/env_test.yaml b/src/python_testing/matter_testing_infrastructure/env_test.yaml similarity index 100% rename from scripts/tests/py/env_test.yaml rename to src/python_testing/matter_testing_infrastructure/env_test.yaml diff --git a/scripts/tests/py/__init__.py b/src/python_testing/matter_testing_infrastructure/metadata_parser/__init__.py similarity index 100% rename from scripts/tests/py/__init__.py rename to src/python_testing/matter_testing_infrastructure/metadata_parser/__init__.py diff --git a/scripts/tests/py/metadata.py b/src/python_testing/matter_testing_infrastructure/metadata_parser/metadata.py similarity index 100% rename from scripts/tests/py/metadata.py rename to src/python_testing/matter_testing_infrastructure/metadata_parser/metadata.py diff --git a/scripts/tests/py/test_metadata.py b/src/python_testing/matter_testing_infrastructure/metadata_parser/test_metadata.py similarity index 100% rename from scripts/tests/py/test_metadata.py rename to src/python_testing/matter_testing_infrastructure/metadata_parser/test_metadata.py diff --git a/scripts/tests/py/pyproject.toml b/src/python_testing/matter_testing_infrastructure/pyproject.toml similarity index 100% rename from scripts/tests/py/pyproject.toml rename to src/python_testing/matter_testing_infrastructure/pyproject.toml diff --git a/scripts/tests/py/setup.cfg b/src/python_testing/matter_testing_infrastructure/setup.cfg similarity index 95% rename from scripts/tests/py/setup.cfg rename to src/python_testing/matter_testing_infrastructure/setup.cfg index 464e36c03d3e2f..d1cbadff10880c 100644 --- a/scripts/tests/py/setup.cfg +++ b/src/python_testing/matter_testing_infrastructure/setup.cfg @@ -16,4 +16,4 @@ name = metadata_parser version = 0.0.1 author = Project CHIP Authors -description = Scripts to get metadata (runner arguments) associated with the python_testing scripts +description = Scripts to get metadata (runner arguments) associated with the python_testing scripts \ No newline at end of file diff --git a/scripts/tests/py/setup.py b/src/python_testing/matter_testing_infrastructure/setup.py similarity index 100% rename from scripts/tests/py/setup.py rename to src/python_testing/matter_testing_infrastructure/setup.py