Setuptools plugin for generating Rust Cargo.toml Files
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
Release files for setuptools-rust-tomlgen 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| setuptools-rust-tomlgen-1.0.0.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| setuptools_rust_tomlgen-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.6 kB
Release files / setuptools-rust-tomlgen-1.0.0.tar.gz
| Download URL | setuptools-rust-tomlgen-1.0.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7de5f5d7589e3485cefc6b34ed46c339ed7e1b26a1815e05e0f88a782ac81973
|
|
BLAKE2b-256 checksum How to use checksums |
6cb6e50dce81eb736789605e81a958b208e590c88cc541b071865d3af1a74dab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / setuptools_rust_tomlgen-1.0.0-py3-none-any.whl
| Download URL | setuptools_rust_tomlgen-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
287c34dd7a89fa81c1a69e9ed1e7316769b67eb5f82388c446b685d1ab8975d8
|
|
BLAKE2b-256 checksum How to use checksums |
44da02e43af8681858acbe241c58c73d5d609219356dd26a31d10b6c402f2852
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|