Skip to content

Commit 119dec3

Browse files
authored
Merge pull request #54 from espressif/feat/manylinux
Repair workflow for dynamically linked libraries of wheels
2 parents 701fcd2 + 3312ec7 commit 119dec3

13 files changed

+1235
-187
lines changed

.github/workflows/build-wheels-defined.yml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ jobs:
157157
run: os_dependencies/macos.sh
158158

159159
- name: Build wheels
160+
env:
161+
ARCHFLAGS: "-arch x86_64" # Force x86_64-only wheels, not universal2
160162
run: |
161163
python build_wheels_from_file.py --requirements ${{ inputs.packages }}
162164
@@ -207,6 +209,8 @@ jobs:
207209
run: os_dependencies/macos.sh
208210

209211
- name: Build wheels
212+
env:
213+
ARCHFLAGS: "-arch arm64" # Force arm64-only wheels, not universal2
210214
run: |
211215
python build_wheels_from_file.py --requirements ${{ inputs.packages }}
212216
@@ -221,33 +225,39 @@ jobs:
221225
needs: get-supported-versions
222226
name: linux aarch32 (armv7)
223227
if: ${{ inputs.os_linux_armv7 }}
224-
runs-on: linux-armv7-self-hosted
228+
runs-on: ubuntu-latest
225229
strategy:
226230
fail-fast: false
227231
matrix:
228232
python-version: ${{ fromJson(needs.get-supported-versions.outputs.supported_python) }}
229-
container: python:${{ matrix.python-version }}-bookworm
230233
steps:
234+
- name: Set up QEMU for ARMv7
235+
uses: docker/setup-qemu-action@v3
236+
with:
237+
platforms: linux/arm/v7
238+
231239
- name: Checkout repository
232240
uses: actions/checkout@v4
233241

234-
- name: Get Python version
235-
run: |
236-
python --version
237-
python -m pip install --upgrade pip
238-
239-
- name: Install build dependencies
240-
run: python -m pip install -r build_requirements.txt
241-
242-
- name: Install additional OS dependencies - Linux ARM
243-
run: os_dependencies/linux_arm.sh
244-
245-
- name: Build wheels
242+
- name: Build wheels - ARMv7 (in Docker)
246243
run: |
247-
# Rust directory needs to be included for Linux ARM7
248-
. $HOME/.cargo/env
249-
250-
python build_wheels_from_file.py --requirements ${{ inputs.packages }}
244+
docker run --rm --platform linux/arm/v7 \
245+
-v $(pwd):/work \
246+
-w /work \
247+
-e GH_TOKEN="${GH_TOKEN}" \
248+
-e PIP_NO_CACHE_DIR=1 \
249+
python:${{ matrix.python-version }}-bookworm \
250+
bash -c "
251+
set -e
252+
python --version
253+
# Install pip packages without cache to reduce memory usage
254+
python -m pip install --no-cache-dir --upgrade pip
255+
python -m pip install --no-cache-dir -r build_requirements.txt
256+
bash os_dependencies/linux_arm.sh
257+
# Source Rust environment after installation
258+
. \$HOME/.cargo/env
259+
python build_wheels_from_file.py --requirements '${{ inputs.packages }}'
260+
"
251261
252262
- name: Upload artifacts of downloaded_wheels directory
253263
uses: actions/upload-artifact@v4
@@ -291,9 +301,17 @@ jobs:
291301
name: wheels-download-directory-linux-arm64-${{ matrix.python-version }}
292302
path: ./downloaded_wheels
293303

294-
upload-python-wheels:
304+
# Repair wheels for dynamically linked libraries on all platforms
305+
# https://github.com/espressif/idf-python-wheels/blob/main/README.md#universal-wheel-tag---linking-of-dynamic-libraries
306+
repair-wheels:
295307
if: ${{ always() }}
296308
needs: [get-supported-versions, ubuntu-latest, windows-latest, macos-latest, macos-m1, linux-armv7, linux-arm64]
309+
name: Repair wheels
310+
uses: ./.github/workflows/wheels-repair.yml
311+
312+
upload-python-wheels:
313+
if: ${{ always() }}
314+
needs: [repair-wheels]
297315
name: Upload Python wheels
298316
uses: espressif/idf-python-wheels/.github/workflows/upload-python-wheels.yml@main
299317
secrets: inherit

.github/workflows/build-wheels-platforms.yml

