Skip to content

Commit

Permalink
Use Maturin directly for building distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Sep 30, 2023
1 parent d1a874d commit bd9fcf2
Show file tree
Hide file tree
Showing 139 changed files with 542 additions and 372 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
run: poetry config virtualenvs.create false

- name: Install dependencies
run: poetry install --only test --only benchmark -vvv --no-root
run: poetry install --only test --only benchmark --only build -vvv --no-root

- name: Install pendulum and check extensions
run: |
MATURIN_BUILD_ARGS="--no-default-features -vv" pip install -e . -v
poetry run maturin develop --no-default-features -vv
python -c 'import _pendulum; assert _pendulum.__pendulum_default_allocator__'
- name: Run benchmarks
Expand Down
123 changes: 62 additions & 61 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,91 @@ on:
workflow_dispatch:

jobs:

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
linux:
name: Build wheels on Linux - ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu, windows, macos ]

target: [x86_64, aarch64, armv7]
steps:
- uses: actions/checkout@v3

- name: Set up rust
uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v4
with:
toolchain: stable

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
key: ${{ matrix.os }}

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
platforms: all
name: dist
path: dist

windows:
name: Build wheels on Windows - ${{ matrix.target }}
runs-on: windows-latest
strategy:
matrix:
target: [x64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: auto aarch64
CIBW_ARCHS_MACOS: x86_64
CIBW_ARCHS_WINDOWS: AMD64
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
uses: PyO3/maturin-action@v1
with:
package-dir: .
output-dir: dist

- uses: actions/upload-artifact@v3
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/*
path: dist

build_wheels_macos_arm:
name: Build arm64 wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
macos:
name: Build wheels on MacOS - ${{ matrix.target }}
runs-on: macos-latest
strategy:
matrix:
os: [ macos-12 ]

target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3

- name: Set up rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v4
with:
key: ${{ matrix.os }}

python-version: '3.10'
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: arm64
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
uses: PyO3/maturin-action@v1
with:
package-dir: .
output-dir: dist

- name: Fix wheel tags
run: |
python3 -m pip install wheel
python3 -m wheel tags --platform-tag macosx_12_0_arm64 dist/*-macosx*.whl --remove
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

- uses: actions/upload-artifact@v3
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/*
path: dist


Release:
Expand All @@ -112,9 +116,6 @@ jobs:
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Build sdist
run: poetry build --format sdist

- name: Check distributions
run: |
ls -la dist
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ jobs:
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install runtime, testing, and typing dependencies
run: poetry install --only main --only test --only typing -vvv
run: poetry install --only main --only test --only typing --only build --no-root -vvv

- name: Install project
run: poetry run maturin develop

- name: Run type checking
run: poetry run mypy

- name: Uninstall typing dependencies
# This ensures pendulum runs without typing_extensions installed
run: poetry install --only main --only test --sync --no-root -vvv
run: poetry install --only main --only test --only build --sync --no-root -vvv

- name: Test Pure Python
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ setup.py

.vscode
/target
/rust/target
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.283
rev: v0.0.291
hooks:
- id: ruff

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ list:
no_targets__:

lint-rust:
cargo fmt --all -- --check
cargo clippy --tests -- -D warnings
cd rust && cargo fmt --all -- --check
cd rust && cargo clippy --tests -- -D warnings


format-rust:
cargo fmt --all
cargo clippy --tests --fix --allow-dirty -- -D warnings
cd rust && cargo fmt --all
cd rust && cargo clippy --tests --fix --allow-dirty -- -D warnings
56 changes: 0 additions & 56 deletions build.py

This file was deleted.

Loading

0 comments on commit bd9fcf2

Please sign in to comment.