mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-22 23:49:58 +00:00
4
.github/workflows/CI.Dockerfile
vendored
Normal file
4
.github/workflows/CI.Dockerfile
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM ubuntu:latest
|
||||
RUN apt update && apt install openssl libssl-dev curl pkg-config software-properties-common -y && add-apt-repository ppa:deadsnakes/ppa && apt update && apt install python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13 python3-pip python3 -y
|
||||
ENV PIP_BREAK_SYSTEM_PACKAGES=1
|
||||
RUN mkdir -p /root/.cache/sbv2 && curl https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin -o /root/.cache/sbv2/all.bin -L
|
||||
47
.github/workflows/CI.yml
vendored
47
.github/workflows/CI.yml
vendored
@@ -1,40 +1,35 @@
|
||||
# This file is autogenerated by maturin v1.7.1
|
||||
# To update, run
|
||||
#
|
||||
# maturin generate-ci github
|
||||
#
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
tags:
|
||||
- '*'
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
contents: write
|
||||
id-token: write
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
python-linux:
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- runner: ubuntu-latest
|
||||
target: x86_64
|
||||
- runner: ubuntu-latest
|
||||
- runner: ubuntu-24.04-arm
|
||||
target: aarch64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
- run: docker build . -f .github/workflows/CI.Dockerfile --tag ci
|
||||
- name: Build wheels
|
||||
uses: PyO3/maturin-action@v1
|
||||
with:
|
||||
@@ -42,6 +37,7 @@ jobs:
|
||||
args: --release --out dist --find-interpreter
|
||||
sccache: 'true'
|
||||
manylinux: auto
|
||||
container: ci
|
||||
working-directory: ./crates/sbv2_bindings
|
||||
- name: Upload wheels
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -49,7 +45,7 @@ jobs:
|
||||
name: wheels-linux-${{ matrix.platform.target }}
|
||||
path: ./crates/sbv2_bindings/dist
|
||||
|
||||
windows:
|
||||
python-windows:
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -75,7 +71,7 @@ jobs:
|
||||
name: wheels-windows-${{ matrix.platform.target }}
|
||||
path: ./crates/sbv2_bindings/dist
|
||||
|
||||
macos:
|
||||
python-macos:
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -100,7 +96,7 @@ jobs:
|
||||
name: wheels-macos-${{ matrix.platform.target }}
|
||||
path: ./crates/sbv2_bindings/dist
|
||||
|
||||
sdist:
|
||||
python-sdist:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -115,22 +111,37 @@ jobs:
|
||||
with:
|
||||
name: wheels-sdist
|
||||
path: ./crates/sbv2_bindings/dist
|
||||
python-wheel:
|
||||
name: Wheel Upload
|
||||
runs-on: ubuntu-latest
|
||||
needs: [python-linux, python-windows, python-macos, python-sdist]
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: gh run download ${{ github.run_id }} -p wheels-*
|
||||
- name: release
|
||||
run: |
|
||||
gh release create commit-${GITHUB_SHA:0:8} --prerelease wheels-*/*
|
||||
|
||||
release:
|
||||
python-release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
if: "startsWith(github.ref, 'refs/tags/')"
|
||||
needs: [linux, windows, macos, sdist]
|
||||
needs: [python-linux, python-windows, python-macos, python-sdist]
|
||||
environment: release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/checkout@v4
|
||||
- run: gh run download ${{ github.run_id }} -p wheels-*
|
||||
- name: Publish to PyPI
|
||||
uses: PyO3/maturin-action@v1
|
||||
with:
|
||||
command: upload
|
||||
args: --non-interactive --skip-existing wheels-*/*
|
||||
|
||||
build:
|
||||
docker:
|
||||
runs-on: ${{ matrix.machine.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -177,10 +188,10 @@ jobs:
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository }}:latest-${{ matrix.tag }}-${{ matrix.machine.platform }}
|
||||
|
||||
merge:
|
||||
docker-merge:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build
|
||||
- docker
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
39
Cargo.lock
generated
39
Cargo.lock
generated
@@ -462,6 +462,27 @@ dependencies = [
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
@@ -1695,6 +1716,12 @@ dependencies = [
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "ort"
|
||||
version = "2.0.0-rc.9"
|
||||
@@ -2063,6 +2090,17 @@ dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
|
||||
dependencies = [
|
||||
"getrandom 0.2.15",
|
||||
"libredox",
|
||||
"thiserror 2.0.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
@@ -2254,6 +2292,7 @@ version = "0.2.0-alpha6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"dirs",
|
||||
"dotenvy",
|
||||
"env_logger",
|
||||
"hound",
|
||||
|
||||
@@ -43,4 +43,5 @@ aivmx = ["npyz", "base64"]
|
||||
base64 = ["dep:base64"]
|
||||
|
||||
[build-dependencies]
|
||||
dirs = "6.0.0"
|
||||
ureq = "3.0.6"
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
use dirs::home_dir;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::io::copy;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let out_dir = env::var("OUT_DIR")?;
|
||||
let out_path = Path::new(&out_dir).join("all.bin");
|
||||
if !out_path.exists() {
|
||||
let static_path = home_dir().unwrap().join(".cache/sbv2/all.bin");
|
||||
let out_path = PathBuf::from(&env::var("OUT_DIR").unwrap()).join("all.bin");
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
if static_path.exists() {
|
||||
if fs::hard_link(&static_path, &out_path).is_err() {
|
||||
fs::copy(static_path, out_path).unwrap();
|
||||
};
|
||||
} else {
|
||||
println!("cargo:warning=Downloading dictionary file...");
|
||||
let mut response =
|
||||
ureq::get("https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin")
|
||||
@@ -15,6 +21,5 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut file = fs::File::create(&out_path)?;
|
||||
copy(&mut response, &mut file)?;
|
||||
}
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user