Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mojo FFI: Build and Publish a mojo package based on the Rust library #434

Open
hhstore opened this issue Oct 13, 2024 · 14 comments
Open

Mojo FFI: Build and Publish a mojo package based on the Rust library #434

hhstore opened this issue Oct 13, 2024 · 14 comments

Comments

@hhstore
Copy link
Owner

hhstore commented Oct 13, 2024

📖 Abstract:

  • ✅ 构建并发布一个基于 Rust 库 + FFI binding 实现的 Mojo 包。

💯 Related:

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

构建+发布一个 Mojo 包(基于 rust 库 + FFI binding 实现)

目标:

  • 基于一个 rust-lib 库,开发一个 rust-lib-ffi 库,并发布到 prefix.dev 包平台。
  • 基于 rust-lib-ffi库,开发一个 mojo 库,并发布到 prefix.dev 平台。
  • 也就是说:需要发布2个库(前者是 libxxx.dylib or .so or .dll, 后者是 .mojopkg 格式)

工具:

conda-build

pixi add conda-build

参考:

pixi + rattler-build

参考:

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

magic 打包 mojo 包目录格式:

  • 截至目前, magic 工具,目前只支持打包 2 种包格式:
# support
src/xxx_package/__init__.mojo

# support
xxx_package/__init__.mojo

# not support
src/__init__.mojo
  • 不支持 src/__init__.mojo 这种包格式,(踩坑,单元测试也不支持)
  • 后续应该可以在 mojoproject.toml 增加配置项来支持。

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

mojo 包安装路径:

  • 使用 magic 打包 mojo 包,打包配置文件,需要把包路径指定为 /lib/mojo
  • 这样安装包时, 会把包安装到 .magic/envs/default/lib/mojo/ 路径下, 这样才能正常导包
image

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

Mojo 打包示例项目

jojo-core

jojo-cli

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

使用 conda-build 构建 rust lib

  • 目标:将一个普通的 rust lib, 构建为 .conda 包,并发布到包平台。

docs:

rust lib 构建示例:

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

8 similar comments
@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

@hhstore
Copy link
Owner Author

hhstore commented Oct 13, 2024

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant