From b0b996c4c4bcf90191d7170bca4ed3689afdc365 Mon Sep 17 00:00:00 2001 From: Markus Zehnder Date: Sat, 4 Nov 2023 17:57:52 +0100 Subject: [PATCH] build: use published ucapi from PyPI --- .github/workflows/build.yml | 24 ++++---------- .github/workflows/python-code-format.yml | 14 -------- README.md | 41 ++++++++++++++++-------- pyproject.toml | 3 +- requirements.txt | 1 + 5 files changed, 37 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d96752..6ba1114 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,6 @@ name: "Build & Release" on: - workflow_dispatch: push: tags: - v[0-9]+.[0-9]+.[0-9]+* @@ -15,7 +14,6 @@ on: env: INTG_NAME: denonavr HASH_FILENAME: uc-intg-denonavr.hash - INTG_LIB_VER: 0.1.0 # Python version to use in the builder image. See https://hub.docker.com/r/arm64v8/python for possible versions. PYTHON_VER: 3.10.13 @@ -26,26 +24,16 @@ jobs: - name: Checkout uses: actions/checkout@v3 - # We need the integration library, this is temporary until we decide to publish it to pypi - - name: Clone integrations library - shell: bash - run: | - git clone --depth 1 --branch v${INTG_LIB_VER} https://martonborzak:${{ secrets.PAT }}@github.com/aitatoi/integration-python-library.git - ls -lah - - name: Prepare run: | sudo apt-get update && sudo apt-get install -y qemu binfmt-support qemu-user-static docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - # do NOT update the Debian image! Bookworm contains a newer libc which is not available on UCR2 - docker run --name builder --platform=aarch64 -v ${GITHUB_WORKSPACE}:/io -d arm64v8/python:${PYTHON_VER}-bullseye tail -f /dev/null - - echo "Building and installing integration-python-library" - docker exec builder bash -c "cd /io/integration-python-library && python3 setup.py bdist_wheel && python3 -m pip install -I dist/ucapi-${INTG_LIB_VER}-py3-none-any.whl" - echo "Installing pyinstaller" - docker exec builder bash -c "python -m pip install pyinstaller -r /io/requirements.txt" - echo "Running pyinstaller" - docker exec builder bash -c "cd /io && pyinstaller --clean --onefile --name intg-denonavr intg-denonavr/driver.py" + + echo "Running pyinstaller" + docker run --name builder --platform=aarch64 --user=$(id -u):$(id -g) \ + -v ${GITHUB_WORKSPACE}:/workspace \ + docker.io/unfoldedcircle/r2-pyinstaller:${PYTHON_VER} \ + bash -c "cd /workspace && python -m pip install -r requirements.txt && pyinstaller --clean --onefile --name intg-denonavr intg-denonavr/driver.py" - name: Fetch all tags to determine version run: | diff --git a/.github/workflows/python-code-format.yml b/.github/workflows/python-code-format.yml index b46cf56..6f29bcb 100644 --- a/.github/workflows/python-code-format.yml +++ b/.github/workflows/python-code-format.yml @@ -18,9 +18,6 @@ on: permissions: contents: read -env: - INTG_LIB_VER: 0.1.0 - jobs: test: runs-on: ubuntu-22.04 @@ -38,17 +35,6 @@ jobs: run: | python -m pip install --upgrade pip - # We need the integration library, this is temporary until we decide to publish it to pypi - - name: Clone & install integrations library - shell: bash - run: | - git clone --depth 1 --branch v${INTG_LIB_VER} https://martonborzak:${{ secrets.PAT }}@github.com/aitatoi/integration-python-library.git - cd integration-python-library - pip install wheel - python setup.py bdist_wheel - ls -lah dist - pip install -I dist/ucapi-${INTG_LIB_VER}-py3-none-any.whl - - name: Install dependencies run: | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi diff --git a/README.md b/README.md index 6f39e66..4649e79 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,6 @@ Supported commands: pip3 install -r requirements.txt ``` -Manually install [ucapi](https://github.com/aitatoi/integration-python-library) library: -```shell -export UCAPI_PYTHON_LIB_VERSION=0.1.0 -pip3 install --force-reinstall ../integration-python-library/dist/ucapi-$UCAPI_PYTHON_LIB_VERSION-py3-none-any.whl -``` - ## Code Style - Code line length: 120 @@ -77,25 +71,46 @@ PyCharm/IntelliJ IDEA integration: python -m isort intg-denonavr/. ``` -## Build self-contained binary +## Build self-contained binary for Remote Two After some tests, turns out python stuff on embedded is a nightmare. So we're better off creating a single binary file that has everything in it. To do that, we need to compile it on the target architecture as `pyinstaller` does not support cross compilation. -The following can be used on x86 Linux: +### x86-64 Linux +On x86-64 Linux we need Qemu to emulate the aarch64 target platform: ```bash sudo apt-get install qemu binfmt-support qemu-user-static docker run --rm --privileged multiarch/qemu-user-static --reset -p yes -docker run --platform=aarch64 -v "$PWD:/io" -it ubuntu:focal +``` -cd /io -apt-get update && apt-get install -y python3-pip -pip3 install pyinstaller -r requirements.txt -pyinstaller --clean --onefile intg-denonavr/driver.py +Run pyinstaller: +```shell +docker run --rm --name builder \ + --platform=aarch64 \ + --user=$(id -u):$(id -g) \ + -v "$PWD":/workspace \ + docker.io/unfoldedcircle/r2-pyinstaller:3.10.13 \ + bash -c \ + "cd /workspace && \ + python -m pip install -r requirements.txt && \ + pyinstaller --clean --onefile --name intg-denonavr intg-denonavr/driver.py" ``` +### aarch64 Linux / Mac + +On an aarch64 host platform, the build image can be run directly (and much faster): +```shell +docker run --rm --name builder \ + --user=$(id -u):$(id -g) \ + -v "$PWD":/workspace \ + docker.io/unfoldedcircle/r2-pyinstaller:3.10.13 \ + bash -c \ + "cd /workspace && \ + python -m pip install -r requirements.txt && \ + pyinstaller --clean --onefile --name intg-denonavr intg-denonavr/driver.py" +``` ## Licenses To generate the license overview file for remote-ui, [pip-licenses](https://pypi.org/project/pip-licenses/) is used diff --git a/pyproject.toml b/pyproject.toml index 02c8acd..64eb1e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ description = "Remote Two integration for Denon AVRs" classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", - "License :: OSI Approved :: MPL-2.0 License", + "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries", "Topic :: Home Automation", @@ -27,6 +27,7 @@ dependencies = [ "asyncio~=3.4.3", "denonavr~=0.11.4", "pyee~=9.0.4", + "ucapi==0.1.1", "websockets~=11.0.3", "zeroconf~=0.119.0", ] diff --git a/requirements.txt b/requirements.txt index d060d70..31ec5c8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ denonavr~=0.11.4 asyncio~=3.4.3 pyee~=9.0.4 +ucapi==0.1.1 websockets~=11.0.3 zeroconf~=0.119.0