Skip to content

Commit

Permalink
build: use published ucapi from PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
zehnm committed Nov 4, 2023
1 parent 0ea850f commit 6523463
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 46 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
name: "Build & Release"

on:
workflow_dispatch:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
Expand All @@ -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

Expand All @@ -26,26 +24,21 @@ 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 --rm --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: |
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/python-code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ on:
permissions:
contents: read

env:
INTG_LIB_VER: 0.1.0

jobs:
test:
runs-on: ubuntu-22.04
Expand All @@ -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
Expand Down
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
]
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6523463

Please sign in to comment.