Skip to content

Commit

Permalink
Document Python import hook in user guide
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 6, 2021
1 parent e5a1eaf commit bf4a65e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions guide/src/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,25 @@ pip install -e .
```

Then Python source code changes will take effect immediately.

## Import Hook

Starting from v0.12.4, the [Python maturin package](https://pypi.org/project/maturin/) provides
a Python import hook to allow quickly build and load a Rust module into Python.

It supports pure Rust and mixed Rust/Python project layout as well as a
standalone `.rs` file.

```python
from maturin import import_hook

# install the import hook with default settings
import_hook.install()
# or you can specify bindings
import_hook.install(bindings="pyo3")
# and build in release mode instead of the default debug mode
import_hook.install(release=True)

# now you can start importing your Rust module
import pyo3_pure
```

0 comments on commit bf4a65e

Please sign in to comment.