ci(python): Split Python release into build / release jobs #31
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Python | |
on: | |
pull_request: | |
workflow_dispatch: | |
push: | |
tags: | |
- py-* | |
env: | |
RUST_TOOLCHAIN: nightly-2023-08-26 | |
PYTHON_VERSION: '3.8' | |
MATURIN_VERSION: '1.2.3' | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build-wheels: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
cpu: x86-64 | |
sdist: true | |
- os: ubuntu-latest | |
cpu: aarch64 | |
- os: macos-latest | |
cpu: x86-64 | |
- os: macos-latest | |
cpu: aarch64 | |
- os: windows-latest | |
cpu: x86-64 | |
- os: ubuntu-latest | |
cpu: x86-64 | |
lts-cpu: true | |
sdist: true | |
- os: ubuntu-latest | |
cpu: x86-64 | |
u64-idx: true | |
sdist: true | |
steps: | |
- uses: actions/checkout@v3 | |
# Avoid potential out-of-memory errors | |
- name: Set swap space for Linux | |
if: matrix.os == 'ubuntu-latest' | |
uses: pierotofy/set-swap-space@master | |
with: | |
swap-size-gb: 10 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Fix README symlink | |
run: | | |
rm py-polars/README.md | |
cp README.md py-polars/README.md | |
- name: Prepare lts-cpu | |
if: matrix.lts-cpu | |
run: sed -i 's/name = "polars"/name = "polars-lts-cpu"/' py-polars/pyproject.toml | |
- name: Prepare u64-idx | |
if: matrix.u64-idx | |
run: | | |
sed -i 's/name = "polars"/name = "polars-u64-idx"/' py-polars/pyproject.toml | |
# A brittle hack to insert the 'bigidx' feature | |
sed -i 's/"dynamic_group_by",/"dynamic_group_by",\n"bigidx",/' py-polars/Cargo.toml | |
- name: Set RUSTFLAGS for x86-64 | |
if: matrix.cpu == 'x86-64' && !matrix.lts-cpu | |
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" >> $GITHUB_ENV | |
- name: Set RUSTFLAGS for x86-64 LTS CPU | |
if: matrix.cpu == 'x86-64' && matrix.lts-cpu | |
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt --cfg use_mimalloc" >> $GITHUB_ENV | |
- name: Set Rust target for aarch64 | |
if: matrix.cpu == 'aarch64' | |
id: target | |
run: | | |
TARGET=${{ matrix.os == 'macos-latest' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu'}} | |
echo "target=$TARGET" >> $GITHUB_OUTPUT | |
- name: Set jemalloc for aarch64 Linux | |
if: matrix.cpu == 'aarch64' && matrix.os == 'ubuntu-latest' | |
run: | | |
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV | |
- name: Build wheel | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: build | |
target: ${{ steps.target.outputs.target }} | |
working-directory: py-polars | |
args: ${{ matrix.sdist && '--sdist' || ''}} # --release | |
maturin-version: ${{ env.MATURIN_VERSION }} | |
rust-toolchain: ${{ env.RUST_TOOLCHAIN }} | |
manylinux: auto | |
- name: Upload wheel | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: py-polars/target/wheels/* | |
publish-to-pypi: | |
needs: build-wheels | |
environment: | |
name: release-python | |
url: https://pypi.org/project/polars | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true | |
repository-url: https://test.pypi.org |