Skip to content

Commit f96fc05

Browse files
authored
Merge pull request #10 from espressif/fix/use_wheels_image
fix: Use image from wheels for ARMv7 builds
2 parents dc48a13 + ea45871 commit f96fc05

File tree

2 files changed

+46
-59
lines changed

2 files changed

+46
-59
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,18 @@ Building the project with default configuration will result in script name `__ma
139139

140140
### ARM Architecture Build
141141

142+
143+
The ARMv7 build image already includes most of the required system packages by default. However, if you need to add extra system packages, you can do so as shown in the example below.
144+
For more details about the ARMv7 image, refer to its [Dockerfile definition](https://github.com/espressif/github-esp-dockerfiles/blob/master/idf_python_wheels_legacy/Dockerfile).
145+
142146
```yaml
143147
- name: Build for ARMv7
144148
uses: espressif/python-binary-action@master
145149
with:
146150
scripts: 'main.py'
147151
output-dir: './arm-binaries'
148152
target-platform: 'linux-armv7'
149-
additional-arm-packages: 'openssl libffi-dev libffi7 libssl-dev'
153+
additional-arm-packages: 'openssl libffi-dev'
150154
python-version: '3.11'
151155
```
152156

@@ -278,7 +282,7 @@ jobs:
278282
| `additional-args` | Additional PyInstaller arguments | `""` | `"--hidden-import=module"` |
279283
| `pip-extra-index-url` | Extra Python package index URL | `https://dl.espressif.com/pypi` | `""` |
280284
| `install-deps-command` | Command to install project dependencies | `"uv pip install -e ."` | `"uv pip install -r requirements.txt"` |
281-
| `additional-arm-packages` | ARMv7 ONLY: Additional system packages | `""` | `"openssl libffi-dev"` |
285+
| `additional-arm-packages` | ARMv7 ONLY: Extra apt packages (the Espressif ARMv7 image already ships most build deps) | `""` | `"openssl libssl-dev"` |
282286
| `test-command-args` | Command arguments to test executables | `"--help"` | `"--version"` |
283287

284288
> [!IMPORTANT]

action.yml

