Skip to content

Add option to cargo vendor crates into sdist #112

@tiran

Description

@tiran

As of today, setuptools_rust's based extensions require network access during compile stage. The build stage uses cargo to fetch crates from crates.io. For some use cases, it would be beneficial to have an option or command that creates a self-containing source distribution with vendored creates. I define self-contained sdist as ball or zip file that contains all required Rust crate sources ( cargo vendor) and a .cargo/config.toml additionally to a standard python setup.py sdist source ball.

Possible consumers of a self-contained sdist with vendored sources are:

  • end users who need to perform offline installations from sources on isolated / firewalled systems.
  • users that run a DevPI cache with their PyPI packages and don't want Python to contact the network during installation
  • distro packagers who require reproducible builds without external resources

Vendoring shouldn't be the default. I guess you could either add an option to sdist or define a custom sdistvendored command. There is an ongoing discussion at https://discuss.python.org/t/setuptools-rust-maturin-fetching-rust-deps-when-building-wheel/7095 .

implementation

  • $ cargo vendor --manifest-path path/to/extension/Cargo.toml
  • create .cargo/config.toml
  • include vendor and .cargo directory in sdist source ball
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"

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