Skip to content

Options for extracting data files from a RustExtension's build-script OUT_DIR #563

@jakelishman

Description

@jakelishman

I have a mixed Python/Rust project using setuptools-rust to build a Rust extension module. This extension module, amongst other things, provides a C API, which I want to expose to external Python extension modules, similarly to how Numpy does (and rust-numpy uses) with a function-pointer table stored in a PyCapsule. setuptools-rust already solves all my needs for generating the shared-object library extension module, and I can create the PyCapsule in PyO3 easily, etc. However, I want to generate the C header file dynamically during the Rust build (using cbindgen as a library), and have the result included in my Python project as a data file, so downstream extension modules can use my Python module as a build dependency.

I think a sensible way I could do this would be if RustExtension provides a way for me to specify that a certain list of files or directories should be installed from the OUT_DIR of the build script into a specified location within the Python package. I'm fine if this is limited to a static mapping in pyproject.toml.

I'd rather avoid introducing a new build system, or having a bootstrap process before sdist creation; I'm happy with setuptools-rust.

I'm happy to produce a prototype PR myself, if this is something that's in scope for the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions