Skip to content

Commit

Permalink
DO NOT MERGE: Testing maturin
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed Oct 18, 2024
1 parent 04f51ba commit 0acc9c0
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 62 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/maturin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This file is autogenerated by maturin v1.7.4 and manually modified by ia0.
name: CI

on:
pull_request:

permissions:
contents: read

jobs:
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out=../dist
before-script-linux: "${{ github.workspace }}/rust/onnx/maturin.sh"
manylinux: 2_28
working-directory: python
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist

windows:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out=../dist
working-directory: python
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.platform.target }}
path: dist

macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-12
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out=../dist
working-directory: python
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist
2 changes: 0 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ 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.
Expand Down
65 changes: 25 additions & 40 deletions rust/cli/Cargo.lock

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

6 changes: 5 additions & 1 deletion rust/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ clap = { version = "4.5.9", features = ["cargo", "derive", "string"] }
colored = "2.1.0"
magika = { version = "=0.1.0-rc.1", path = "../lib", features = ["serde"] }
num_cpus = "1.16.0"
ort = "2.0.0-rc.5"
ort = "2.0.0-rc.6"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
tokio = { version = "1.38.1", features = ["full"] }

# TODO: Temporary until 2.0.0-rc.7 is released.
[patch.crates-io.ort]
git = "https://github.com/pykeio/ort.git"
23 changes: 5 additions & 18 deletions rust/lib/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ thiserror = "1.0.63"
tokio = { version = "1.38.1", features = ["fs", "io-util"] }

[dependencies.ort]
version = "2.0.0-rc.5"
version = "2.0.0-rc.6"
default-features = false
features = ["ndarray"]

Expand Down
1 change: 1 addition & 0 deletions rust/onnx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/runtime/
47 changes: 47 additions & 0 deletions rust/onnx/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
. ../color.sh

# This script builds ONNX Runtime as a static library to be linked in the Magika CLI.
#
# This is needed when building for manylinux since the prebuilt binaries provided by the ort crate
# have too recent dependency requirements.

[ -e runtime ] && error "This script can only be run once."

info "Make sure we have Python 3.x and cmake-3.27 or higher."
python3 -m venv venv
source venv/bin/activate
python3 -m pip install cmake

info "Clone ONNX Runtime repository (recursively)."
git clone --recursive https://github.com/Microsoft/onnxruntime.git runtime
cd runtime

info "We checkout v1.19.2 because that's what ort v2.0.0-rc.7 supports."
git checkout v1.19.2

info "Build the static library."
./build.sh --config=Release --parallel $ONNX_RUNTIME_BUILD_FLAGS

info "Point the ort crate to the locally built static library."
cd ../../..
cat >> .cargo/config.toml <<EOF
[env]
ORT_LIB_LOCATION = "$PWD/rust/onnx/runtime/build/Linux"
EOF
Loading

0 comments on commit 0acc9c0

Please sign in to comment.