Skip to content

Commit 5c01d00

Browse files
authored
Use Maturin directly for building distributions (#755)
1 parent d1a874d commit 5c01d00

File tree

139 files changed

+556
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+556
-379
lines changed

Diff for: .github/workflows/codspeed.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ jobs:
3535
run: poetry config virtualenvs.create false
3636

3737
- name: Install dependencies
38-
run: poetry install --only test --only benchmark -vvv --no-root
38+
run: poetry install --only test --only benchmark --only build -vvv --no-root
39+
40+
- name: Install project
41+
run: poetry install --only test --only benchmark --only build -vvv --no-root
3942

4043
- name: Install pendulum and check extensions
4144
run: |
42-
MATURIN_BUILD_ARGS="--no-default-features -vv" pip install -e . -v
43-
python -c 'import _pendulum; assert _pendulum.__pendulum_default_allocator__'
45+
poetry run pip install -e . -vvv
46+
python -c 'import pendulum._pendulum'
4447
4548
- name: Run benchmarks
4649
uses: CodSpeedHQ/action@v1

Diff for: .github/workflows/release.yml

+71-66
Original file line numberDiff line numberDiff line change
@@ -7,91 +7,99 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
11-
build_wheels:
12-
name: Build wheels on ${{ matrix.os }}
13-
runs-on: ${{ matrix.os }}-latest
10+
build:
11+
name: Build on ${{ matrix.platform || matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }})
1412
strategy:
13+
fail-fast: false
1514
matrix:
16-
os: [ ubuntu, windows, macos ]
15+
os: [ubuntu, macos, windows]
16+
target: [x86_64, aarch64]
17+
manylinux: [auto]
18+
include:
19+
- os: ubuntu
20+
platform: linux
21+
- os: windows
22+
ls: dir
23+
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10
24+
- os: windows
25+
ls: dir
26+
target: aarch64
27+
interpreter: 3.11 3.12
28+
- os: macos
29+
target: aarch64
30+
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10
31+
- os: ubuntu
32+
platform: linux
33+
target: aarch64
34+
# mimalloc not supported on manylinux2014 cross-compile container
35+
extra-build-args: --no-default-features
36+
# musllinux
37+
- os: ubuntu
38+
platform: linux
39+
target: x86_64
40+
manylinux: musllinux_1_1
41+
- os: ubuntu
42+
platform: linux
43+
target: aarch64
44+
manylinux: musllinux_1_1
45+
- os: ubuntu
46+
platform: linux
47+
target: ppc64le
48+
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12
49+
# mimalloc not supported on manylinux2014 cross-compile container
50+
extra-build-args: --no-default-features
51+
- os: ubuntu
52+
platform: linux
53+
target: s390x
54+
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12
55+
# mimalloc not supported on manylinux2014 cross-compile container
56+
extra-build-args: --no-default-features
1757

58+
runs-on: ${{ matrix.os }}-latest
1859
steps:
19-
- uses: actions/checkout@v3
60+
- uses: actions/checkout@v4
2061

21-
- name: Set up rust
22-
uses: dtolnay/rust-toolchain@stable
62+
- name: set up python
63+
uses: actions/setup-python@v4
2364
with:
24-
toolchain: stable
65+
python-version: '3.11'
66+
architecture: ${{ matrix.python-architecture || 'x64' }}
2567

26-
- name: Setup Rust cache
27-
uses: Swatinem/rust-cache@v2
68+
- name: build wheels
69+
uses: PyO3/maturin-action@v1
2870
with:
29-
key: ${{ matrix.os }}
71+
target: ${{ matrix.target }}
72+
manylinux: ${{ matrix.manylinux || 'auto' }}
73+
container: ${{ matrix.container }}
74+
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.7 3.8 3.9 3.10 3.11 3.12 pypy3.7 pypy3.8 pypy3.9 pypy3.10' }} ${{ matrix.extra-build-args }}
75+
rust-toolchain: stable
76+
docker-options: -e CI
3077

