Skip to content

Commit

Permalink
feat: support arm64 linux & use maturin (#263)
Browse files Browse the repository at this point in the history
* feat: python 3.12 support; switch to maturin
  • Loading branch information
Mokto authored Sep 13, 2024
1 parent 6b0c253 commit 600cbe8
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 820 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.47
current_version = 0.1.48
commit = True
tag = True

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/build-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e -x

for PYBIN in /opt/python/cp3[5678]*/bin; do
"${PYBIN}/pip" install maturin
"${PYBIN}/maturin" build -i "${PYBIN}/python" --release
done

for wheel in target/wheels/*.whl; do
auditwheel repair "${wheel}"
done
96 changes: 96 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: publish-pypi

on:
push:
tags:
- 'v*'

jobs:
linux-wheels:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, i686, aarch64]
steps:
- uses: actions/checkout@v3
- uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
maturin-version: latest
command: build
manylinux: auto
args: --release --sdist -i 3.8 3.9 3.10 3.11 3.12
- uses: actions/upload-artifact@v4
with:
name: linux-wheels-${{ matrix.target }}
path: target/wheels/

osx-wheels:
runs-on: macos-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Build wheels
run: |
python3 -m pip install maturin
maturin build --release
- uses: actions/upload-artifact@v4
with:
name: osx-${{ matrix.python-version }}-wheel
path: target/wheels

windows-wheels:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true
- uses: actions/setup-python@v2
- name: Build wheels
run: |
python -m pip install maturin
maturin build --release
- uses: actions/upload-artifact@v4
with:
name: windows-wheels
path: target/wheels

push:
needs: [osx-wheels, windows-wheels, linux-wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v4

- name: Display structure of downloaded files
run: ls -R

- run: mkdir wheels
- run: mv ./linux-wheels-x86_64/* wheels
- run: mv ./linux-wheels-i686/* wheels
- run: mv ./linux-wheels-aarch64/* wheels
- run: mv ./osx-3.12-wheel/* wheels
- run: mv ./osx-3.11-wheel/* wheels
- run: mv ./osx-3.10-wheel/* wheels
- run: mv ./osx-3.9-wheel/* wheels
- run: mv ./osx-3.8-wheel/* wheels
- run: mv ./windows-wheels/* wheels


- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI }}
packages_dir: wheels/
verify_metadata: false
138 changes: 0 additions & 138 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,141 +38,3 @@ jobs:
with:
command: test
toolchain: stable

native-build:
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.3.2
- name: Install package deps
run: |
poetry install
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install Rust aarch64-apple-darwin target
if: matrix.os == 'macos-latest'
run: rustup target add aarch64-apple-darwin

- name: Install Rust x86_64-apple-darwin
if: matrix.os == 'macos-latest'
run: rustup target add x86_64-apple-darwin

- name: Build on macOS universal2
if: matrix.os == 'macos-latest'
shell: bash
env:
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
MACOSX_DEPLOYMENT_TARGET: "10.15"
ARCHFLAGS: -arch x86_64 -arch arm64
# PYO3_CROSS_LIB_DIR: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/${{ matrix.python-version }}/lib
PYO3_CROSS_PYTHON_VERSION: ${{ matrix.python-version }}
run: poetry run python setup.py bdist_wheel && poetry install

- name: Build Python package
if: matrix.os != 'macos-latest'
run: poetry run python setup.py bdist_wheel && poetry install

- name: pytest
run: poetry run pytest tests

- name: archive wheels
uses: actions/upload-artifact@v2
if: matrix.os != 'ubuntu-latest'
with:
name: wheels
path: dist/*.whl

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && matrix.os != 'ubuntu-latest'
with:
files: dist/sqloxide*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

manylinux-build:
if: true
strategy:
fail-fast: false
matrix:
include:
- { tag: manylinux2014, arch: x86_64 }
- { tag: manylinux2014, arch: i686 }
# TODO: figure out a way to renable these, for now far too slow
# to run in github actions (> 6hrs)
# - {tag: manylinux2014, arch: ppc64le}
# - {tag: manylinux2014, arch: aarch64}
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v2
with:
path: io

- name: Set up QEMU for multi-arch build
uses: docker/setup-qemu-action@v1

- name: Build Wheels
run: >-
docker run --rm
-e PLAT=${{ matrix.tag }}_${{ matrix.arch }}
-e PACKAGE_NAME=sqloxide
-v `pwd`:/io
--workdir /io
quay.io/pypa/${{ matrix.tag }}_${{ matrix.arch }}
io/build-wheels.sh
- name: Archive Wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: io/dist/*${{ matrix.tag }}_${{ matrix.arch }}.whl

source-build:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v2
- name: Build source distribution
run: |
pip install -U setuptools wheel setuptools-rust
python setup.py sdist
- name: Archive source distribution
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist/*

publish:
runs-on: ubuntu-latest
needs: [manylinux-build, native-build, source-build]
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
with:
user: __token__
password: ${{ secrets.PYPI }}
skip_existing: true
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "sqloxide"
version = "0.1.47"
version = "0.1.48"
authors = ["Will Eaton <[email protected]>"]
edition = "2018"
edition = "2021"

[lib]
name = "sqloxide"
Expand Down
17 changes: 0 additions & 17 deletions build-wheels.sh

This file was deleted.

12 changes: 0 additions & 12 deletions build.py

This file was deleted.

Loading

0 comments on commit 600cbe8

Please sign in to comment.