Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions drivers/usb/tests/TESTS/usb_device/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Testing the Mbed OS USB device

## Setup
Before running tests, please make sure to install all the
required Python modules.

```
pip install -r mbed-os/tools/requirements-ci-build.txt
```
> [!NOTE]
> all required Python modules are instaled into the Python virtual enviroment (venv) automatically with first build of Greentea.

Additional, platform-specific setup is described below.
See also [Known issues](#known-issues).
Expand Down
34 changes: 29 additions & 5 deletions tools/cmake/mbed_python_interpreter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if(MBED_CREATE_PYTHON_VENV)
set(VENV_STAMP_FILE ${MBED_VENV_LOCATION}/mbed-venv.stamp)
set(MBED_PYPROJECT_TOML_LOCATION "${MBED_CE_TOOLS_BASE_DIR}/pyproject.toml")

# a separate stamp file to track whether greentea dependencies
set(GT_STAMP_FILE ${MBED_VENV_LOCATION}/mbed-gt.stamp)

# Make it so modifying pyproject.toml will trigger a reconfigure
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${MBED_PYPROJECT_TOML_LOCATION})

Expand Down Expand Up @@ -66,6 +69,11 @@ if(MBED_CREATE_PYTHON_VENV)
set(NEED_TO_INSTALL_PACKAGES TRUE)
endif()

# If greentea tests are being built, we need to ensure greentea dependencies are installed
if(MBED_BUILD_GREENTEA_TESTS AND NOT EXISTS "${GT_STAMP_FILE}")
set(NEED_TO_INSTALL_PACKAGES TRUE)
endif()

if(NEED_TO_CREATE_VENV)
# Create venv.
# Using approach from here: https://discourse.cmake.org/t/possible-to-create-a-python-virtual-env-from-cmake-and-then-find-it-with-findpython3/1132/2
Expand All @@ -92,13 +100,29 @@ if(MBED_CREATE_PYTHON_VENV)
COMMAND ${Python3_EXECUTABLE} -m pip install --upgrade pip
COMMAND_ERROR_IS_FATAL ANY
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -m pip install -e ${MBED_CE_TOOLS_BASE_DIR}
COMMAND_ERROR_IS_FATAL ANY
)

#
if(MBED_BUILD_GREENTEA_TESTS)
# Enable the extra dependencies for the GT
execute_process(
COMMAND ${Python3_EXECUTABLE} -m pip install -e "${MBED_CE_TOOLS_BASE_DIR}[greentea]"
COMMAND_ERROR_IS_FATAL ANY
)
else()
# The dependencies for regular build
execute_process(
COMMAND ${Python3_EXECUTABLE} -m pip install -e "${MBED_CE_TOOLS_BASE_DIR}"
COMMAND_ERROR_IS_FATAL ANY
)
endif()

message(STATUS "Mbed: venv created successfully")
file(TOUCH ${VENV_STAMP_FILE})
if(MBED_BUILD_GREENTEA_TESTS)
# If greentea tests are being built, we need create a greentea stamp file
file(TOUCH ${GT_STAMP_FILE})
endif()

endif()

# When using the venv, scripts will always be installed to the directory where Python itself is installed
Expand Down Expand Up @@ -175,4 +199,4 @@ function(mbed_check_or_install_python_package FOUND_VAR PACKAGE_IMPORT_NAME PACK
message(WARNING "Mbed: ${PACKAGE_IMPORT_NAME} cannot be installed because the Mbed virtualenv is not being used. Please install ${PACKAGE_INSTALL_CONSTRAINT} into Mbed's Python interpeter manually.")
endif()
endif()
endfunction(mbed_check_or_install_python_package)
endfunction(mbed_check_or_install_python_package)
9 changes: 8 additions & 1 deletion tools/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ unit-tests = [
"beautifulsoup4",
"lxml"
]
greentea = [
## Additional requirements to install into the Mbed environment when running Greentea tests
# For USB Device host tests
"hidapi>=0.7.99",
"pyusb>=1.2.0",
"wmi>=1.5; platform_system == 'Windows'",
]

[tool.hatch.build.targets.wheel]
packages = [
Expand All @@ -88,4 +95,4 @@ mbedhtrun = "mbed_host_tests.mbedhtrun:main"
mbedls = "mbed_lstools.main:mbedls_main"
mbed-tools = "mbed_tools.cli.main:cli"
memap = "memap.memap:main"
ambiq_svl = "ambiq_svl.svl:cli"
ambiq_svl = "ambiq_svl.svl:cli"
6 changes: 0 additions & 6 deletions tools/requirements-greentea.txt

This file was deleted.