API Reference¶
- class setuptools_rust.RustExtension(target, path='Cargo.toml', args=None, features=None, rustc_flags=None, rust_version=None, quiet=False, debug=None, binding=Binding.PyO3, strip=Strip.No, script=False, native=False, optional=False, py_limited_api='auto')¶
Used to define a rust extension module and its build configuration.
- Parameters
target (
Union
[str
,Dict
[str
,str
]]) – The full Python dotted name of the extension, including any packages, i.e not a filename or pathname. It is possible to specify multiple binaries, if extension usesBinding.Exec
binding mode. In that case first argument has to be dictionary. Keys of the dictionary correspond to the rust binary names and values are the full dotted name to place the executable inside the python package. To install executables with kebab-case names, the final part of the dotted name can be in kebab-case. For example, hello_world.hello-world will install an executable named hello-world.path (
str
) – Path to theCargo.toml
manifest file.args (
Optional
[List
[str
]]) – A list of extra arguments to be passed to Cargo. For example,args=["--no-default-features"]
will disable the default features listed inCargo.toml
.features (
Optional
[List
[str
]]) – A list of Cargo features to also build.rust_version (
Optional
[str
]) – Minimum Rust compiler version required for this extension.quiet (
bool
) – Suppress Cargo’s output.debug (
Optional
[bool
]) – Controls whether--debug
or--release
is passed to Cargo. If set to None (the default) then build type is automatic:inplace
build will be a debug build,install
andwheel
builds will be release.binding (
Binding
) – Informssetuptools_rust
which Python binding is in use.strip (
Strip
) – Strip symbols from final file. Does nothing for debug build.script (
bool
) – Generate console script for executable ifBinding.Exec
is used.native (
bool
) – Build extension or executable with--target-cpu=native
.optional (
bool
) – If it is true, a build failure in the extension will not abort the build process, and instead simply not install the failing extension.py_limited_api (
Literal
[‘auto’, True, False]) –Similar to
py_limited_api
onsetuptools.Extension
, this controls whether the built extension should be considered compatible with the PEP 384 “limited API”.'auto'
: the--py-limited-api
option ofsetup.py bdist_wheel
will control whether the extension is built as a limited api extension. The correspondingpyo3/abi3-pyXY
feature will be set accordingly. This is the recommended setting, as it allowspython setup.py install
to build a version-specific extension for best performance.True
: the extension is assumed to be compatible with the limited abi. You must ensure this is the case (e.g. by setting thepyo3/abi3
feature).False
: the extension is version-specific.
- class setuptools_rust.Binding(value)¶
Enumeration of possible Rust binding types supported by
setuptools-rust
.- RustCPython¶
This is an extension built using rust-cpython.
- NoBinding¶
Bring your own bindings for the extension.
- Exec¶
Build an executable instead of an extension.