diff --git a/BUILD.gn b/BUILD.gn index 298e5bf7c8e83d..7cba95d7944d3f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -132,6 +132,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { deps = [ "${chip_root}/scripts:matter_yamltests_distribution.wheel", "${chip_root}/scripts/py_matter_yamltests:matter-yamltests.wheel", + "${chip_root}/src/controller/python:matter-core-module.wheel", "${chip_root}/src/controller/python:matter-repl", "${chip_root}/src/python_testing/matter_testing_infrastructure:matter-testing.wheel", "${chip_root}/src/python_testing/post_certification_tests:matter-post-certification-tests.wheel", diff --git a/build/chip/python_wheel.gni b/build/chip/python_wheel.gni index a41aff0a953a63..02ba2437cc7e6c 100644 --- a/build/chip/python_wheel.gni +++ b/build/chip/python_wheel.gni @@ -19,7 +19,7 @@ import("$dir_pw_build/python.gni") import("${chip_root}/src/system/system.gni") declare_args() { - chip_python_version = "1.0.0" + chip_python_version = "1.5.0" chip_python_package_prefix = "matter" chip_python_supports_stack_locking = chip_system_config_locking != "none" } diff --git a/scripts/BUILD.gn b/scripts/BUILD.gn index 5b56d0c60c6e28..6c7226a8896301 100644 --- a/scripts/BUILD.gn +++ b/scripts/BUILD.gn @@ -18,6 +18,8 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") import("$dir_pw_build/python_dist.gni") +import("${chip_root}/src/controller/flags.gni") + # This target creates a single Python package and wheel for yamltests. It will # merge all Python dependencies Matter. The output is located in: # out/obj/scripts/matter_yamltests_distribution/ <- source files here @@ -31,3 +33,61 @@ pw_python_distribution("matter_yamltests_distribution") { append_date_to_version = true } } + +pw_python_distribution("matter_iot") { + packages = [ + "${chip_root}/scripts/py_matter_yamltests:matter-yamltests", + "${chip_root}/scripts/py_matter_idl:matter-idl", + "${chip_root}/src/python_testing/matter_testing_infrastructure:matter-testing-module", + "${chip_root}/src/controller/python:matter-core-module", + "${chip_root}/src/controller/python:matter-clusters-module", + "${chip_root}/src/controller/python:matter-repl-module", + ] + + generate_setup_cfg = { + name = "matter_iot" + version = "1.5.0.dev1" + include_default_pyproject_file = true + include_extra_files_in_package_data = true + metadata = { + description = "Matter IoT python development controller and test package" + url = "https://github.com/project-chip/connectedhomeip" + classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + ] + } + } + + if (chip_support_commissioning_in_controller) { + lib_name = "_ChipDeviceCtrl.so" + } else { + lib_name = "_ChipServer.so" + } + + public_deps = [ "${chip_root}/src/controller/python:ChipDeviceCtrl" ] + public_deps += [ + "${chip_root}/src/python_testing/matter_testing_infrastructure:data_model_zip_1_2", + "${chip_root}/src/python_testing/matter_testing_infrastructure:data_model_zip_1_3", + "${chip_root}/src/python_testing/matter_testing_infrastructure:data_model_zip_1_4", + "${chip_root}/src/python_testing/matter_testing_infrastructure:data_model_zip_1_4_1", + "${chip_root}/src/python_testing/matter_testing_infrastructure:data_model_zip_1_4_2", + "${chip_root}/src/python_testing/matter_testing_infrastructure:data_model_zip_1_5", + ] + + extra_files = [ + "${root_out_dir}/data_model/zip_1_2.zip > matter/testing/data_model/1.2/allfiles.zip", + "${root_out_dir}/data_model/zip_1_3.zip > matter/testing/data_model/1.3/allfiles.zip", + "${root_out_dir}/data_model/zip_1_4.zip > matter/testing/data_model/1.4/allfiles.zip", + "${root_out_dir}/data_model/zip_1_4_1.zip > matter/testing/data_model/1.4.1/allfiles.zip", + "${root_out_dir}/data_model/zip_1_4_2.zip > matter/testing/data_model/1.4.2/allfiles.zip", + "${root_out_dir}/data_model/zip_1_5.zip > matter/testing/data_model/1.5/allfiles.zip", + "${root_out_dir}/obj/src/controller/python/matter/${lib_name} > matter/${lib_name}", + ] +} + +pw_python_wheels("python_wheel_dist") { + packages = [ ":matter_iot" ] + directory = "$root_out_dir/dist" +} diff --git a/scripts/build_python.sh b/scripts/build_python.sh index 1d39c2e6a14a0b..a97e65e66f40f3 100755 --- a/scripts/build_python.sh +++ b/scripts/build_python.sh @@ -327,6 +327,7 @@ fi # Compile Python wheels ninja -C "$output_root" python_wheels +ninja -C "$output_root" python_wheel_dist # Add wheels from matter_python_wheel_action templates. WHEEL=("$output_root"/controller/python/matter*.whl) diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn index 76de66311996a1..901532e8821fac 100644 --- a/src/controller/python/BUILD.gn +++ b/src/controller/python/BUILD.gn @@ -201,90 +201,105 @@ shared_library("ChipDeviceCtrl") { configs += [ ":controller_wno_deprecate" ] } +core_sources = [ + "matter/CertificateAuthority.py", + "matter/ChipBleBase.py", + "matter/ChipBleUtility.py", + "matter/ChipBluezMgr.py", + "matter/ChipCommissionableNodeCtrl.py", + "matter/ChipStack.py", + "matter/FabricAdmin.py", + "matter/MatterTlvJson.py", + "matter/__init__.py", + "matter/bdx/Bdx.py", + "matter/bdx/BdxProtocol.py", + "matter/bdx/BdxTransfer.py", + "matter/bdx/__init__.py", + "matter/ble/__init__.py", + "matter/ble/commissioning/__init__.py", + "matter/ble/get_adapters.py", + "matter/ble/library_handle.py", + "matter/ble/scan_devices.py", + "matter/ble/types.py", + "matter/clusters/Attribute.py", + "matter/clusters/Command.py", + "matter/clusters/__init__.py", + "matter/commissioning/__init__.py", + "matter/commissioning/commissioning_flow_blocks.py", + "matter/commissioning/pase.py", + "matter/configuration/__init__.py", + "matter/credentials/__init__.py", + "matter/credentials/cert.py", + "matter/crypto/__init__.py", + "matter/crypto/fabric.py", + "matter/crypto/p256keypair.py", + "matter/discovery/__init__.py", + "matter/discovery/library_handle.py", + "matter/discovery/types.py", + "matter/exceptions/__init__.py", + "matter/fault_injection/__init__.py", + "matter/interaction_model/__init__.py", + "matter/interaction_model/delegate.py", + "matter/internal/__init__.py", + "matter/internal/commissioner.py", + "matter/internal/thread.py", + "matter/internal/types.py", + "matter/logging/__init__.py", + "matter/logging/library_handle.py", + "matter/logging/types.py", + "matter/native/__init__.py", + "matter/setup_payload/__init__.py", + "matter/setup_payload/setup_payload.py", + "matter/storage/__init__.py", + "matter/tracing/__init__.py", + "matter/utils/CommissioningBuildingBlocks.py", + "matter/utils/__init__.py", + "matter/yaml/__init__.py", + "matter/yaml/data_model_lookup.py", + "matter/yaml/errors.py", + "matter/yaml/format_converter.py", + "matter/yaml/runner.py", +] +if (chip_support_webrtc_python_bindings) { + core_sources += [ + "matter/webrtc/__init__.py", + "matter/webrtc/async_websocket_client.py", + "matter/webrtc/browser_peer_connection.py", + "matter/webrtc/browser_webrtc_client.py", + "matter/webrtc/command.py", + "matter/webrtc/libdatachannel_peer_connection.py", + "matter/webrtc/libdatachannel_webrtc_client.py", + "matter/webrtc/library_handle.py", + "matter/webrtc/types.py", + "matter/webrtc/utils.py", + "matter/webrtc/webrtc_manager.py", + ] +} + +if (chip_support_commissioning_in_controller) { + core_sources += [ "matter/ChipDeviceCtrl.py" ] +} else { + core_sources += [ "matter/server/__init__.py" ] +} + +core_py_package_reqs = [ + "coloredlogs", + "construct", + "cryptography", + "dacite", + "deprecation", + "ecdsa", + "ipdb", + "matter-clusters", + "pyyaml", + "rich", +] + matter_python_wheel_action("matter-core") { py_manifest_files = [ { src_dir = "." - sources = [ - "matter/CertificateAuthority.py", - "matter/ChipBleBase.py", - "matter/ChipBleUtility.py", - "matter/ChipBluezMgr.py", - "matter/ChipCommissionableNodeCtrl.py", - "matter/ChipStack.py", - "matter/FabricAdmin.py", - "matter/MatterTlvJson.py", - "matter/__init__.py", - "matter/bdx/Bdx.py", - "matter/bdx/BdxProtocol.py", - "matter/bdx/BdxTransfer.py", - "matter/bdx/__init__.py", - "matter/ble/__init__.py", - "matter/ble/commissioning/__init__.py", - "matter/ble/get_adapters.py", - "matter/ble/library_handle.py", - "matter/ble/scan_devices.py", - "matter/ble/types.py", - "matter/clusters/Attribute.py", - "matter/clusters/Command.py", - "matter/clusters/__init__.py", - "matter/commissioning/__init__.py", - "matter/commissioning/commissioning_flow_blocks.py", - "matter/commissioning/pase.py", - "matter/configuration/__init__.py", - "matter/credentials/__init__.py", - "matter/credentials/cert.py", - "matter/crypto/__init__.py", - "matter/crypto/fabric.py", - "matter/crypto/p256keypair.py", - "matter/discovery/__init__.py", - "matter/discovery/library_handle.py", - "matter/discovery/types.py", - "matter/exceptions/__init__.py", - "matter/fault_injection/__init__.py", - "matter/interaction_model/__init__.py", - "matter/interaction_model/delegate.py", - "matter/internal/__init__.py", - "matter/internal/commissioner.py", - "matter/internal/thread.py", - "matter/internal/types.py", - "matter/logging/__init__.py", - "matter/logging/library_handle.py", - "matter/logging/types.py", - "matter/native/__init__.py", - "matter/setup_payload/__init__.py", - "matter/setup_payload/setup_payload.py", - "matter/storage/__init__.py", - "matter/tracing/__init__.py", - "matter/utils/CommissioningBuildingBlocks.py", - "matter/utils/__init__.py", - "matter/yaml/__init__.py", - "matter/yaml/data_model_lookup.py", - "matter/yaml/errors.py", - "matter/yaml/format_converter.py", - "matter/yaml/runner.py", - ] - if (chip_support_webrtc_python_bindings) { - sources += [ - "matter/webrtc/__init__.py", - "matter/webrtc/async_websocket_client.py", - "matter/webrtc/browser_peer_connection.py", - "matter/webrtc/browser_webrtc_client.py", - "matter/webrtc/command.py", - "matter/webrtc/libdatachannel_peer_connection.py", - "matter/webrtc/libdatachannel_webrtc_client.py", - "matter/webrtc/library_handle.py", - "matter/webrtc/types.py", - "matter/webrtc/utils.py", - "matter/webrtc/webrtc_manager.py", - ] - } - - if (chip_support_commissioning_in_controller) { - sources += [ "matter/ChipDeviceCtrl.py" ] - } else { - sources += [ "matter/server/__init__.py" ] - } + sources = core_sources }, { src_dir = target_out_dir @@ -334,19 +349,6 @@ matter_python_wheel_action("matter-core") { py_packages += [ "matter.server" ] } - py_package_reqs = [ - "coloredlogs", - "construct", - "cryptography", - "dacite", - "deprecation", - "ecdsa", - "ipdb", - "matter-clusters", - "pyyaml", - "rich", - ] - if (current_cpu == "x64") { cpu_tag = "x86_64" } else if (current_cpu == "arm64" && current_os == "linux") { @@ -357,6 +359,8 @@ matter_python_wheel_action("matter-core") { cpu_tag = current_cpu } + py_package_reqs = core_py_package_reqs + if (current_os == "mac") { py_platform_tag = string_replace( string_replace(mac_deployment_target, "macos", "macosx."), @@ -381,21 +385,49 @@ matter_python_wheel_action("matter-core") { output_name = "${py_package_name}-${chip_python_version}-cp37-abi3-${py_platform_tag}.whl" } +pw_python_package("matter-core-module") { + generate_setup = { + metadata = { + name = "matter-core" + version = "1.5.0" + description = "Matter IoT development controller core files" + url = "https://github.com/project-chip/connectedhomeip" + classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + ] + } + options = { + install_requires = core_py_package_reqs + } + } + + sources = core_sources +} + +cluster_sources = [ + "matter/ChipUtility.py", + "matter/clusters/CHIPClusters.py", + "matter/clusters/ClusterObjects.py", + "matter/clusters/Objects.py", + "matter/clusters/TestObjects.py", + "matter/clusters/Types.py", + "matter/clusters/enum.py", + "matter/tlv/__init__.py", + "matter/tlv/tlvlist.py", +] + +cluster_py_package_reqs = [ + "aenum", + "dacite", +] + matter_python_wheel_action("matter-clusters") { py_manifest_files = [ { src_dir = "." - sources = [ - "matter/ChipUtility.py", - "matter/clusters/CHIPClusters.py", - "matter/clusters/ClusterObjects.py", - "matter/clusters/Objects.py", - "matter/clusters/TestObjects.py", - "matter/clusters/Types.py", - "matter/clusters/enum.py", - "matter/tlv/__init__.py", - "matter/tlv/tlvlist.py", - ] + sources = cluster_sources }, { src_dir = "//" @@ -411,10 +443,7 @@ matter_python_wheel_action("matter-clusters") { "matter.tlv", ] - py_package_reqs = [ - "aenum", - "dacite", - ] + py_package_reqs = cluster_py_package_reqs py_package_name = "${chip_python_package_prefix}-clusters" py_platform_tag = "any" @@ -422,18 +451,59 @@ matter_python_wheel_action("matter-clusters") { output_name = "${py_package_name}-${chip_python_version}-py3-none-${py_platform_tag}.whl" } -matter_python_wheel_action("matter-repl") { - py_scripts = [ "matter-repl.py" ] +pw_python_package("matter-clusters-module") { + generate_setup = { + metadata = { + name = "matter-clusters" + version = "1.5.0" + description = "Matter IoT development controller cluster files" + url = "https://github.com/project-chip/connectedhomeip" + classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + ] + } + options = { + install_requires = cluster_py_package_reqs + } + } + + sources = cluster_sources +} + +repl_py_scripts = [ "matter-repl.py" ] +repl_sources = [ + "matter/ChipBluezMgr.py", + "matter/ChipCoreBluetoothMgr.py", + "matter/ReplStartup.py", +] + +repl_py_package_reqs = [ + "coloredlogs", + + # + # IPython 7.30.0 has a bug which results in the use of await ... failing on some platforms (see https://github.com/ipython/ipython/pull/13269) + # For now, let's just avoid that version. + # + # IPython 8.1.0 has a bug which causes issues: https://github.com/ipython/ipython/issues/13554 + # + # + "ipython!=8.1.0", + "rich", + "ipykernel", + "pyobjc-framework-corebluetooth ; sys_platform==\"darwin\"", + "dbus-python==1.2.18 ; sys_platform==\"linux\"", + "pygobject==3.50.0 ; sys_platform==\"linux\"", + "matter-core", +] +matter_python_wheel_action("matter-repl") { + py_scripts = repl_py_scripts py_manifest_files = [ { src_dir = "." - sources = [ - "matter/ChipBluezMgr.py", - "matter/ChipCoreBluetoothMgr.py", - "matter/ReplStartup.py", - ] - sources += py_scripts + sources = repl_sources + py_scripts }, { src_dir = "//" @@ -445,24 +515,7 @@ matter_python_wheel_action("matter-repl") { py_packages = [ "matter" ] - py_package_reqs = [ - "coloredlogs", - - # - # IPython 7.30.0 has a bug which results in the use of await ... failing on some platforms (see https://github.com/ipython/ipython/pull/13269) - # For now, let's just avoid that version. - # - # IPython 8.1.0 has a bug which causes issues: https://github.com/ipython/ipython/issues/13554 - # - # - "ipython!=8.1.0", - "rich", - "ipykernel", - "pyobjc-framework-corebluetooth ; sys_platform==\"darwin\"", - "dbus-python==1.2.18 ; sys_platform==\"linux\"", - "pygobject==3.50.0 ; sys_platform==\"linux\"", - "matter-core", - ] + py_package_reqs = repl_py_package_reqs py_package_name = "${chip_python_package_prefix}-repl" py_platform_tag = "any" @@ -474,3 +527,24 @@ matter_python_wheel_action("matter-repl") { output_name = "${py_package_name}-${chip_python_version}-py3-none-${py_platform_tag}.whl" } + +pw_python_package("matter-repl-module") { + generate_setup = { + metadata = { + name = "matter-clusters" + version = "1.5.0" + description = "Matter IoT development controller cluster files" + url = "https://github.com/project-chip/connectedhomeip" + classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + ] + } + options = { + install_requires = repl_py_package_reqs + } + } + + sources = cluster_sources +} diff --git a/src/controller/python/build-matter-wheel.py b/src/controller/python/build-matter-wheel.py index 3d7166de8561ff..cf59d43cfadbec 100644 --- a/src/controller/python/build-matter-wheel.py +++ b/src/controller/python/build-matter-wheel.py @@ -132,7 +132,7 @@ def has_ext_modules(foo): "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3" ], - python_requires=">=3.7", + python_requires=">=3.11", packages=packages, package_dir={ # By default, look in the tmp directory for packages/modules to be included. diff --git a/src/python_testing/matter_testing_infrastructure/BUILD.gn b/src/python_testing/matter_testing_infrastructure/BUILD.gn index 7bef9a0c1025a0..f8d5b98123cd76 100644 --- a/src/python_testing/matter_testing_infrastructure/BUILD.gn +++ b/src/python_testing/matter_testing_infrastructure/BUILD.gn @@ -20,11 +20,24 @@ import("$dir_pw_build/python.gni") import("$dir_pw_build/python_dist.gni") import("$dir_pw_build/zip.gni") +testing_package_reqs = [ + "click", + "colorama", + "ifaddr", + "langcodes", + "mobly", + "pyasn1", + "pyasn1_modules", + "requests", + "zeroconf", +] + pw_python_package("matter-testing-module") { generate_setup = { metadata = { name = "matter-testing-module" - version = "1.4.0" + description = "Matter python testing framework" + version = "1.5.0" description = "Testing support for Matter SDK" url = "https://github.com/project-chip/connectedhomeip" classifiers = [ @@ -33,6 +46,9 @@ pw_python_package("matter-testing-module") { "Programming Language :: Python :: 3", ] } + options = { + install_requires = testing_package_reqs + } } inputs = [ "env_test.yaml" ] @@ -130,7 +146,7 @@ pw_python_distribution("matter-testing") { generate_setup_cfg = { name = "matter-testing" - version = "1.4.2" + version = "1.5.0" include_default_pyproject_file = true include_extra_files_in_package_data = true } diff --git a/src/python_testing/requirements.txt b/src/python_testing/requirements.txt index 3cf93be71c8c46..e9a82098158657 100644 --- a/src/python_testing/requirements.txt +++ b/src/python_testing/requirements.txt @@ -1,3 +1,5 @@ +click +colorama mobly pyasn1 pyasn1_modules