Skip to content

Commit 61dd4d0

Browse files
authored
[python] Split Python wheel in two separate wheels (#20054)
* 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
1 parent aa2f050 commit 61dd4d0

16 files changed

+259
-151
lines changed

.github/workflows/build.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ jobs:
316316
- name: Run Python library specific unit tests
317317
timeout-minutes: 5
318318
run: |
319-
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip-0.0-cp37-abi3-linux_x86_64.whl'
319+
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_core-0.0-cp37-abi3-linux_x86_64.whl'
320+
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_clusters-0.0-py3-none-any.whl'
321+
scripts/run_in_build_env.sh 'pip3 install ./out/controller/python/chip_repl-0.0-py3-none-any.whl'
320322
scripts/run_in_build_env.sh '(cd src/controller/python/test/unit_tests/ && python3 -m unittest -v)'
321323
322324
build_darwin:

BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
140140
if (enable_pylib) {
141141
deps += [ "${chip_root}/src/pybindings/pycontroller" ]
142142
}
143-
deps += [ "${chip_root}/src/controller/python" ]
143+
deps += [ "${chip_root}/src/controller/python:chip-repl" ]
144144
}
145145
}
146146

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

172172
write_runtime_deps = "${root_out_dir}/certification.runtime_deps"

scripts/build/builders/host.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
278278
elif app == HostApp.PYTHON_BINDINGS:
279279
self.extra_gn_options.append('enable_rtti=false')
280280
self.extra_gn_options.append('chip_project_config_include_dirs=["//config/python"]')
281-
self.build_command = 'python'
281+
self.build_command = 'chip-repl'
282282

283283
def GnBuildArgs(self):
284284
if self.board == HostBoard.NATIVE:

scripts/build/testdata/build_linux_on_x64.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ ninja -C {out}/linux-arm64-ota-requestor
374374
ninja -C {out}/linux-arm64-ota-requestor-ipv6only
375375

376376
# Building linux-arm64-python-bindings
377-
ninja -C {out}/linux-arm64-python-bindings python
377+
ninja -C {out}/linux-arm64-python-bindings chip-repl
378378

379379
# Building linux-arm64-shell
380380
ninja -C {out}/linux-arm64-shell
@@ -491,7 +491,7 @@ ninja -C {out}/linux-x64-ota-requestor
491491
ninja -C {out}/linux-x64-ota-requestor-ipv6only
492492

493493
# Building linux-x64-python-bindings
494-
ninja -C {out}/linux-x64-python-bindings python
494+
ninja -C {out}/linux-x64-python-bindings chip-repl
495495

496496
# Building linux-x64-rpc-console
497497
ninja -C {out}/linux-x64-rpc-console

scripts/build_python.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ gn --root="$CHIP_ROOT" gen "$OUTPUT_ROOT" --args="chip_detail_logging=$chip_deta
120120
if [ "$enable_pybindings" == true ]; then
121121
ninja -C "$OUTPUT_ROOT" pycontroller
122122
else
123-
ninja -C "$OUTPUT_ROOT" python
123+
ninja -C "$OUTPUT_ROOT" chip-repl
124124
fi
125125

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

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

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

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

151151
echo ""
152152
echo_green "Compilation completed and WHL package installed in virtualenv for building sdk"

scripts/build_python_device.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ gn --root="$CHIP_ROOT" gen "$OUTPUT_ROOT" --args="chip_detail_logging=$chip_deta
104104
if [ "$enable_pybindings" == true ]; then
105105
ninja -v -C "$OUTPUT_ROOT" pycontroller
106106
else
107-
ninja -v -C "$OUTPUT_ROOT" python
107+
ninja -v -C "$OUTPUT_ROOT" chip-library
108108
fi
109109

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

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

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

125125
echo ""
126126
echo_green "Compilation completed and WHL package installed in: "

0 commit comments

Comments
 (0)