Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
PyO3
Rust bindings for the python interpreter.
- User Guide
- API Documentation
- Cargo package: pyo3
PyO3 is licensed under the Apache-2.0 license. Python is licensed under the Python License.
Supported Python versions:
- Python2.7, Python 3.5 and up
Supported Rust version:
- Rust 1.23.0-nightly 2017-11-07 or later
- On Windows, we require rustc 1.23.0-nightly 2017-11-07
Usage
To use pyo3
, add this to your Cargo.toml
:
[]
= "0.2"
Example program displaying the value of sys.version
:
extern crate pyo3;
use ;
Example library with python bindings:
The following two files will build with cargo build
, and will generate a python-compatible library.
For MacOS, "-C link-arg=-undefined -C link-arg=dynamic_lookup" is required to build the library.
setuptools-rust
includes this by default.
See examples/word-count and the associated setup.py.
Also on macOS, you will need to rename the output from *.dylib to *.so.
On Windows, you will need to rename the output from *.dll to *.pyd.
Cargo.toml
:
[]
= "rust2py"
= ["cdylib"]
[]
= "0.2"
= ["extension-module"]
src/lib.rs
extern crate pyo3;
use *;
// add bindings to the generated python module
// N.B: names: "librust2py" must be the name of the `.so` or `.pyd` file
/// This module is implemented in Rust.
// logic implemented as a normal rust function
For setup.py
integration, see setuptools-rust
This is fork of rust-cpython project https://github.com/dgrunwald/rust-cpython