Skip to content

Commit

Permalink
Use Maturin to ship the Rust CLI in the Python package (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 authored Sep 12, 2024
1 parent 7a8da11 commit a7676e3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/maturin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file is was initially generated by maturin generate-ci github, then heavily simplified.

name: Maturin

on:
push:
branches:
- 'main'
tags:
- 'rust-v*'
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: ${{ matrix.conf.name }}
runs-on: ${{ matrix.conf.runner }}
strategy:
matrix:
conf:
- name: linux
runner: ubuntu-latest
command: build
args: --release --out=../dist
- name: windows
runner: windows-latest
command: build
args: --release --out=../dist
- name: macos
runner: macos-latest
command: build
args: --release --out=../dist
# TODO(https://github.com/PyO3/maturin/issues/2154): Re-enable when fixed.
# - name: sdist
# runner: ubuntu-latest
# command: sdist
# args: --out=../dist
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
command: ${{ matrix.conf.command }}
container: off # The build fails in containers.
working-directory: python
args: ${{ matrix.conf.args }}
- name: Upload wheels
if: "startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.conf.name }}
path: dist
13 changes: 11 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ dev-dependencies = [
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
requires = ["maturin>=1.7,<2.0"]
build-backend = "maturin"

[tool.hatch.version]
path = "src/magika/__init__.py"

[tool.maturin]
python-source = "src"
module-name = "magika"
bindings = "bin"
manifest-path = "../rust/cli/Cargo.toml"
locked = true
compatibility = "linux"
skip-auditwheel = true

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
Expand Down

0 comments on commit a7676e3

Please sign in to comment.