python-setuptools-rust
Port variant v11
Summary Setuptools Rust extension plugin (3.11)
BROKEN
Package version 1.10.2
Homepage https://github.com/PyO3/setuptools-rust
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v12
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 12 OCT 2024, 19:09:16 UTC
Port created 10 FEB 2021, 19:26:20 UTC
Subpackage Descriptions
single # Setuptools plugin for Rust extensions [github actions] [pypi package] [readthedocs] [Ruff] `setuptools-rust` is a plugin for `setuptools` to build Rust Python extensions implemented with [PyO3] or [rust-cpython]. Compile and distribute Python extensions written in Rust as easily as if they were written in C. ## Quickstart The following is a very basic tutorial that shows how to use `setuptools-rust` in `pyproject.toml`. It assumes that you already have a bunch of Python and Rust files that you want to distribute. You can see examples for these files in the [`examples/hello-world`] directory in the [github repository]. The [PyO3 docs] have detailed information on how to write Python modules in Rust. ``` hello-world ├── python │ └── hello_world │ └── __init__.py └── rust └── lib.rs ``` Once the implementation files are in place, we need to add a `pyproject.toml` file that tells anyone that wants to use your project how to build it. In this file, we use an [array of tables] (TOML jargon equivalent to Python's list of dicts) for ``[[tool.setuptools-rust.ext-modules]]``, to specify different extension modules written in Rust: ```toml # pyproject.toml [build-system] requires = ["setuptools", "setuptools-rust"] build-backend = "setuptools.build_meta" [project] name = "hello-world" version = "1.0" [tool.setuptools.packages] # Pure Python packages/modules find = { where = ["python"] } [[tool.setuptools-rust.ext-modules]] # Private Rust extension module to be nested into the Python package target = "hello_world._lib" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml, # but you can add a prefix to nest it inside of a Python package. path = "Cargo.toml" # Default value, can be omitted binding = "PyO3" # Default value, can be omitted ``` Each extension module should map directly into the corresponding `[lib]` table on the [Cargo manifest file]: ```toml # Cargo.toml [package] name = "hello-world" version = "0.1.0" edition = "2021" [dependencies] pyo3 = "0.22.0" [lib] name = "_lib" # private module to be nested into Python package, # needs to match the name of the function with the `[#pymodule]` attribute path = "rust/lib.rs" crate-type = ["cdylib"] # required for shared library for Python to import from. # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See also PyO3 docs on writing Cargo.toml files at https://pyo3.rs ``` You will also need to tell Setuptools that the Rust files are required to build your project from the [source distribution]. That can be done either via `MANIFEST.in` (see example below) or via a plugin like [`setuptools-scm`].
Configuration Switches (platform-specific settings discarded)
PY311 ON Build using Python 3.11 PY312 OFF Build using Python 3.12
Package Dependencies by Type
Build (only) python-pip:single:v11
autoselect-python:single:std
Build and Runtime python311:single:std
Runtime (only) python-setuptools:single:v11
python-semantic-version:single:v11
Download groups
main mirror://PYPIWHL/97/09/3da290ba3934c7003d3a178840579989a7fcfa5bd23f50dd7f2ff27f30e1
Distribution File Information
4b39c435ae9670315d522ed08fa0e8cb29f2a6048033966b6be2571a90ce4f1c 26807 setuptools_rust-1.10.2-py3-none-any.whl
Ports that require python-setuptools-rust:v11
python-bcrypt:v11 Modern password hashing based on blowfish (3.11)
python-cryptography:v11 Cryptographic recipes and primitives (3.11)
python-dulwich:v11 Python Git Library (3.11)
python-maturin:v11 Build and publish python rust packages (3.11)
python-netifaces2:v11 Portable network interface information (3.11)
python-orjson:v11 Fast, correct Python JSON library (3.11)