Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
228 changes: 228 additions & 0 deletions .github/workflows/kernels_data_python_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# This file is autogenerated by maturin v1.13.1
# To update, run
#
# maturin generate-ci github -m kernels-data/bindings/python/Cargo.toml -o .github/workflows/kernels_data_python_release.yaml
#
# Post-generation edits:
# - manifest paths made relative
# - publish step switched from `uv publish` + API token to
# `PyO3/maturin-action` + PyPI trusted publishing (see plan.md §3a, §3b)
# - pull_request trigger gained `paths-ignore` for docs-only PRs
name: CI

on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
paths-ignore:
- "docs/**"
- "*.md"
workflow_dispatch:

permissions:
contents: read

jobs:
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-22.04
target: x86_64
- runner: ubuntu-22.04
target: x86
- runner: ubuntu-22.04
target: aarch64
- runner: ubuntu-22.04
target: armv7
- runner: ubuntu-22.04
target: s390x
- runner: ubuntu-22.04
target: ppc64le
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.8
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: auto
- name: Build free-threaded wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml -i python3.14t
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

musllinux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-22.04
target: x86_64
- runner: ubuntu-22.04
target: x86
- runner: ubuntu-22.04
target: aarch64
- runner: ubuntu-22.04
target: armv7
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.8
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: musllinux_1_2
- name: Build free-threaded wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml -i python3.14t
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: musllinux_1_2
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: dist

windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
python_arch: x64
- runner: windows-latest
target: x86
python_arch: x86
- runner: windows-11-arm
target: aarch64
python_arch: arm64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.13
architecture: ${{ matrix.platform.python_arch }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: actions/setup-python@v6
with:
python-version: 3.14t
architecture: ${{ matrix.platform.python_arch }}
- name: Build free-threaded wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml -i python3.14t
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-15-intel
target: x86_64
- runner: macos-latest
target: aarch64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.8
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- uses: actions/setup-python@v6
with:
python-version: 3.14t
- name: Build free-threaded wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --manifest-path kernels-data/bindings/python/Cargo.toml -i python3.14t
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path kernels-data/bindings/python/Cargo.toml
- name: Upload sdist
uses: actions/upload-artifact@v6
with:
name: wheels-sdist
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
needs: [linux, musllinux, windows, macos, sdist]
environment:
name: pypi
url: https://pypi.org/p/kernels-data
permissions:
# Use to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
steps:
- uses: actions/download-artifact@v7
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-path: 'wheels-*/*'
- name: Publish to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: PyO3/maturin-action@v1
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*
8 changes: 6 additions & 2 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
( cd kernel-abi-check/kernel-abi-check && cargo fmt --all -- --check )
( cd kernel-abi-check/bindings/python && cargo fmt --all -- --check )
- name: Cargo fmt (kernels-data)
run: ( cd kernels-data && cargo fmt --all -- --check )
run: |
( cd kernels-data && cargo fmt --all -- --check )
( cd kernels-data/bindings/python && cargo fmt --all -- --check )
- name: Cargo fmt (kernel-builder)
run: ( cd kernel-builder && cargo fmt --all -- --check )

Expand All @@ -42,6 +44,8 @@ jobs:
( cd kernel-abi-check/kernel-abi-check && cargo clippy -- -D warnings )
( cd kernel-abi-check/bindings/python && cargo clippy -- -D warnings )
- name: Clippy (kernels-data)
run: ( cd kernels-data && cargo clippy -- -D warnings )
run: |
( cd kernels-data && cargo clippy -- -D warnings )
( cd kernels-data/bindings/python && cargo clippy -- -D warnings )
- name: Clippy (kernel-builder)
run: ( cd kernel-builder && cargo clippy -- -D warnings )
32 changes: 30 additions & 2 deletions .github/workflows/test_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ concurrency:
cancel-in-progress: true

jobs:
build:
name: Run tests
kernel-abi-check:
name: kernel-abi-check bindings
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -40,3 +40,31 @@ jobs:

- name: Run tests
run: ( cd kernel-abi-check/bindings/python && uv run pytest tests )

kernels-data:
name: kernels-data bindings
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]

env:
UV_PYTHON_PREFERENCE: only-managed

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install the project
run: ( cd kernels-data/bindings/python && uv sync --all-extras --dev)

- name: Run tests
run: ( cd kernels-data/bindings/python && uv run pytest tests )

- name: Check type stubs match runtime
run: ( cd kernels-data/bindings/python && uv run python -m mypy.stubtest kernels_data --allowlist stubtest-allowlist.txt )
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ members = [
"kernel-abi-check/bindings/python",
"kernel-builder",
"kernels-data",
"kernels-data/bindings/python",
]
resolver = "2"
18 changes: 18 additions & 0 deletions kernels-data/bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "kernels-data-python"
version = "0.0.1"
edition = "2024"
description = "Kernels data structures (Python bindings)"
homepage = "https://github.com/huggingface/kernels"
license = "Apache-2.0"
repository = "https://github.com/huggingface/kernels"

[lib]
name = "kernels_data"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.26", features = ["abi3", "abi3-py38"] }

[dependencies.kernels-data]
path = "../.."
4 changes: 4 additions & 0 deletions kernels-data/bindings/python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include Cargo.toml
include pyproject.toml
include ../../../LICENSE
recursive-include src *
Loading
Loading