Skip to content

Commit 96d9e96

Browse files
committed
More documents about example
1 parent 584f770 commit 96d9e96

File tree

3 files changed

+36
-23
lines changed

3 files changed

+36
-23
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ fn main() -> PyResult<()> {
8181

8282
### Write a Python module in Rust
8383

84-
Please see the [examples](https://github.com/PyO3/rust-numpy/examples) directory for a complete example
84+
Please see [simple-extension](https://github.com/PyO3/rust-numpy/tree/master/examples/simple-extension)
85+
directory for the complete example.
86+
Also, we have an example project with [ndarray-linalg](https://github.com/PyO3/rust-numpy/tree/master/examples/linalg).
8587

8688
```toml
8789
[lib]
@@ -139,7 +141,11 @@ fn rust_ext(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
139141
}
140142
```
141143

142-
## Contribution
143-
We need your feedback.
144+
## Conributing
145+
We welcome [issues](https://github.com/rust-numpy/rust-numpy/issues)
146+
and [pull requests](https://github.com/rust-numpy/rust-numpy/pulls).
147+
148+
PyO3's [contrinbuting.md](https://github.com/PyO3/pyo3/blob/master/Contributing.md)
149+
is a nice guide for starting.
150+
Also, we have a [gitter](https://gitter.im/PyO3/Lobby) channel for communicating.
144151

145-
Don't hesitate to open [issues](https://github.com/rust-numpy/rust-numpy/issues)!

examples/linalg/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# rust-numpy example extension with linalg
2+
3+
An example extension with [ndarray-linalg](https://github.com/rust-ndarray/ndarray-linalg).
4+
5+
Needs a fortran compiler (e.g., `gfortran`) for building.
6+
7+
See [simple-extension's README](https://github.com/PyO3/rust-numpy/blob/master/examples/simple-extension/README.md)
8+
for introduction.
9+

examples/simple-extension/README.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
Example of rust-numpy
2-
----------------------
1+
# rust-numpy example extension
32

4-
- Prerequirement
3+
Here, we use [`maturin`][maturin] for building Python wheel and
4+
[`poetry`][poetry] for managing Python dependencies and virtualenvs.
5+
Following commands creates a virtualenv, install Python-side
6+
dependencies, and install the extension to the virtualenv.
57

8+
```bash
9+
poetry install
10+
poetry run maturin develop
611
```
7-
sudo pip3 install -r requirements.txt
8-
```
9-
10-
- Build
1112

12-
```
13-
python3 setup.py develop --user
14-
```
15-
16-
- Run
13+
Once the extension installed, you can run the extension from
14+
Python REPL started by `poetry run python`:
1715

1816
```python
19-
import numpy as np
20-
import rust_ext
21-
22-
a = np.array([0.0, 1.0])
23-
b = np.array([2.0, 3.0])
24-
rust_ext.axpy(2.0, a, b)
17+
>>> import numpy as np
18+
>>> import rust_ext
19+
>>> rust_ext.axpy(2.0, np.array([0.0, 1.0]), np.array([2.0, 3.0]))
20+
array([2., 5.])
2521
```
26-
which returns `array([2., 5.])`.
22+
23+
[maturin]: https://github.com/PyO3/maturin
24+
[poetry]: https://python-poetry.org/

0 commit comments

Comments
 (0)