Skip to content

Commit 0869598

Browse files
build(python): Build wheels for ARM Windows in Python release workflow (#20247)
1 parent 0edbfff commit 0869598

File tree

1 file changed

+92
-2
lines changed

1 file changed

+92
-2
lines changed

Diff for: .github/workflows/release-python.yml

+92-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ concurrency:
1919

2020
env:
2121
PYTHON_VERSION: '3.9'
22+
PYTHON_VERSION_WIN_ARM64: '3.11' # ARM64 Windows doesn't have older versions
2223
CARGO_INCREMENTAL: 0
2324
CARGO_NET_RETRY: 10
2425
RUSTUP_MAX_RETRIES: 10
@@ -93,17 +94,75 @@ jobs:
9394
fail-fast: false
9495
matrix:
9596
package: [polars, polars-lts-cpu, polars-u64-idx]
96-
os: [ubuntu-latest, macos-13, windows-latest]
97+
os: [ubuntu-latest, macos-13, windows-latest, windows-arm64-16gb]
9798
architecture: [x86-64, aarch64]
9899
exclude:
99100
- os: windows-latest
100101
architecture: aarch64
102+
- os: windows-arm64-16gb
103+
architecture: x86-64
101104

102105
env:
103106
SED_INPLACE: ${{ matrix.os == 'macos-13' && '-i ''''' || '-i'}}
104107
CPU_CHECK_MODULE: py-polars/polars/_cpu_check.py
105108

106109
steps:
110+
- name: Setup build environment (ARM64 Windows)
111+
if: matrix.os == 'windows-arm64-16gb'
112+
shell:
113+
powershell
114+
# Notes
115+
# * We update `Expand-Archive` to avoid "" is not a supported archive file format when extracting
116+
# files that don't end in `.zip`
117+
run: |
118+
Write-Output "> Update Expand-Archive (Microsoft.PowerShell.Archive)"
119+
Install-PackageProvider -Name NuGet -Force
120+
Install-Module -Name Microsoft.PowerShell.Archive -Force
121+
122+
Write-Output "> Setup bash.exe (git-for-windows/PortableGit)"
123+
Invoke-WebRequest "https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/PortableGit-2.47.1-arm64.7z.exe" -OutFile /git.7z.exe
124+
/git.7z.exe -o/git -y
125+
126+
Write-Output "> Setup Rust"
127+
Invoke-WebRequest "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe" -OutFile /rustup-init.exe
128+
/rustup-init.exe --default-host aarch64-pc-windows-msvc -y
129+
130+
Write-Output "> Setup VS Build Tools"
131+
Invoke-WebRequest "https://aka.ms/vs/17/release/vs_BuildTools.exe" -OutFile /vs_BuildTools.exe
132+
Start-Process C:/vs_BuildTools.exe -ArgumentList " `
133+
--add Microsoft.VisualStudio.Workload.NativeDesktop `
134+
--add Microsoft.VisualStudio.Workload.VCTools `
135+
--add Microsoft.VisualStudio.Component.VC.Tools.arm64 `
136+
--add Microsoft.VisualStudio.Component.VC.Llvm.Clang `
137+
--add Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset `
138+
--includeRecommended --quiet --norestart --wait" -Wait
139+
140+
Write-Output "> Setup CMake"
141+
Invoke-WebRequest "https://github.com/Kitware/CMake/releases/download/v3.31.2/cmake-3.31.2-windows-arm64.zip" -OutFile /cmake.zip
142+
Expand-Archive /cmake.zip -DestinationPath /
143+
144+
Write-Output "> Download jq.exe (github.com/jqlang) (needed for tomlq / yq)"
145+
Invoke-WebRequest https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-i386.exe -OutFile /jq.exe
146+
147+
Write-Output "> Update GITHUB_PATH"
148+
[System.IO.File]::AppendAllText($Env:GITHUB_PATH, "`n" + "C:/git/bin/")
149+
[System.IO.File]::AppendAllText($Env:GITHUB_PATH, "`n" + $Env:USERPROFILE + "/.cargo/bin/")
150+
[System.IO.File]::AppendAllText($Env:GITHUB_PATH, "`n" + "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/Llvm/bin/")
151+
[System.IO.File]::AppendAllText($Env:GITHUB_PATH, "`n" + "C:/cmake-3.31.2-windows-arm64/bin")
152+
[System.IO.File]::AppendAllText($Env:GITHUB_PATH, "`n" + "C:/")
153+
[System.IO.File]::AppendAllText($Env:GITHUB_PATH, "`n")
154+
155+
Get-Content $Env:GITHUB_PATH | Out-Host
156+
157+
- name: Check build environment (ARM64 Windows)
158+
if: matrix.os == 'windows-arm64-16gb'
159+
run: |
160+
set -x
161+
bash --version
162+
rustup show
163+
clang -v
164+
cmake --version
165+
107166
- uses: actions/checkout@v4
108167
with:
109168
ref: ${{ inputs.sha }}
@@ -116,19 +175,35 @@ jobs:
116175
swap-size-gb: 10
117176

118177
- name: Set up Python
178+
if: matrix.os != 'windows-arm64-16gb'
119179
uses: actions/setup-python@v5
120180
with:
121181
python-version: ${{ env.PYTHON_VERSION }}
122182

183+
- name: Set up Python (ARM64 Windows)
184+
if: matrix.os == 'windows-arm64-16gb'
185+
uses: actions/setup-python@v5
186+
with:
187+
python-version: ${{ env.PYTHON_VERSION_WIN_ARM64 }}
188+
189+
# Otherwise can't find `tomlq` after `pip install yq`
190+
- name: Add Python scripts folder to GITHUB_PATH (ARM64 Windows)
191+
if: matrix.os == 'windows-arm64-16gb'
192+
run: |
193+
python -c "import sysconfig; print(sysconfig.get_path('scripts'))" >> $GITHUB_PATH
194+
123195
- name: Install yq
124196
if: matrix.package != 'polars'
125197
run: pip install yq
198+
126199
- name: Update package name
127200
if: matrix.package != 'polars'
128201
run: tomlq -i -t ".project.name = \"${{ matrix.package }}\"" py-polars/pyproject.toml
202+
129203
- name: Add bigidx feature
130204
if: matrix.package == 'polars-u64-idx'
131205
run: tomlq -i -t '.dependencies.polars.features += ["bigidx"]' py-polars/Cargo.toml
206+
132207
- name: Update optional dependencies
133208
if: matrix.package != 'polars'
134209
run: sed $SED_INPLACE 's/polars\[/${{ matrix.package }}\[/' py-polars/pyproject.toml
@@ -181,14 +256,29 @@ jobs:
181256
if: matrix.architecture == 'aarch64'
182257
id: target
183258
run: |
184-
TARGET=${{ matrix.os == 'macos-13' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu'}}
259+
TARGET=$(
260+
if [[ "${{ matrix.os }}" == "macos-13" ]]; then
261+
echo "aarch64-apple-darwin";
262+
elif [[ "${{ matrix.os }}" == "windows-arm64-16gb" ]]; then
263+
echo "aarch64-pc-windows-msvc";
264+
else
265+
echo "aarch64-unknown-linux-gnu";
266+
fi
267+
)
185268
echo "target=$TARGET" >> $GITHUB_OUTPUT
186269
187270
- name: Set jemalloc for aarch64 Linux
188271
if: matrix.architecture == 'aarch64' && matrix.os == 'ubuntu-latest'
189272
run: |
190273
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
191274
275+
- name: Copy toolchain to py-polars/ (ARM64 Windows)
276+
# Manual fix for:
277+
# TomlError: Unknown character "46" at row 1, col 2, pos 1:
278+
# 1> ../rust-toolchain.toml
279+
if: matrix.os == 'windows-arm64-16gb'
280+
run: cp rust-toolchain.toml py-polars/
281+
192282
- name: Build wheel
193283
uses: PyO3/maturin-action@v1
194284
with:

0 commit comments

Comments
 (0)