Skip to content

Commit

Permalink
[python] Split Python wheel in two separate wheels (#20054)
Browse files Browse the repository at this point in the history
* Move package information into manifest file

* Specify scripts in manifest as well

* Make build-chip-wheel.py independent of build variant

Pass library name via command line arguments. This makes
build-chip-wheel.py more generic.

* Move package requirements to manifest file as well

* Split Python into library and repl package

* Introduce common GN template chip_python_wheel_action

* Add runtime dependency between chip-repl and chip-library

* Split chip-library into chip-core and chip-clusters

* Apply restyled

* Install all wheels for unit tests

* Use new chip-repl build target

* Fix Cirque failures

* Fix wheel names for chip_clusters/chip_repl
  • Loading branch information
agners authored and web-flow committed Jul 13, 2022
1 parent 0390a8d commit c5f1670
Show file tree
Hide file tree
Showing 16 changed files with 259 additions and 151 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ jobs:
- name: Run Python library specific unit tests
timeout-minutes: 5
run: |
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip-0.0-cp37-abi3-linux_x86_64.whl'
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_core-0.0-cp37-abi3-linux_x86_64.whl'
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_clusters-0.0-py3-none-any.whl'
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_repl-0.0-py3-none-any.whl'
scripts/run_in_build_env.sh '(cd src/controller/python/test/unit_tests/ && python3 -m unittest -v)'
build_darwin:
Expand Down
4 changes: 2 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
if (enable_pylib) {
deps += [ "${chip_root}/src/pybindings/pycontroller" ]
}
deps += [ "${chip_root}/src/controller/python" ]
deps += [ "${chip_root}/src/controller/python:chip-repl" ]
}
}

Expand All @@ -166,7 +166,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
if (enable_pylib) {
data_deps += [ "${chip_root}/src/pybindings/pycontroller" ]
}
data_deps += [ "${chip_root}/src/controller/python" ]
data_deps += [ "${chip_root}/src/controller/python:chip-repl" ]
}

write_runtime_deps = "${root_out_dir}/certification.runtime_deps"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
elif app == HostApp.PYTHON_BINDINGS:
self.extra_gn_options.append('enable_rtti=false')
self.extra_gn_options.append('chip_project_config_include_dirs=["//config/python"]')
self.build_command = 'python'
self.build_command = 'chip-repl'

def GnBuildArgs(self):
if self.board == HostBoard.NATIVE:
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/testdata/build_linux_on_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ ninja -C {out}/linux-arm64-ota-requestor
ninja -C {out}/linux-arm64-ota-requestor-ipv6only

# Building linux-arm64-python-bindings
ninja -C {out}/linux-arm64-python-bindings python
ninja -C {out}/linux-arm64-python-bindings chip-repl

# Building linux-arm64-shell
ninja -C {out}/linux-arm64-shell
Expand Down Expand Up @@ -491,7 +491,7 @@ ninja -C {out}/linux-x64-ota-requestor
ninja -C {out}/linux-x64-ota-requestor-ipv6only

# Building linux-x64-python-bindings
ninja -C {out}/linux-x64-python-bindings python
ninja -C {out}/linux-x64-python-bindings chip-repl

# Building linux-x64-rpc-console
ninja -C {out}/linux-x64-rpc-console
Expand Down
10 changes: 5 additions & 5 deletions scripts/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ gn --root="$CHIP_ROOT" gen "$OUTPUT_ROOT" --args="chip_detail_logging=$chip_deta
if [ "$enable_pybindings" == true ]; then
ninja -C "$OUTPUT_ROOT" pycontroller
else
ninja -C "$OUTPUT_ROOT" python
ninja -C "$OUTPUT_ROOT" chip-repl
fi

if [ "$enable_pybindings" == true ]; then
WHEEL=$(ls "$OUTPUT_ROOT"/pybindings/pycontroller/pychip-*.whl | head -n 1)
WHEEL=("$OUTPUT_ROOT"/pybindings/pycontroller/pychip-*.whl)
else
WHEEL=$(ls "$OUTPUT_ROOT"/controller/python/chip-*.whl | head -n 1)
WHEEL=("$OUTPUT_ROOT"/controller/python/chip*.whl)
fi

if [ "$install_wheel" = "no" ]; then
Expand All @@ -137,7 +137,7 @@ elif [ "$install_wheel" = "separate" ]; then

source "$ENVIRONMENT_ROOT"/bin/activate
"$ENVIRONMENT_ROOT"/bin/python -m pip install --upgrade pip
"$ENVIRONMENT_ROOT"/bin/pip install --upgrade --force-reinstall --no-cache-dir "$WHEEL"
"$ENVIRONMENT_ROOT"/bin/pip install --upgrade --force-reinstall --no-cache-dir "${WHEEL[@]}"

echo ""
echo_green "Compilation completed and WHL package installed in: "
Expand All @@ -146,7 +146,7 @@ elif [ "$install_wheel" = "separate" ]; then
echo_green "To use please run:"
echo_bold_white " source $ENVIRONMENT_ROOT/bin/activate"
elif [ "$install_wheel" = "build-env" ]; then
pip install --force-reinstall "$WHEEL"
pip install --force-reinstall "${WHEEL[@]}"

echo ""
echo_green "Compilation completed and WHL package installed in virtualenv for building sdk"
Expand Down
8 changes: 4 additions & 4 deletions scripts/build_python_device.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ gn --root="$CHIP_ROOT" gen "$OUTPUT_ROOT" --args="chip_detail_logging=$chip_deta
if [ "$enable_pybindings" == true ]; then
ninja -v -C "$OUTPUT_ROOT" pycontroller
else
ninja -v -C "$OUTPUT_ROOT" python
ninja -v -C "$OUTPUT_ROOT" chip-library
fi

# Create a virtual environment that has access to the built python tools
Expand All @@ -113,14 +113,14 @@ virtualenv --clear "$ENVIRONMENT_ROOT"
# Activate the new environment to register the python WHL

if [ "$enable_pybindings" == true ]; then
WHEEL=$(ls "$OUTPUT_ROOT"/pybindings/pycontroller/pychip-*.whl | head -n 1)
WHEEL=("$OUTPUT_ROOT"/pybindings/pycontroller/pychip-*.whl)
else
WHEEL=$(ls "$OUTPUT_ROOT"/controller/python/chip-*.whl | head -n 1)
WHEEL=("$OUTPUT_ROOT"/controller/python/chip_library*.whl)
fi

source "$ENVIRONMENT_ROOT"/bin/activate
"$ENVIRONMENT_ROOT"/bin/python -m pip install --upgrade pip
"$ENVIRONMENT_ROOT"/bin/pip install --upgrade --force-reinstall --no-cache-dir "$WHEEL"
"$ENVIRONMENT_ROOT"/bin/pip install --upgrade --force-reinstall --no-cache-dir "${WHEEL[@]}"

echo ""
echo_green "Compilation completed and WHL package installed in: "
Expand Down
Loading

0 comments on commit c5f1670

Please sign in to comment.