API Reference - setuptools-rust documentation (original) (raw)
Toggle table of contents sidebar
class setuptools_rust.RustExtension(target, path='Cargo.toml', args=(), cargo_manifest_args=(), features=(), rustc_flags=(), rust_version=None, quiet=False, debug=None, binding=Binding.PyO3, strip=Strip.No, script=False, native=False, optional=False, py_limited_api='auto', env=None)¶
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
[Sequence
[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
. - cargo_manifest_args (
Optional
[Sequence
[str
]]) – A list of extra arguments to be passed to Cargo. These arguments will be passed to everycargo
command, not justcargo build
. For valid options, seethe Cargo Book. For example,cargo_manifest_args=["--locked"]
will requireCargo.lock
files are up to date. - features (
Optional
[Sequence
[str
]]) – Cargo –features to add to the build. - rustc_flags (
Optional
[Sequence
[str
]]) – A list of additional flags passed to cargo rustc. These only affect the final artifact, usually you should set theRUSTFLAGS environment variable. - 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) – Informs
setuptools_rust
which Python binding is in use. - strip (Strip) – Strip symbols from final file. Does nothing for debug build.
- native (
bool
) – Build extension or executable with-Ctarget-cpu=native
(deprecated, set environment variable RUSTFLAGS=-Ctarget-cpu=native). - script (
bool
) – Generate console script for executable ifBinding.Exec
is used (deprecated, just useRustBin
instead). - 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
]) – Deprecated. - env (
Optional
[Dict
[str
,str
]]) – Environment variables to use when calling cargo or rustc (env=
insubprocess.Popen
). setuptools-rust may add additional variables or modifyPATH
.
class setuptools_rust.RustBin(target, path='Cargo.toml', args=(), cargo_manifest_args=(), features=(), rust_version=None, quiet=False, debug=None, strip=Strip.No, optional=False, env=None)¶
Used to define a Rust binary and its build configuration.
Parameters:
- target (
Union
[str
,Dict
[str
,str
]]) – Rust binary target name. - path (
str
) – Path to theCargo.toml
manifest file. - args (
Optional
[Sequence
[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
. - cargo_manifest_args (
Optional
[Sequence
[str
]]) –
A list of extra arguments to be passed to Cargo. These arguments will be passed to everycargo
command, not justcargo build
. For valid options, seethe Cargo Book. For example,cargo_manifest_args=["--locked"]
will requireCargo.lock
files are up to date. - features (
Optional
[Sequence
[str
]]) – Cargo –features to add to the build. - rust_version (
Optional
[str
]) – Minimum Rust compiler version required for this bin. - 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. - strip (Strip) – Strip symbols from final file. Does nothing for debug build.
- optional (
bool
) – If it is true, a build failure in the bin will not abort the build process, and instead simply not install the failing bin.
class setuptools_rust.Binding(value)¶
Enumeration of possible Rust binding types supported by setuptools-rust
.
PyO3¶
This is an extension built usingPyO3.
RustCPython¶
This is an extension built usingrust-cpython.
NoBinding¶
Bring your own bindings for the extension.
Exec¶
Build an executable instead of an extension.
class setuptools_rust.Strip(value)¶
Enumeration of modes for stripping symbols from the built extension.
No¶
Do not strip symbols.
Debug¶
Strip debug symbols.
All¶
Strip all symbols.