Skip to main content

Setuptools Rust Tomlgen extension plugin

Project description

Setuptools plugin for generating Rust Cargo.toml Files

github actions pypi package code style: black

setuptools-rust-tomlgen is a plugin for setuptools and setuptools-rust. It adds the tomlgen_rust command which generates Rust Cargo.toml files from the contents of setup.py.

Usage

Install from pip:

$ pip install setuptools-rust-tomlgen

Create a project which contains both a setup.py file and some Rust .rs files, such as the example project.

Generate Cargo.toml files via setup.py:

$ python setup.py tomlgen_rust

Metadata

The package name will be generated from the position of the extension within the Python package. The same version is used as the one declared in setup.py or setup.cfg.

The authors list is generated after the author and author_email options from setup.py / setup.cfg, but can also be overriden using the authors key in the [tomlgen_rust] section of setup.cfg:

[tomlgen_rust]
authors =
  Jane Doe <jane@doe.name>
  John Doe <john@doe.name>

The library name is a slugified variant of the extension package name, to avoid name collisions within the build directory.

As a safety, publish = false is added to the [package] section (you wouldn't publish an automatically generated package, would you ?!).

Options

Use --force (or add force = true to the [tomlgen_rust] section of setup.cfg) to force generating a manifest even when one already exists.

Use --create-workspace to create a virtual manifest at the root of your project (next to the setup.py file) which registers all of the extensions. This way, generic cargo commands can be run without leaving the root of the project.

If --create-workspace is enabled, a .cargo/config file will also be created to force cargo to build to the temporary build directory. Use --no-config to disable.

Dependencies

To specify dependencies for all extensions, add them to the [tomlgen_rust.dependencies] section of your setuptools configuration file (setup.cfg), as you would normally in your Cargo.toml file. Here is probably a good place to add pyo3 as a dependency.

To specify per-extension dependency, create a section for each extension ([tomlgen_rust.dependencies.<DOTTEDPATH>], where <DOTTEDPATH> is the complete Python path to the extension (e.g. hello-english). Extension specific dependencies are added after global dependencies.

Note that, since all projects are built in the same directory, you can also declare all dependencies in the [tomlgen_rust.dependencies], as they will be built only once anyway.

Automatic generation at each build

If you intend to regenerate manifests everytime the library is built, you can add Cargo.toml and Cargo.lock to your .gitignore file.

Then, make sure tomlgen_rust is run before build_rust everytime by adding aliases to your setup.cfg file:

[aliases]
build_rust = tomlgen_rust -f build_rust
clean_rust = tomlgen_rust -f clean_rust
build = tomlgen_rust -f build
clean = clean_rust -f clean

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setuptools-rust-tomlgen-1.0.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

setuptools_rust_tomlgen-1.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file setuptools-rust-tomlgen-1.0.0.tar.gz.

File metadata

  • Download URL: setuptools-rust-tomlgen-1.0.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for setuptools-rust-tomlgen-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7de5f5d7589e3485cefc6b34ed46c339ed7e1b26a1815e05e0f88a782ac81973
MD5 afdbf5f67a2eeadf1fc66c76f1999b8e
BLAKE2b-256 6cb6e50dce81eb736789605e81a958b208e590c88cc541b071865d3af1a74dab

See more details on using hashes here.

File details

Details for the file setuptools_rust_tomlgen-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: setuptools_rust_tomlgen-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for setuptools_rust_tomlgen-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 287c34dd7a89fa81c1a69e9ed1e7316769b67eb5f82388c446b685d1ab8975d8
MD5 d5d1b973879f38c0b1c735acc77f891e
BLAKE2b-256 44da02e43af8681858acbe241c58c73d5d609219356dd26a31d10b6c402f2852

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page