Skip to content

Commit 49ac8e6

Browse files
authored
Merge pull request #167 from PyO3/refactor-examples
Renew examples
2 parents 4de6269 + 96d9e96 commit 49ac8e6

File tree

26 files changed

+622
-193
lines changed

26 files changed

+622
-193
lines changed

.github/workflows/test.yml renamed to .github/workflows/ci.yml

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
name: Test
1+
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
48

59
jobs:
610

@@ -13,16 +17,16 @@ jobs:
1317
toolchain: stable
1418
profile: minimal
1519
components: rustfmt, clippy
16-
- run:
17-
cargo fmt --all -- check
20+
- run: |
21+
cargo fmt --all -- --check
1822
cargo clippy --tests
1923
for example in examples/*; do (cd $example/; cargo clippy) || exit 1; done
2024
21-
build:
25+
test:
2226
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
2327
runs-on: ${{ matrix.platform.os }}
2428
strategy:
25-
max-parallel: 12
29+
max-parallel: 16
2630
matrix:
2731
python-version: [3.6, 3.7, 3.8, 3.9]
2832
platform: [
@@ -49,10 +53,44 @@ jobs:
4953
run: cargo build --verbose
5054
- name: Install test dependencies
5155
run: |
52-
python -m pip install -U pip setuptools
53-
pip install setuptools-rust pytest pytest-benchmark tox tox-venv numpy
54-
- name: Test
55-
run: ci/actions/test.sh
56+
python -m pip install --upgrade pip
57+
pip install maturin numpy poetry
58+
- name: Run cargo test
59+
run: cargo test --verbose
60+
- name: Test Examples
61+
run: |
62+
for example_dir in 'examples/simple-extension'; do
63+
pushd $example_dir && \
64+
poetry install && \
65+
poetry run maturin develop && \
66+
poetry run pytest && \
67+
popd
68+
done
5669
shell: bash
5770
env:
5871
RUST_BACKTRACE: 1
72+
73+
linalg-example:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v2
77+
- name: Set up Python
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: 3.8
81+
- name: Install gfortran
82+
run: |
83+
sudo apt install -y gfortran
84+
- name: Install Rust
85+
uses: actions-rs/toolchain@v1
86+
with:
87+
toolchain: stable
88+
default: true
89+
- name: Install maturin and poetry
90+
run: pip install maturin poetry
91+
- name: Test Examples
92+
run: |
93+
cd examples/linalg && \
94+
poetry install && \
95+
poetry run maturin develop && \
96+
poetry run pytest

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
- Unreleased
4+
- Bump num-complex to 0.3
5+
- Bump ndarray to 0.14
6+
37
- v0.12.1
48
- Fix compile error in Rust 1.39
59

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cfg-if = "0.1"
1414
libc = "0.2"
1515
num-complex = "0.3"
1616
num-traits = "0.2"
17-
ndarray = ">=0.13"
17+
ndarray = "0.14"
1818
pyo3 = ">=0.12"
1919

2020
[features]

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
rust-numpy
22
===========
3-
[![Actions Status](https://github.com/pyo3/rust-numpy/workflows/Test/badge.svg)](https://github.com/pyo3/rust-numpy/actions)
3+
[![Actions Status](https://github.com/pyo3/rust-numpy/workflows/CI/badge.svg)](https://github.com/pyo3/rust-numpy/actions)
44
[![Crate](http://meritbadge.herokuapp.com/numpy)](https://crates.io/crates/numpy)
55
[![minimum rustc 1.39](https://img.shields.io/badge/rustc-1.39+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
66

@@ -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)!

ci/actions/test.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

ci/travis/deploy.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

ci/travis/setup.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

ci/travis/test.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/linalg/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "numpy-linalg-example"
33
version = "0.1.0"
4-
authors = ["kngwyu <[email protected]>"]
4+
authors = ["Yuji Kanagawa <[email protected]>"]
55
edition = "2018"
66

77
[lib]
@@ -10,8 +10,8 @@ crate-type = ["cdylib"]
1010

1111
[dependencies]
1212
numpy = { path = "../.." }
13-
ndarray = ">= 0.13"
14-
ndarray-linalg = { version = "0.12", features = ["openblas"] }
13+
ndarray = "0.14"
14+
ndarray-linalg = { git = "https://github.com/kngwyu/ndarray-linalg", branch = "ndarray-014", features = ["openblas-static"] }
1515

1616
[dependencies.pyo3]
1717
version = "0.12"

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+

0 commit comments

Comments
 (0)