Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust extension module #101

Merged
merged 26 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
94f31ed
Rust extension module with maturin
ariebovenberg Mar 29, 2024
18a83b4
Make rust extension optional
ariebovenberg Apr 1, 2024
7b81dd6
First classes in rust extension
ariebovenberg Apr 2, 2024
2fc7ccf
Add other datetime types, redesign DateDelta
ariebovenberg Apr 29, 2024
fc2f77f
Improve error handling
ariebovenberg May 20, 2024
a060e69
Add missing methods, improve error handling
ariebovenberg May 28, 2024
7b1d82c
patch up GC/ref handling, 3.13 support
ariebovenberg Jun 10, 2024
5d7ce10
Improve docs, get pure-Python version working again
ariebovenberg Jun 10, 2024
0c39c8c
rationalize method names
ariebovenberg Jun 13, 2024
2e6e53a
fix leftover todos and coverage
ariebovenberg Jun 13, 2024
6cc336c
Fixes for wheels across platforms
ariebovenberg Jun 16, 2024
def6619
fix image link in README
ariebovenberg Jun 19, 2024
3b43929
Additional wheels for other archs
ariebovenberg Jun 19, 2024
a4c0e8f
add flag to see whether rust extension is loaded
ariebovenberg Jun 20, 2024
e5bfa10
additional testing for internal function
ariebovenberg Jun 20, 2024
857caab
add benchmark readme
ariebovenberg Jun 20, 2024
1ef0ab7
docs improvements
ariebovenberg Jun 20, 2024
d517867
small refactorings across extension module
ariebovenberg Jun 20, 2024
9475917
improve robustness of conversions near bounds
ariebovenberg Jun 23, 2024
14876cf
Drop "local" terminolgy from system timezone
ariebovenberg Jun 23, 2024
38cfb27
fix failing tests
ariebovenberg Jun 24, 2024
d93a57f
Replace UTCDateTime with Instant
ariebovenberg Jun 25, 2024
f18b5ba
Rename naive to local, cleanup docs
ariebovenberg Jun 28, 2024
1d4b722
make disambiguate argument required for relevant methods
ariebovenberg Jun 28, 2024
7c35f86
Add ignore_dst and disambiguate arg to relevant methods
ariebovenberg Jun 29, 2024
ce7885a
prepare next release
ariebovenberg Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Additional wheels for other archs
  • Loading branch information
ariebovenberg committed Jun 20, 2024
commit 3b439297340e16c0a30752e5cd942eb5f78a763a
95 changes: 38 additions & 57 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Build and publish wheels

on:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
Expand All @@ -12,90 +10,73 @@ permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-latest
binary:
name: build on ${{ matrix.os }} - (target ${{ matrix.target || 'all' }}) - (filter ${{ matrix.build_only || 'all' }})
strategy:
fail-fast: false # TODO: unset
fail-fast: false
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build wheels
run: |
pip install cibuildwheel==2.17.0
cibuildwheel --output-dir dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: dist/*.whl
include:
- os: windows-latest
- os: macos-latest
- os: ubuntu-latest
target: x86_64
- os: ubuntu-latest
target: i686
- os: ubuntu-latest
target: ppc64le
- os: ubuntu-latest
target: s390x
# parallelized because they are slow
- os: ubuntu-latest
target: aarch64
build_only: 'musllinux'
- os: ubuntu-latest
target: aarch64
build_only: 'manylinux'

windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/setup-python@v5
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
python-version: '3.12'
architecture: ${{ matrix.target }}
- name: Build wheels
run: |
pip install cibuildwheel==2.17.0
cibuildwheel --output-dir dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.target }}
path: dist/*.whl

macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
platforms: all
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build wheels
run: |
pip install cibuildwheel==2.17.0
cibuildwheel --output-dir dist
- run: pip install -U twine cibuildwheel==2.19.1
- run: cibuildwheel --output-dir dist
env:
CIBW_ARCHS: ${{ matrix.target || 'auto' }}
CIBW_BUILD: '*${{ matrix.build_only }}*'
- run: twine check --strict dist/*
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: dist/*.whl
name: wheels-binary-${{ runner.os }}-${{ matrix.target || 'all' }}-${{ matrix.build_only || 'all' }}
path: dist/*

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: |
pip install build
pip install build twine
python -m build --sdist --outdir dist
- run: twine check --strict dist/*
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
path: dist/*

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
needs: [binary, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Rust extension module for whenever"
edition = "2021"
rust-version = "1.78"
license = "MIT"
readme = "README.rst"
readme = "README.md"
keywords = []
include = [
"Cargo.toml",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ init:
.PHONY: typecheck
typecheck:
mypy pysrc/ tests/
pytest typesafety/
pytest --mypy-ini-file=tests/mypy.ini typesafety/

.PHONY: format
format:
Expand Down
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,27 @@ module = [
ignore_missing_imports = true

[tool.cibuildwheel]
skip = ["pp*", "*-musllinux_i686"]
skip = ["pp*", "*-musllinux_i686", "*-musllinux_ppc64le", "*-musllinux_s390x"]
free-threaded-support = true
test-command = "pytest -s {project}/tests"
test-requires = [
"pytest",
"pytest-benchmark",
"hypothesis",
"pytest-mypy-plugins",
]
environment = { PATH = "$HOME/.cargo/bin:$PATH" }

[tool.cibuildwheel.linux]
before-all = "curl -sSf https://sh.rustup.rs | sh -s -- -y"
archs = ["x86_64", "i686", "aarch64", "ppc64le", "s390x"]

[tool.cibuildwheel.windows]
before-all = "rustup target add i686-pc-windows-msvc"
environment = { PATH = "$UserProfile\\.cargo\\bin;$PATH" }

[tool.cibuildwheel.macos]
before-all = "rustup target add x86_64-apple-darwin"
archs = ["x86_64", "arm64"]

[[tool.cibuildwheel.overrides]]
select = "*-musllinux*"
before-all = "curl -sSf https://sh.rustup.rs | sh -s -- -y && apk add tzdata"
Expand Down
3 changes: 0 additions & 3 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[pytest]
addopts=
--mypy-ini-file=tests/mypy.ini

filterwarnings =
error
ignore::DeprecationWarning:dateutil.*
1 change: 0 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pytest>=7,<9
pytest-cov>=4,<6
pytest-benchmark[histogram]>=4,<6
pytest-mypy-plugins>=3,<4
hypothesis>=6,<7

# FUTURE: remove these constraints once rdps-py supports python 3.13
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

import platform
from setuptools import setup
from setuptools_rust import Binding, RustExtension, build_rust

Expand Down Expand Up @@ -27,6 +28,7 @@ def run(self):
rust_extensions=(
[]
if os.getenv("WHENEVER_NO_BUILD_RUST_EXT")
or platform.python_implementation() == "PyPy"
else [RustExtension("whenever._whenever", binding=Binding.PyO3)]
),
cmdclass={"build_rust": CustomBuildExtCommand},
Expand Down