Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add python matter server #6481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
51 changes: 51 additions & 0 deletions spk/matter-server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
SPK_NAME = matter-server
SPK_VERS = 7.0.1
SPK_REV = 1
SPK_ICON = src/matter.png

# 64-bit OS supported only
# and therefore home-assistant-chip-core is only available for x64 and aarch64
UNSUPPORTED_ARCHS = $(32bit_ARCHS)

# home-assistant-chip-core requires glibc >= 2.34
# despite home-assistant-chip-core wheel is provided as manylinux_2_31, it requires glibc 2.34 and not 2.31
REQUIRED_MIN_DSM = 7.2

PYTHON_PACKAGE = python312
SPK_DEPENDS = "$(PYTHON_PACKAGE)"

MAINTAINER = SynoCommunity
DESCRIPTION = The Open Home Foundation Matter Server is an officially certified Software Component to create a Matter controller. It serves as the foundation to provide Matter support to Home Assistant but its universal approach makes it suitable to be used in other projects too. This package conains a custom library for home-assistant-chip-core to allow definition of config data path.
DISPLAY_NAME = Python Matter Server
CHANGELOG = "1. Initial package with custom library for home_assistant_chip_core==2024.11.4"

HOMEPAGE = https://www.python.org
LICENSE = PSF

STARTABLE = yes
SERVICE_SETUP = src/service-setup.sh

FWPORTS = src/matter-server.sc

USE_ALTERNATE_TMPDIR = 1

POST_STRIP_TARGET = matter-server_extra_install

WHEELS = src/requirements-crossenv.txt

# [PyYAML]
DEPENDS += cross/libyaml

include ../../mk/spksrc.python.mk

ifeq ($(findstring $(ARCH),$(x64_ARCHS)),$(ARCH))
CUSTOM_CHIP_LIBRARY = src/custom_chip_library/x64/_ChipDeviceCtrl.so
else ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS)),$(ARCH))
CUSTOM_CHIP_LIBRARY = src/custom_chip_library/aarch64/_ChipDeviceCtrl.so
endif

.PHONY: matter-server_extra_install
matter-server_extra_install:
@install -m 755 -d $(STAGING_DIR)/share $(STAGING_DIR)/custom_chip_library
@install -m 644 src/requirements-pure.txt $(STAGING_DIR)/share/
@install -m 644 $(CUSTOM_CHIP_LIBRARY) $(STAGING_DIR)/custom_chip_library/
1 change: 1 addition & 0 deletions spk/matter-server/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rsc:share/wheelhouse
Binary file not shown.
33 changes: 33 additions & 0 deletions spk/matter-server/src/custom_chip_library/strip_libraries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#/bin/bash

# run this script once after update of the custom library files

TOOLCHAIN_ROOT=$(realpath ../../../../toolchain)

if [ ! -d ${TOOLCHAIN_ROOT} ]; then
echo "This script must be run in spksrc."
echo "ERROR: Toolchain root folder not found: ${TOOLCHAIN_ROOT}"
exit 1
fi

STRIP_X64=${TOOLCHAIN_ROOT}/syno-x64-7.1/work/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/bin/strip
STRIP_AARCH64=${TOOLCHAIN_ROOT}/syno-aarch64-7.1/work/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/bin/strip
if [ ! -e "${STRIP_X64}" ]; then
echo "stip for x64 not available"
echo "missing ${STRIP_X64}"
exit 1
else
${STRIP_X64} ./x64/_ChipDeviceCtrl.so
echo "file stripped:"
file ./x64/_ChipDeviceCtrl.so
fi

