aria-engine (Python)
aria-engine 是 Aria 推理引擎的 Python SDK(ctypes 封装 libaria_ffi)。
通过 PyPI 安装的 平台 wheel 内已捆绑动态库,开箱即用,无需手动设置环境变量。
安装(PyPI 发布版)
pip install aria-engine
支持 Linux (x86_64 / aarch64 manylinux)、macOS (x86_64 / arm64)、Windows (x86_64), Python 3.10+。wheel 内自带
libaria_ffi.so/.dylib/.dll。
用法
from aria_engine import Engine
with Engine("/path/to/bundle") as eng:
print(eng.complete([{"role":"user","content":"hi"}], {"max_tokens": 16}))
按模型名自动下载
Engine 同时接受本地 bundle 路径或 Aria 模型名(如 gemma-4-e2b-it_q4)。含 /
或本地已存在的值直接加载;否则由 SDK 从本区公开 hub 自动下载(.com → Hugging Face,
.cn → ModelScope;site 默认 https://ariacompute.com)到 ~/.ariacompute/models/{model} 再加载。
不再请求 Dashboard(避免 HTTP 403)。需授权的 hub 文件请传入 hf_token(.com)或
modelscope_api_token(.cn),字段名与 aria-engine setup 相同;未传则读
~/.ariacompute/engine.yml。Dashboard sk- / bfvk- token 不会当作 hub 凭证。
不读环境变量 HF_TOKEN / MODELSCOPE_API_TOKEN。
缓存中已有有效 bundle 时直接复用,不重复下载。
with Engine("gemma-4-e2b-it_q4") as eng:
print(eng.complete([{"role":"user","content":"hi"}], {"max_tokens": 16}))
# Gated Hugging Face files (instance setup; does not write engine.yml):
eng = Engine()
eng.setup(hf_token="hf_...")
eng.open("gemma-4-e2b-it_q4")
print(eng.complete([{"role":"user","content":"hi"}], {"max_tokens": 16}))
Engine.setup sets Config / Run fields on that instance only. CLI aria-engine setup still writes ~/.ariacompute/engine.yml; the SDK never does. Empty fields still fall back to reading that file for hub download. Also: eng.setup_status(), eng.setup_clear().
动态库查找顺序
_load_lib() 按以下顺序解析:
- 显式传入的
path - 环境变量
ARIA_FFI_LIB(源码安装 / 自定义路径时使用) - wheel 内捆绑的
aria_engine/lib/<libaria_ffi.so|dylib|dll> ~/.ariacompute/lib/(与aria-engine upgrade相同目录)- 都找不到 → 从本区 Releases 下载最新正式版
libaria_ffi_{ver}_{os}.tar.gz解压到~/.ariacompute/lib/(upgrade_url优先;否则.com→ GitHub,.cn→ Gitee)。失败明确报错。
aria-engine download 只拉模型 bundle,不会装 FFI;Python SDK 在 Engine(...) 加载前自动补齐。
源码安装(开发)
export ARIA_FFI_LIB=/path/to/libaria_ffi.so
pip install -e .
构建 wheel(cibuildwheel)
bash scripts/build-python-ffi.sh # 编译 libaria_ffi 并拷入 aria_engine/lib/
pip install cibuildwheel
cibuildwheel --platform linux # 或 macos / windows
发布到 PyPI
GitHub Release 触发 .github/workflows/publish-pypi.yml:五平台构建 + twine upload。
需要仓库 Secret PYPI_TOKEN(PyPI API token,project-scoped,owner ariacompute)。
版本号取 tag 去 v(也支持 workflow_dispatch 手动输入)。
Metadata
Release files for aria-engine 1.17.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 30.1 MB
Release files / aria_engine-1.17.1-cp313-cp313-win_amd64.whl
| Download URL | aria_engine-1.17.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8eba84d9c302cb1e47a3cb354978599c1a58e4d8e9b4185e0c6dd7c9b7bf2827
|
|
BLAKE2b-256 checksum How to use checksums |
a187fce5bf7cf46772977e413078e360f44d8df087fe580c1f3cff82611298bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | aria_engine-1.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
925e4273f455c05a4339955e831bf41ead96d9859c82cbb5aaa6aeb3ab172939
|
|
BLAKE2b-256 checksum How to use checksums |
b0dfc0b488d538e490c6c507f2d2957a5c4b4dfc34084e608ee25b4ad631d872
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | aria_engine-1.17.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
41a7eb10a5a186a329f8dd296385bcbceb9216debe75ec73b9a2d684d1c646b6
|
|
BLAKE2b-256 checksum How to use checksums |
b9ccb29ce777c87fdf58d3895cf4227f0c261ab2809c2b19ff880bc170bfc0cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | aria_engine-1.17.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
319e633536a6c62b4c001bb868c654a7cf605663f10655e805928acd8769ef4c
|
|
BLAKE2b-256 checksum How to use checksums |
48ec0f24c4b14f9efbff49bb9bcdc9bb9874df7e80df0708047466820d9abcc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp312-cp312-win_amd64.whl
| Download URL | aria_engine-1.17.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
901e042e2f41145c4a0eb06a097cddb635f9f6d31849ab65787bfa59100455ec
|
|
BLAKE2b-256 checksum How to use checksums |
6b858214b12a70f5c6c660033d14e3cf9a4b55dd00e1d60b9a6eed786560ac2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | aria_engine-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
bb6a796e7b8011ba9dac2502263e50be851ab2b1b5ef41c37aa8995a32f33749
|
|
BLAKE2b-256 checksum How to use checksums |
532a5f65586cd9d5657bc953a270abedd34998b29d54f4e393fa587531c22216
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | aria_engine-1.17.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
0adfca0d1a54624dd2f78b1ffb93a4e56bd1dac225656c343633e214df90b652
|
|
BLAKE2b-256 checksum How to use checksums |
861e3431b1db650de4d55815cef7fd23e84750d5b2698eef9561accc8f4429f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | aria_engine-1.17.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6db997c3651a8b4ee1168a5f45bb90146478a76e3cc61f9026a9d35e503e4872
|
|
BLAKE2b-256 checksum How to use checksums |
0f7b5db4587bb4fadea1fd9db556b2f6cbe325c7dd5ce826206b42d56c985d00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp311-cp311-win_amd64.whl
| Download URL | aria_engine-1.17.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a5cc4c4dd353a255768850db517cb521cc971181c67174deec89de8569252188
|
|
BLAKE2b-256 checksum How to use checksums |
d2141fa2a40a13da2b6d556d96fe18e530b618c38b9a39009e375efd0fe01b96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | aria_engine-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
fccabee115b3a8d47f5db33ad127d2f38c670632308fcb4a356ae890efadf8e5
|
|
BLAKE2b-256 checksum How to use checksums |
2bef1466b29698611f6cfc17fc8b5cc7d52aed3fe570ff1d04c0716288b99255
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | aria_engine-1.17.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
6fbf720805d16a2c09f5ac6061e73172dd052ad338e6420b36cb325c1a526265
|
|
BLAKE2b-256 checksum How to use checksums |
4b2db7588cdeedaf581b97bbf633db12912f094d99e66f8559cef43a73ed090b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | aria_engine-1.17.1-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
72fe067e588b4b24d82d20eeeadf1e4b9564de06ccb00fbbcea3cc10bff8f33f
|
|
BLAKE2b-256 checksum How to use checksums |
8fc9b33da4a47498a5f2ba3233616300569798593966a5b96fb2fc127a795a9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp310-cp310-win_amd64.whl
| Download URL | aria_engine-1.17.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
42d71e612c6dc4006c0ac3809cc6aee1d24ab54009c8fe342eb0cec2970c1bc8
|
|
BLAKE2b-256 checksum How to use checksums |
216c6e0cf98329f0a70ec843ebe87076a7f3d1fe2c507b37d50e7ebf2bc0f41b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | aria_engine-1.17.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
0917c01846875e2667cf9a4a5fe9424ca1e96345cf5533b6960b0c0552375a93
|
|
BLAKE2b-256 checksum How to use checksums |
624ff32f037378b2c5a9f8c40dc0d4d21521b964173161359899976d6384ea49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | aria_engine-1.17.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
67e037af4cbf69e0345b117a88a1a1d85de0298eb718ada524fe4b01e6f17da0
|
|
BLAKE2b-256 checksum How to use checksums |
60dacc6dd811f527f73f918b50298d4670e150fdb4bb001da1e073fe50a219c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / aria_engine-1.17.1-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | aria_engine-1.17.1-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
137c1a4eb89967eff7a3e60908defaadd097303e792443d22d11bd5a5f38b844
|
|
BLAKE2b-256 checksum How to use checksums |
2c4f6439e4132ebd0f4f3eb2ceff244482fd2703da9a66055f2c0f795fecbdb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|