Lines changed: 89 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,52 @@ jobs:
1717
build-wheels:
1818
needs: get-supported-versions
1919
name: Build for ${{ matrix.os }} (Python ${{matrix.python-version}})
20-
runs-on: ${{ matrix.os }}
20+
runs-on: ${{ matrix.runner }}
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
os: # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
25-
- windows-latest
26-
- ubuntu-latest
27-
- macos-15-intel # MacOS x86_64
28-
- macos-latest # MacOS arm64 (M1)
29-
- ubuntu-24.04-arm
30-
- linux-armv7-self-hosted
24+
os: # Platform names for identification
25+
- Windows
26+
- Linux x86_64
27+
- macOS Intel
28+
- macOS ARM
29+
- Linux ARM64
30+
- Linux ARMv7
3131
include:
32-
- os: linux-armv7-self-hosted
33-
CONTAINER: python:${{ needs.get-supported-versions.outputs.oldest_supported_python }}-bookworm
32+
- os: Windows
33+
runner: windows-latest
34+
arch: windows-x86_64
35+
- os: Linux x86_64
36+
runner: ubuntu-latest
37+
arch: linux-x86_64
38+
- os: macOS Intel
39+
runner: macos-15-intel
40+
arch: macos-x86_64
41+
- os: macOS ARM
42+
runner: macos-latest
43+
arch: macos-arm64
44+
- os: Linux ARM64
45+
runner: ubuntu-24.04-arm
46+
arch: linux-arm64
47+
- os: Linux ARMv7
48+
runner: ubuntu-latest
49+
arch: linux-armv7
3450
python-version: ['${{ needs.get-supported-versions.outputs.oldest_supported_python }}']
3551

36-
# Use python container on ARM
37-
container: ${{ matrix.CONTAINER }}
38-
3952
steps:
53+
- name: Set up QEMU for ARMv7
54+
if: matrix.os == 'Linux ARMv7'
55+
uses: docker/setup-qemu-action@v3
56+
with:
57+
platforms: linux/arm/v7
58+
4059
- name: OS info
41-
if: matrix.os != 'windows-latest'
60+
if: matrix.os != 'Windows'
4261
run: |
4362
echo "Operating System: ${{ runner.os }}"
4463
echo "Architecture: $(uname -m)"
4564
- name: OS info
46-
if: matrix.os == 'windows-latest'
65+
if: matrix.os == 'Windows'
4766
run: |
4867
echo "Operating System: ${{ runner.os }}"
4968
echo "Architecture: $env:PROCESSOR_ARCHITECTURE"
@@ -60,66 +79,92 @@ jobs:
6079
6180
- name: Setup Python
6281
# Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108
63-
if: matrix.os != 'linux-armv7-self-hosted'
82+
if: matrix.os != 'Linux ARMv7'
6483
uses: actions/setup-python@v5
6584
with:
6685
python-version: ${{ matrix.python-version }}
6786

6887

6988
- name: Install build dependencies
89+
if: matrix.os != 'Linux ARMv7'
7090
run: |
7191
python -m pip install --upgrade pip
7292
python -m pip install -r build_requirements.txt
7393
74-
7594
- name: Get Tools versions
95+
if: matrix.os != 'Linux ARMv7'
7696
run: |
7797
python --version
7898
pip show pip setuptools
7999
80-
81100
- name: Install additional OS dependencies - Ubuntu
82-
if: matrix.os == 'ubuntu-latest'
101+
if: matrix.os == 'Linux x86_64'
83102
run: os_dependencies/ubuntu.sh
84103

85104
- name: Install additional OS dependencies - MacOS
86-
if: matrix.os == 'macos-latest' || matrix.os == 'macos-15-intel'
105+
if: matrix.os == 'macOS ARM' || matrix.os == 'macOS Intel'
87106
run: os_dependencies/macos.sh
88107

89-
- name: Install additional OS dependencies - Linux ARM
90-
if: matrix.os == 'linux-armv7-self-hosted' || matrix.os == 'ubuntu-24.04-arm'
108+
- name: Install additional OS dependencies - Linux ARM64
109+
if: matrix.os == 'Linux ARM64'
91110
run: os_dependencies/linux_arm.sh
92111

93112
- name: Install additional OS dependencies - Windows
94-
if: matrix.os == 'windows-latest'
113+
if: matrix.os == 'Windows'
95114
run: powershell -ExecutionPolicy Bypass -File os_dependencies/windows.ps1
96115