Lines changed: 40 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ inputs:
5252
required: false
5353
default: uv pip install -e .
5454
additional-arm-packages:
55-
description: 'ARMv7 ONLY: Additional system packages to install (space-separated).
56-
e.g. for cryptography: openssl libffi-dev libffi7 libssl-dev'
55+
description: 'ARMv7 ONLY: Optional extra apt packages (space-separated). The Espressif
56+
idf-python-wheels-armv7l image already includes build tools, libffi-dev, libssl-dev,
57+
patchelf, etc.; omit this unless you need more.'
5758
required: false
5859
default: ''
5960
test-command-args:
@@ -132,68 +133,50 @@ runs:
132133
# Write include-data-dirs to a temporary file to avoid shell escaping issues
133134
echo '${{ inputs.include-data-dirs }}' > ${GITHUB_ACTION_PATH}/include_data_dirs.json
134135
136+
- name: Set up QEMU for ARMv7 Docker
137+
if: inputs.target-platform == 'linux-armv7'
138+
uses: docker/setup-qemu-action@v3
139+
135140
- name: Build for ARMv7 architecture
136141
if: inputs.target-platform == 'linux-armv7'
137-
uses: uraimo/run-on-arch-action@v3
138-
with:
139-
arch: armv7
140-
# Use Ubuntu 20.04 because of missing libffi7 in 24.04 (cryptography requires it) and better compatibility with GLIBC
141-
distro: ubuntu20.04
142-
shell: /bin/bash
143-
githubToken: ${{ github.token }}
144-
setup: mkdir -p "${PWD}/${{ inputs.output-dir }}"
145-
dockerRunArgs: |
146-
--volume "${PWD}/${{ inputs.output-dir }}:/${{ inputs.output-dir }}"
147-
--volume "${GITHUB_ACTION_PATH}:/github/action"
148-
install: |
149-
export DEBIAN_FRONTEND=noninteractive
150-
export TZ=UTC
151-
apt-get update -y
152-
apt-get install -y curl git build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev pkg-config gcc g++ patchelf binutils ${{ inputs.additional-arm-packages }}
153-
run: |
154-
adduser --disabled-password --gecos "" builder
155-
chmod -R a+rwx /home/runner/work
156-
su builder <<'EOF'
157-
curl -LsSf https://astral.sh/uv/install.sh | sh
158-
source $HOME/.local/bin/env
159-
# Install Python version using uv
160-
uv python install ${{ inputs.python-version }}
161-
# Create and activate virtual environment
162-
uv venv
163-
source .venv/bin/activate
164-
# Install UV and upgrade tools
165-
uv pip install --upgrade setuptools wheel
166-
export PATH=$PATH:/home/builder/.local/bin
142+
shell: bash
143+
run: |
144+
docker run --rm \
145+
--platform linux/arm/v7 \
146+
-v "${PWD}/${{ inputs.output-dir }}:/${{ inputs.output-dir }}" \
147+
-v "${GITHUB_ACTION_PATH}:/github/action" \
148+
-v "${GITHUB_WORKSPACE}:/${GITHUB_WORKSPACE}" \
149+
-w ${GITHUB_WORKSPACE} \
150+
ghcr.io/espressif/github-esp-dockerfiles/idf-python-wheels-armv7l:v1 \
151+
bash -c "
152+
export DEBIAN_FRONTEND=noninteractive &&
153+
export TZ=UTC &&
154+
if [ -n '${{ inputs.additional-arm-packages }}' ]; then
155+
apt-get update -y &&
156+
apt-get install -y ${{ inputs.additional-arm-packages }}
157+
fi &&
158+
curl -LsSf https://astral.sh/uv/install.sh | sh &&
159+
source /root/.local/bin/env &&
160+
uv python install ${{ inputs.python-version }} &&
161+
uv venv &&
162+
source .venv/bin/activate &&
163+
uv pip install --upgrade setuptools wheel &&
167164
168-
# Setup environment using helper script
165+
export GITHUB_ACTION_PATH=/github/action &&
169166
/github/action/setup_environment.sh \
170-
"${{ inputs.pyinstaller-version }}" \
171-
"${{ inputs.pip-extra-index-url }}" \
172-
"${{ inputs.install-deps-command }}"
173-
174-
# Write include-data-dirs to a temporary file to avoid shell escaping issues
175-
echo '${{ inputs.include-data-dirs }}' > /tmp/include_data_dirs.json
167+
'${{ inputs.pyinstaller-version }}' \
168+
'${{ inputs.pip-extra-index-url }}' \
169+
'${{ inputs.install-deps-command }}' &&
176170
177-
# Build each file using the script
178-
export GITHUB_ACTION_PATH=/github/action
179-
/github/action/build_with_pyinstaller.sh \
180-
"${{ inputs.target-platform }}" \
181-
"${{ inputs.output-dir }}" \
182-
"${{ inputs.scripts }}" \
183-
"${{ inputs.script-name }}" \
184-
"" \
185-
"/tmp/include_data_dirs.json" \
186-
"${{ steps.setup-platform.outputs.data-separator }}" \
187-
"${{ inputs.additional-args }}"
171+
/github/action/build_with_pyinstaller.sh '${{ inputs.target-platform }}' '${{ inputs.output-dir }}' '${{ inputs.scripts }}' '${{ inputs.script-name }}' '${{ inputs.icon-file }}' '/github/action/include_data_dirs.json' '${{ steps.setup-platform.outputs.data-separator }}' '${{ inputs.additional-args }}' &&
188172
189-
# Test binaries using helper script
190173
/github/action/test_executables.sh \
191-
"${{ inputs.scripts }}" \
192-
"${{ inputs.script-name }}" \
193-
"${{ inputs.output-dir }}" \
194-
"${{ steps.setup-platform.outputs.exe-extension }}" \
195-
"${{ inputs.test-command-args }}"
196-
EOF
174+
'${{ inputs.scripts }}' \
175+
'${{ inputs.script-name }}' \
176+
'${{ inputs.output-dir }}' \
177+
'${{ steps.setup-platform.outputs.exe-extension }}' \
178+
'${{ inputs.test-command-args }}'
179+
"
197180
198181
- name: Build for Linux (Docker)
199182
# Running in Docker to link older versions of GLIBC, because the GitHub runners don't offer ubuntu 20.04 anymore

0 commit comments

Comments
 (0)