Skip to content

Commit

Permalink
Rearrange instructions
Browse files Browse the repository at this point in the history
Signed-off-by: Andrej Orsula <[email protected]>
  • Loading branch information
AndrejOrsula committed Mar 6, 2024
1 parent 7b31e43 commit 4fd885b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ The workspace contains these packages:

## Instructions

Add `pyo3` as a dependency and `pyo3_bindgen` as a build dependency to your [`Cargo.toml`](https://doc.rust-lang.org/cargo/reference/manifest.html) manifest (`auto-initialize` feature of `pyo3` is optional and shown here for your convenience).
### <a href="#-option-1-build-script"><img src="https://rustacean.net/assets/rustacean-flat-noshadow.svg" width="16" height="16"></a> Option 1: Build script

First, add `pyo3` as a dependency and `pyo3_bindgen` as a build dependency to your [`Cargo.toml`](https://doc.rust-lang.org/cargo/reference/manifest.html) manifest (`auto-initialize` feature is optional and shown here for your convenience).

```toml
[dependencies]
Expand All @@ -95,9 +97,7 @@ pyo3 = { version = "0.20", features = ["auto-initialize"] }
pyo3_bindgen = { version = "0.4" }
```

### <a href="#-option-1-build-script"><img src="https://rustacean.net/assets/rustacean-flat-noshadow.svg" width="16" height="16"></a> Option 1: Build script

Create a [`build.rs`](https://doc.rust-lang.org/cargo/reference/build-scripts.html) script in the root of your crate that generates bindings to the `py_module` Python module.
Then create a [`build.rs`](https://doc.rust-lang.org/cargo/reference/build-scripts.html) script in the root of your crate that generates bindings to the `py_module` Python module.

```rs
// build.rs
Expand All @@ -112,7 +112,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```

Afterwards, include the generated bindings anywhere in your crate.
Afterwards, you can include the generated bindings anywhere in your crate.

```rs
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
Expand Down
10 changes: 5 additions & 5 deletions pyo3_bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
//!
//! ## Instructions
//!
//! Add `pyo3` as a dependency and `pyo3_bindgen` as a build dependency to your [`Cargo.toml`](https://doc.rust-lang.org/cargo/reference/manifest.html) manifest (`auto-initialize` feature of `pyo3` is optional and shown here for your convenience).
//! ### <a href="#-option-1-build-script"><img src="https://rustacean.net/assets/rustacean-flat-noshadow.svg" width="16" height="16"></a> Option 1: Build script
//!
//! First, add `pyo3` as a dependency and `pyo3_bindgen` as a build dependency to your [`Cargo.toml`](https://doc.rust-lang.org/cargo/reference/manifest.html) manifest (`auto-initialize` feature is optional and shown here for your convenience).
//!
//! ```toml
//! [dependencies]
Expand All @@ -20,9 +22,7 @@
//! pyo3_bindgen = { version = "0.4" }
//! ```
//!
//! ### <a href="#-option-1-build-script"><img src="https://rustacean.net/assets/rustacean-flat-noshadow.svg" width="16" height="16"></a> Option 1: Build script
//!
//! Create a [`build.rs`](https://doc.rust-lang.org/cargo/reference/build-scripts.html) script in the root of your crate that generates bindings to the `py_module` Python module.
//! Then create a [`build.rs`](https://doc.rust-lang.org/cargo/reference/build-scripts.html) script in the root of your crate that generates bindings to the `py_module` Python module.
//!
//! ```no_run
//! // build.rs
Expand All @@ -37,7 +37,7 @@
//! }
//! ```
//!
//! Afterwards, include the generated bindings anywhere in your crate.
//! Afterwards, you can include the generated bindings anywhere in your crate.
//!
//! ```ignore
//! include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
Expand Down

0 comments on commit 4fd885b

Please sign in to comment.