Skip to content

Commit e9c9757

Browse files
authored
refactor: create a compatible custom integration installation archive (#53)
- Create a one-folder bundle with PyInstaller instead a one-file bundle to save resources. - Change archive format to the custom integration installation archive. - Change default `driver_id` value in `driver.json` to create a compatible custom installation archive.
1 parent 15a7104 commit e9c9757

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
bash -c \
5555
"cd /workspace && \
5656
python -m pip install -r requirements.txt && \
57-
pyinstaller --clean --onefile --name intg-androidtv intg-androidtv/driver.py"
57+
pyinstaller --clean --onedir --name intg-androidtv intg-androidtv/driver.py"
5858
5959
- name: Add version
6060
run: |
@@ -65,7 +65,9 @@ jobs:
6565
- name: Prepare artifacts
6666
shell: bash
6767
run: |
68-
cp dist/intg-androidtv artifacts/
68+
mv dist/intg-androidtv artifacts/
69+
mv artifacts/intg-androidtv artifacts/bin
70+
mv artifacts/bin/intg-androidtv artifacts/bin/driver
6971
cp driver.json artifacts/
7072
cp -r config artifacts/
7173
echo "ARTIFACT_NAME=uc-intg-${{ env.INTG_NAME }}-${{ env.VERSION }}-aarch64" >> $GITHUB_ENV

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Unreleased
99
_Changes in the next release_
1010

11+
### Changed
12+
- Create a one-folder bundle with pyinstaller instead a one-file bundle to save resources.
13+
- Change archive format to the custom integration installation archive.
14+
- Change default `driver_id` value in `driver.json` to create a compatible custom installation archive.
15+
1116
---
1217

1318
## v0.6.1 - 2024-07-21

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ UC_CONFIG_HOME=./config python3 intg-androidtv/driver.py
4444
- The client name used for the client certificate can be set in ENV variable `UC_CLIENT_NAME`.
4545
The hostname is used by default.
4646

47-
## Build self-contained binary
47+
## Build distribution binary
4848

49-
After some tests, turns out python stuff on embedded is a nightmare. So we're better off creating a single binary file
50-
that has everything in it.
49+
After some tests, turns out Python stuff on embedded is a nightmare. So we're better off creating a binary distribution
50+
that has everything in it, including the Python runtime and all required modules and native libraries.
5151

52-
To do that, we need to compile it on the target architecture as `pyinstaller` does not support cross compilation.
52+
To do that, we use [PyInstaller](https://pyinstaller.org/), but it needs to run on the target architecture as
53+
`PyInstaller` does not support cross compilation.
54+
55+
The `--onefile` option to create a one-file bundled executable should be avoided:
56+
- Higher startup cost, since the wrapper binary must first extract the archive.
57+
- Files are extracted to the /tmp directory on the device, which is an in-memory filesystem.
58+
This will further reduce the available memory for the integration drivers!
5359

5460
### x86-64 Linux
5561

@@ -59,7 +65,7 @@ sudo apt install qemu binfmt-support qemu-user-static
5965
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
6066
```
6167

62-
Run pyinstaller:
68+
Run PyInstaller:
6369
```shell
6470
docker run --rm --name builder \
6571
--platform=aarch64 \
@@ -68,7 +74,7 @@ docker run --rm --name builder \
6874
docker.io/unfoldedcircle/r2-pyinstaller:3.11.6 \
6975
bash -c \
7076
"python -m pip install -r requirements.txt && \
71-
pyinstaller --clean --onefile --name intg-androidtv intg-androidtv/driver.py"
77+
pyinstaller --clean --onedir --name intg-androidtv intg-androidtv/driver.py"
7278
```
7379

7480
### aarch64 Linux / Mac
@@ -81,7 +87,7 @@ docker run --rm --name builder \
8187
docker.io/unfoldedcircle/r2-pyinstaller:3.11.6 \
8288
bash -c \
8389
"python -m pip install -r requirements.txt && \
84-
pyinstaller --clean --onefile --name intg-androidtv intg-androidtv/driver.py"
90+
pyinstaller --clean --onedir --name intg-androidtv intg-androidtv/driver.py"
8591
```
8692

8793
## Versioning

driver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"driver_id": "uc_androidtv_driver",
2+
"driver_id": "androidtv",
33
"version": "0.6.1",
44
"min_core_api": "0.20.0",
55
"name": { "en": "Android TV" },

0 commit comments

Comments
 (0)