if [ ! -e "${STRIP_AARCH64}" ]; then
echo "stip for aarch64 not available"
echo "missing ${STRIP_AARCH64}"
exit 1
else
${STRIP_AARCH64} ./aarch64/_ChipDeviceCtrl.so
echo "file stripped:"
file ./aarch64/_ChipDeviceCtrl.so
fi
Binary file not shown.
5 changes: 5 additions & 0 deletions spk/matter-server/src/matter-server.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[matter_ws]
title="Matter WebService (TCP)"
desc="matter ws"
port_forward="yes"
dst.ports="5580/tcp"
Binary file added spk/matter-server/src/matter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions spk/matter-server/src/requirements-crossenv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
aiohttp==3.11.11
cffi==1.17.1
cryptography==44.0.0
frozenlist==1.5.0
#home_assistant_chip_core==2024.11.4 # no source available, moved to requirements-pure to download from index
multidict==6.1.0
orjson==3.10.13
propcache==0.3.0
PyYAML==6.0.2
yarl==1.18.3
zeroconf==0.136.2
43 changes: 43 additions & 0 deletions spk/matter-server/src/requirements-pure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
aenum==3.1.15
aiohappyeyeballs==2.6.1
aiorun==2024.8.1
aiosignal==1.3.2
asttokens==3.0.0
async_timeout==5.0.1
atomicwrites==1.4.1
attrs==25.3.0
coloredlogs==15.0.1
construct==2.10.70
dacite==1.9.2
decorator==5.2.1
deprecation==2.1.0
ecdsa==0.19.1
executing==2.2.0
home_assistant_chip_clusters==2024.11.4
# chip library for home_assistant_chip_core will be replaced by a custom version by package installer to support custom config path
home_assistant_chip_core==2024.11.4 # cross wheel downloaded from index
humanfriendly==10.0
idna==3.10
ifaddr==0.2.0
ipdb==0.13.13
ipython==9.0.2
ipython_pygments_lexers==1.1.1
jedi==0.19.2
markdown_it_py==3.0.0
matplotlib_inline==0.1.7
mdurl==0.1.2
packaging==24.2
parso==0.8.4
pexpect==4.9.0
#pip==24.3.1
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pure_eval==0.2.3
pycparser==2.22
pygments==2.19.1
python_matter_server==7.0.1
rich==13.9.4
six==1.17.0
stack_data==0.6.3
traitlets==5.14.3
wcwidth==0.2.13
40 changes: 40 additions & 0 deletions spk/matter-server/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

PYTHON_VER=python3.12
PYTHON_DIR="/var/packages/python312/target/bin"
PATH="${SYNOPKG_PKGDEST}/env/bin:${SYNOPKG_PKGDEST}/bin:${PYTHON_DIR}:${PATH}"

DATA_PATH=${SYNOPKG_PKGVAR}/data
# config data path provided by custom chip library only:
export CHIP_CONIFG_DATA_PATH=${DATA_PATH}
OTA_PROVIDER_DIR=${SYNOPKG_PKGVAR}/ota
SERVER=${SYNOPKG_PKGDEST}/env/bin/matter-server
SERVICE_COMMAND="${SERVER} --log-file ${LOG_FILE} --storage-path ${DATA_PATH} --ota-provider-dir ${OTA_PROVIDER_DIR}"
SVC_WRITE_PID=y
SVC_BACKGROUND=y


service_postinst ()
{
separator="===================================================="

echo ${separator}
echo "Install Python virtual environment"
install_python_virtualenv

echo ${separator}
echo "Install packages from wheelhouse"
pip install --disable-pip-version-check --no-deps --no-input --no-index ${SYNOPKG_PKGDEST}/share/wheelhouse/*.whl

echo ${separator}
echo "Install python packages from index"
pip install --disable-pip-version-check --no-deps --no-input --requirement ${SYNOPKG_PKGDEST}/share/requirements-pure.txt

echo ${separator}
echo "create special folders"
mkdir -p ${DATA_PATH}
mkdir -p ${OTA_PROVIDER_DIR}

echo ${separator}
echo "use custom chip library in home_assistant_chip_core"
install -m 644 ${SYNOPKG_PKGDEST}/custom_chip_library/_ChipDeviceCtrl.so ${SYNOPKG_PKGDEST}/env/lib/${PYTHON_VER}/site-packages/chip/
}
9 changes: 9 additions & 0 deletions spk/python312/crossenv/requirements-propcache.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pip==24.3.1
setuptools==75.4.0
wheel==0.45.0
#
build:build==1.2.2
build:Cython==3.0.11
build:pip-tools==7.4.1
#
cross:expandvars==0.12.0