pyo3-built
Simple macro to expose metadata obtained with the built
crate as a PyDict
Usage
Add the following to your Cargo.toml
manifest:
[]
= { = "0.7", = ["chrono"] }
[]
= "0.5"
Create your build.rs
as you normally would with built
, but activate
dependencies metadata as well:
//! build.rs
extern crate built;
Then, include the generated file anywhere in a dedicated module in your Python
extension, and use the pyo3_built!
macro to generate the PyDict
:
//! lib.rs
extern crate pyo3_built;
extern crate pyo3;
use *;
/// Module documentation string
That's it ! After compiling your extension module, the __build__
attribute
will contain the following metadata:
>>>
>>>
Customization
When invoking the macro, one can control what will be added to the build dictionary by postfixing the list of the parameters we want in the dictionary. See the following example:
m.add?;
The following parameters are available, mirroring built categories:
"build"
"time"
(requires thechrono
feature ofbuilt
)"deps"
"features"
(requires thecargo-lock
feature ofbuilt
)"host"
"target"
"git"
(requires thegit2
feature ofbuilt
)
By default everything except "git"
is enabled.