Skip to content

Commit

Permalink
Make build_python.sh automatically install run_python_test.py require…
Browse files Browse the repository at this point in the history
…ments (#27510)

* Add a python unit test requirement file

* Update build_python to install test dependencies by default

* Restyle

* Add diskcache as a requirement for yaml tests

* Add websockets as well since python yaml tests need it and I expect python tests to want both

* lark/jinja2 wheel requirements do not seem to take effect. Add  them

* Add stringcase dependency
  • Loading branch information
andy31415 authored and pull[bot] committed Dec 5, 2023
1 parent a55d84e commit 4406424
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ jobs:
- name: Build Apps
run: |
scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv --include_yamltests'
scripts/run_in_python_env.sh out/venv 'pip install -r scripts/setup/requirements.build.txt'
scripts/run_in_python_env.sh out/venv 'pip install -r scripts/setup/requirements.yaml_tests.txt'
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT} \
Expand Down Expand Up @@ -424,8 +422,6 @@ jobs:
- name: Build Python REPL and example apps
run: |
scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv --extra_packages "mobly"'
scripts/run_in_python_env.sh out/venv 'pip install -r scripts/setup/requirements.build.txt'
scripts/run_in_python_env.sh out/venv 'pip install colorama pyasn1 pyasn1_modules'
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test \
Expand Down Expand Up @@ -499,8 +495,6 @@ jobs:
- name: Build Python REPL and example apps
run: |
scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv'
scripts/run_in_python_env.sh out/venv 'pip install -r scripts/setup/requirements.build.txt'
scripts/run_in_python_env.sh out/venv 'pip install colorama'
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target darwin-x64-all-clusters-${BUILD_VARIANT}-test \
Expand Down
16 changes: 16 additions & 0 deletions scripts/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ declare chip_mdns
declare case_retry_delta
declare install_virtual_env
declare clean_virtual_env=yes
declare install_pytest_requirements=yes

help() {

Expand All @@ -63,6 +64,8 @@ Input Options:
<path> represents where the virtual environment is to be created.
-c, --clean_virtual_env <yes|no> When installing a virtual environment, create/clean it first.
Defaults to yes.
--include_pytest_deps <yes|no> Install requirements.python_tests.txt.
Defaults to yes.
--extra_packages PACKAGES Install extra Python packages from PyPI
--include_yamltests Whether to install the matter_yamltests wheel.
-z --pregen_dir DIRECTORY Directory where generated zap files have been pre-generated.
Expand Down Expand Up @@ -101,6 +104,10 @@ while (($#)); do
clean_virtual_env=$2
shift
;;
--include_pytest_deps)
install_pytest_requirements=$2
shift
;;
--extra_packages)
extra_packages=$2
shift
Expand Down Expand Up @@ -178,13 +185,22 @@ if [ -n "$install_virtual_env" ]; then

if [ "$clean_virtual_env" = "yes" ]; then
# Create a virtual environment that has access to the built python tools
echo_blue "Creating a clear VirtualEnv in '$ENVIRONMENT_ROOT' ..."
virtualenv --clear "$ENVIRONMENT_ROOT"
elif [ ! -f "$ENVIRONMENT_ROOT"/bin/activate ]; then
echo_blue "Creating a new VirtualEnv in '$ENVIRONMENT_ROOT' ..."
virtualenv "$ENVIRONMENT_ROOT"
fi

source "$ENVIRONMENT_ROOT"/bin/activate
"$ENVIRONMENT_ROOT"/bin/python -m pip install --upgrade pip
"$ENVIRONMENT_ROOT"/bin/pip install --upgrade "${WHEEL[@]}"

if [ "$install_pytest_requirements" = "yes" ]; then
echo_blue "Installing python test dependencies ..."
"$ENVIRONMENT_ROOT"/bin/pip install -r "$CHIP_ROOT/scripts/setup/requirements.python_tests.txt"
fi

echo ""
echo_green "Compilation completed and WHL package installed in: "
echo_blue " $ENVIRONMENT_ROOT"
Expand Down
16 changes: 16 additions & 0 deletions scripts/setup/requirements.python_tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# scripts/tests
click
colorama
diskcache
websockets

# scripts/py_matter_idl
# TODO: these should be wheel dependencies
lark
jinja2
stringcase

# src/python_testing
mobly
pyasn1
pyasn1_modules

0 comments on commit 4406424

Please sign in to comment.