通过rye 进行maturin rust python 扩展开发

rye 实际上也是一个python 包管理工具,实际上与uv 是比较类似的工具,都是同一个团队开发的,但是uv 相对晚一些出现的
rye 可以进行maturin 项目的开发,maturin 实际上也提供了内置的cli 可以快速开发

maturin 项目初始化

  • 命令
rye init my-project --build-system maturin
  • 结构
├── Cargo.lock
├── Cargo.toml
├── README.md
├── pyproject.toml
├── python
└── my_project
└── __init__.py
└── src
    └── lib.rs
  • pyproject.toml 内容
[project]
name = "my-project"
version = "0.1.0"
description = "Add your description here"
authors = [
    { name = "rongfengliang", email = "1141591465@qq.com" }
]
dependencies = []
readme = "README.md"
requires-python = ">= 3.8"
 
[build-system]
requires = ["maturin>=1.2,<2.0"]
build-backend = "maturin"
 
[tool.rye]
managed = true
dev-dependencies = []
 
[tool.maturin]
python-source = "python"
module-name = "my_project._lowlevel"
features = ["pyo3/extension-module"]
  • 构建
rye build # 标准玩法
rye sync  # 也会进行构建
  • 效果

说明

maturin 是一个基于rust 开发高性能python 扩展不错的工具,与rye 集成起来也是不错的选择,这样开发的扩展就不用太受限于
maturin 默认cli 结构了

参考资料

https://github.com/PyO3/maturin
https://rye.astral.sh/guide/rust/

posted on   荣锋亮  阅读(35)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-10-24 nginx unit WebAssembly 试用
2023-10-24 unit 1.31.1 发布
2023-10-24 使用centos 7 的系统应该升级了
2022-10-24 dremio parquet zstd 压缩支持docker 镜像
2022-10-24 dremio parquet zstd 压缩支持尝试
2021-10-24 openmetadata 简单说明
2019-10-24 Netflix-mantis 实时数据流开发平台

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示