From a8844843a6751ae77697a731abffc50402cf008e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 26 Jan 2021 23:30:47 +0100 Subject: ci: Also build/publish 32-bit wheels (#26) Closes #25 --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++---- ci/set-target.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 4 deletions(-) create mode 100755 ci/set-target.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61042a8..68e1a10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,8 +41,21 @@ jobs: strategy: fail-fast: false matrix: + rust-toolchain: [1.45, nightly] python-version: [3.6, 3.7, 3.8, 3.9] os: [ubuntu-latest, macos-latest, windows-latest] + architecture: [x86, x64] + exclude: + # Only build 32-bit for Windows + - os: macos-latest + architecture: x86 + - os: ubuntu-latest + architecture: x86 + # Only build on Rust 1.45 on Linux + - os: macos-latest + rust-toolchain: 1.45 + - os: windows-latest + rust-toolchain: 1.45 steps: - name: Checkout @@ -51,22 +64,35 @@ jobs: - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.architecture }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install poetry poetry install - - name: Install latest nightly + + - name: Set Rust target environment variable + run: bash ci/set-target.sh ${{ matrix.os }} ${{ matrix.architecture }} + shell: bash + + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: ${{ matrix.rust-toolchain }} + target: ${{ env.ACTIONS_RUST_TARGET }} override: true - name: Build Python package - run: poetry run maturin develop --release + if: matrix.architecture == 'x86' + run: poetry run maturin build --target ${{ env.ACTIONS_RUST_TARGET }} + + - name: Build Python package + if: matrix.architecture != 'x86' + run: poetry run maturin develop - name: Run Python tests + if: matrix.architecture != 'x86' run: poetry run pytest -vv --color=yes python-publish: @@ -77,17 +103,31 @@ jobs: matrix: python-version: [3.6, 3.7, 3.8, 3.9] os: [ubuntu-latest, macos-latest, windows-latest] + architecture: [x86, x64] + exclude: + # Only build 32-bit for Windows + - os: macos-latest + architecture: x86 + - os: ubuntu-latest + architecture: x86 + steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.architecture }} + + - name: Set Rust target environment variable + run: bash ci/set-target.sh ${{ matrix.os }} ${{ matrix.architecture }} + shell: bash - name: Install latest nightly uses: actions-rs/toolchain@v1 with: toolchain: nightly + target: ${{ env.ACTIONS_RUST_TARGET }} override: true - name: Install dependencies @@ -96,7 +136,7 @@ jobs: pip install poetry poetry install - name: Build Python package - run: poetry run maturin build --release --no-sdist --strip --interpreter python${{matrix.python_version}} + run: poetry run maturin build --release --no-sdist --strip --interpreter python${{matrix.python_version}} --target ${{ env.ACTIONS_RUST_TARGET }} - name: List wheels if: matrix.os == 'windows-latest' diff --git a/ci/set-target.sh b/ci/set-target.sh new file mode 100755 index 0000000..f0dfbf0 --- /dev/null +++ b/ci/set-target.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 OS ARCHITECTURE" >&2 + exit 1 +fi + +os=$1 +architecture=$2 + +output() { + echo "Setting ACTIONS_RUST_TARGET=$1" + echo "ACTIONS_RUST_TARGET=$1" >> "$GITHUB_ENV" + exit 0 +} + +if [ "$architecture" = "x64" ]; then + if [ "$os" = "ubuntu-latest" ]; then + output "x86_64-unknown-linux-gnu" + elif [ "$os" = "macos-latest" ]; then + output "x86_64-apple-darwin" + elif [ "$os" = "windows-latest" ]; then + output "x86_64-pc-windows-msvc" + else + echo "Unknown 64-bit OS: $os" + exit 1 + fi +elif [ "$architecture" = "x86" ]; then + if [ "$os" = "ubuntu-latest" ]; then + output "i686-unknown-linux-gnu" + elif [ "$os" = "windows-latest" ]; then + output "i686-pc-windows-msvc" + else + echo "Unknown 32-bit OS: $os" + exit 1 + fi +else + echo "Bad architecture: $architecture" + exit 1 +fi -- cgit v1.2.3