31-
- name: Set up QEMU
32-
if: runner.os == 'Linux'
33-
uses: docker/setup-qemu-action@v2
34-
with:
35-
platforms: all
36-
37-
- name: Build wheels
38-
uses: pypa/[email protected]
39-
env:
40-
CIBW_ARCHS_LINUX: auto aarch64
41-
CIBW_ARCHS_MACOS: x86_64
42-
CIBW_ARCHS_WINDOWS: AMD64
43-
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
44-
with:
45-
package-dir: .
46-
output-dir: dist
78+
- run: ${{ matrix.ls || 'ls -lh' }} dist/
4779

4880
- uses: actions/upload-artifact@v3
4981
with:
5082
name: dist
51-
path: ./dist/*
52-
53-
build_wheels_macos_arm:
54-
name: Build arm64 wheels on ${{ matrix.os }}
55-
runs-on: ${{ matrix.os }}
56-
strategy:
57-
matrix:
58-
os: [ macos-12 ]
83+
path: dist
5984

85+
build_sdist:
86+
runs-on: ubuntu-latest
6087
steps:
6188
- uses: actions/checkout@v3
62-
63-
- name: Set up rust
64-
uses: dtolnay/rust-toolchain@stable
89+
- name: Build sdist
90+
uses: PyO3/maturin-action@v1
6591
with:
66-
toolchain: stable
67-
68-
- name: Setup Rust cache
69-
uses: Swatinem/rust-cache@v2
70-
with:
71-
key: ${{ matrix.os }}
72-
73-
- name: Build wheels
74-
uses: pypa/[email protected]
75-
env:
76-
CIBW_ARCHS_MACOS: arm64
77-
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
78-
with:
79-
package-dir: .
80-
output-dir: dist
81-
82-
- name: Fix wheel tags
83-
run: |
84-
python3 -m pip install wheel
85-
python3 -m wheel tags --platform-tag macosx_12_0_arm64 dist/*-macosx*.whl --remove
86-
87-
- uses: actions/upload-artifact@v3
92+
command: sdist
93+
args: --out dist
94+
- name: Upload sdist
95+
uses: actions/upload-artifact@v3
8896
with:
8997
name: dist
90-
path: ./dist/*
98+
path: dist
9199

92100

93101
Release:
94-
needs: [ build_wheels, build_wheels_macos_arm ]
102+
needs: [ build, build_sdist ]
95103
if: success() && startsWith(github.ref, 'refs/tags/')
96104
runs-on: ubuntu-latest
97105

@@ -112,9 +120,6 @@ jobs:
112120
- name: Update PATH
113121
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
114122

115-
- name: Build sdist
116-
run: poetry build --format sdist
117-
118123
- name: Check distributions
119124
run: |
120125
ls -la dist

Diff for: .github/workflows/tests.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,17 @@ jobs:
8080
run: timeout 10s poetry run pip --version || rm -rf .venv
8181

8282
- name: Install runtime, testing, and typing dependencies
83-
run: poetry install --only main --only test --only typing -vvv
83+
run: poetry install --only main --only test --only typing --only build --no-root -vvv
84+
85+
- name: Install project
86+
run: poetry run maturin develop
8487

8588
- name: Run type checking
8689
run: poetry run mypy
8790

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

9295
- name: Test Pure Python
9396
run: |

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ setup.py
3636

3737
.vscode
3838
/target
39+
/rust/target

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: black
1818

1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.0.283
20+
rev: v0.0.291
2121
hooks:
2222
- id: ruff
2323

Diff for: Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ list:
99
no_targets__:
1010

1111
lint-rust:
12-
cargo fmt --all -- --check
13-
cargo clippy --tests -- -D warnings
12+
cd rust && cargo fmt --all -- --check
13+
cd rust && cargo clippy --tests -- -D warnings
1414

1515

1616
format-rust:
17-
cargo fmt --all
18-
cargo clippy --tests --fix --allow-dirty -- -D warnings
17+
cd rust && cargo fmt --all
18+
cd rust && cargo clippy --tests --fix --allow-dirty -- -D warnings

Diff for: build.py

-56
This file was deleted.

0 commit comments

Comments
 (0)