Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Feature request: Build a published crate as a RustExtension (for use with `ctypes` or `cffi` directly)

Đang mở
#575 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python, rust
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu bằng cách đọc hack được trích dẫn trong _backend/rustfst_backend/build_meta.py và entry point setuptools_rust.setuptools_ext.rust_extensions. Xác định cách một RustExtension có thể build một dependency đã được publish và expose shared library của nó trên các platform được hỗ trợ, sau đó xác định tiêu chí hoàn thành xoay quanh một tùy chọn source_package hỗ trợ use case ctypes hoặc cffi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hopefully I haven't missed something and this isn't already possible (perhaps with some invocation of maturin that I didn't see in the documentation?)...

It would be nice to be able to create a Python package which contains no actual Rust code of its own but simply builds a publicly available crate (which exports a C interface) and calls into it with ctypes. This may be a bit of a niche use case? I am using it with https://crates.io/crates/rustfst-ffi/1.2.6 because the upstream mantainers, while they publish a Python package, don't publish it as a source distribution and so it can only be installed from PyPI on platforms for which a binary exists.

Now obviously you shouldn't do that. So, I've found a somewhat ugly hack, which is to simply create an empty library with the desired crate as a dependency, then copy the shared library for the dependency instead of the built library (which, obviously, exports none of its dependency's symbols). This is done by monkey-patching setuptools_rust.setuptools_ext.rust_extensions in an in-tree build backend: https://github.com/dhdaines/rustfst/blob/standalone_python/_backend/rustfst_backend/build_meta.py

Not being an expert in Rust I don't know if this works on all platforms or if there's a better way to do it. But I think it would be relatively easy to add this as an option to RustExtension, perhaps, source_package, which would do what the hack above does.

Ngôn ngữ chính
Python
Star
680
Fork
110
Merge trung bình
3 ngày 18 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PyO3/setuptools-rust

Tất cả issue của PyO3/setuptools-rust

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.