97-
98-
- name: Build wheels for IDF
99-
if: matrix.os != 'windows-latest'
116+
- name: Build wheels for IDF - ARMv7 (in Docker)
117+
if: matrix.os == 'Linux ARMv7'
100118
run: |
101-
# Source Rust environment for self-hosted ARMv7 runner
102-
if [ "${{ matrix.os }}" = "linux-armv7-self-hosted" ]; then
103-
. $HOME/.cargo/env
119+
docker run --rm --platform linux/arm/v7 \
120+
-v $(pwd):/work \
121+
-w /work \
122+
-e MIN_IDF_MAJOR_VERSION=${{ needs.get-supported-versions.outputs.min_idf_major_version }} \
123+
-e MIN_IDF_MINOR_VERSION=${{ needs.get-supported-versions.outputs.min_idf_minor_version }} \
124+
-e GH_TOKEN="${GH_TOKEN}" \
125+
-e PIP_NO_CACHE_DIR=1 \
126+
python:${{ matrix.python-version }}-bookworm \
127+
bash -c "
128+
set -e
129+
python --version
130+
# Install pip packages without cache to reduce memory usage
131+
python -m pip install --no-cache-dir --upgrade pip
132+
python -m pip install --no-cache-dir -r build_requirements.txt
133+
bash os_dependencies/linux_arm.sh
134+
# Source Rust environment after installation
135+
. \$HOME/.cargo/env
136+
python build_wheels.py
137+
"
138+
139+
- name: Build wheels for IDF - Linux/macOS
140+
if: matrix.os != 'Windows' && matrix.os != 'Linux ARMv7'
141+
run: |
142+
# Set ARCHFLAGS for macOS to prevent universal2 wheels
143+
if [ "${{ matrix.os }}" = "macOS ARM" ]; then
144+
export ARCHFLAGS="-arch arm64"
145+
elif [ "${{ matrix.os }}" = "macOS Intel" ]; then
146+
export ARCHFLAGS="-arch x86_64"
104147
fi
105148
106149
python build_wheels.py
107150
108151
- name: Build wheels for IDF - Windows
109-
if: matrix.os == 'windows-latest'
152+
if: matrix.os == 'Windows'
110153
run: python build_wheels.py
111154

112155
- name: Upload artifacts of downloaded_wheels directory
113156
uses: actions/upload-artifact@v4
114157
with:
115-
name: wheels-download-directory-${{ matrix.os}}-${{ matrix.python-version }}
158+
name: wheels-download-directory-${{ matrix.arch }}-${{ matrix.python-version }}
116159
path: ./downloaded_wheels
160+
retention-days: 1
117161

118162
- name: Upload artifacts of Python version dependent wheels
119163
uses: actions/upload-artifact@v4
120164
with:
121-
name: dependent_requirements_${{ matrix.os}}
165+
name: dependent_requirements_${{ matrix.arch }}
122166
path: ./dependent_requirements.txt
167+
retention-days: 1
123168

124169

125170
build-python-version-dependent-wheels:
@@ -130,9 +175,15 @@ jobs:
130175
supported_python_versions: ${{ needs.get-supported-versions.outputs.supported_python }}
131176
oldest_supported_python: ${{ needs.get-supported-versions.outputs.oldest_supported_python }}
132177

133-
# TODO Uncomment this when we are ready to upload the wheels
134-
#upload-python-wheels:
135-
# needs: [build-wheels, build-python-version-dependent-wheels]
136-
# name: Upload Python wheels
137-
# uses: ./.github/workflows/upload-python-wheels.yml
138-
# secrets: inherit
178+
# Repair wheels for dynamically linked libraries on all platforms
179+
# https://github.com/espressif/idf-python-wheels/blob/main/README.md#universal-wheel-tag---linking-of-dynamic-libraries
180+
repair-wheels:
181+
needs: [build-wheels, build-python-version-dependent-wheels]
182+
name: Repair wheels
183+
uses: ./.github/workflows/wheels-repair.yml
184+
185+
upload-python-wheels:
186+
needs: [repair-wheels]
187+
name: Upload Python wheels
188+
uses: ./.github/workflows/upload-python-wheels.yml
189+
secrets: inherit

0 commit comments

Comments
 (0)