Skip to content

Commit e6112e7

Browse files
committed
Use stable Rust in CI
1 parent d7d0d4d commit e6112e7

File tree

6 files changed

+26
-58
lines changed

6 files changed

+26
-58
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v1
21+
uses: actions/setup-python@v2
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
- name: Install Rust
2525
uses: actions-rs/toolchain@v1
2626
with:
27-
toolchain: nightly
27+
toolchain: stable
2828
default: true
2929
- run: rustup set default-host ${{ matrix.platform.rust-target }}
3030
- name: Build without default features

.travis.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: python
2-
dist: xenial
2+
os: linux
3+
dist: bionic
34

45
cache:
56
pip: true
@@ -8,38 +9,26 @@ cache:
89
matrix:
910
include:
1011
- python: "3.5"
11-
env: FEATURES=python3
1212
- python: "3.6"
13-
env: FEATURES=python3
1413
- python: "3.7"
15-
env: FEATURES=python3
1614
- python: "3.8"
17-
env: FEATURES=python3
15+
env: RUN_LINT=1
1816

1917
env:
2018
global:
21-
- TRAVIS_RUST_VERSION=nightly
19+
- TRAVIS_RUST_VERSION=stable
2220
- RUST_BACKTRACE=1
23-
- FEATURES=python3
2421

2522
addons:
2623
apt:
2724
packages:
28-
- libcurl4-openssl-dev
29-
- libelf-dev
30-
- libdw-dev
31-
- cmake
32-
- gcc
33-
- binutils-dev
34-
- libiberty-dev
3525
- gfortran
3626

3727
before_install:
3828
- source ./ci/travis/setup.sh
3929

4030
install:
41-
- pip install setuptools-rust pytest pytest-benchmark \
42-
tox numpy flake8
31+
- pip install setuptools-rust pytest tox numpy flake8
4332

4433
script:
4534
- flake8 examples/

ci/travis/setup.sh

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,15 @@
22

33
set -e
44

5-
# Find the installed version of a binary, if any
6-
_installed() {
7-
VERSION=$($@ --version 2>/dev/null || echo "$@ none")
8-
echo $VERSION | rev | cut -d' ' -f1 | rev
9-
}
10-
11-
# Find the latest available version of a binary on `crates.io`
12-
_latest() {
13-
VERSION=$(cargo search -q "$@" | grep "$@" | cut -f2 -d"\"")
14-
echo $VERSION
15-
}
16-
175
### Setup Rust toolchain #######################################################
18-
curl -SsL "https://sh.rustup.rs/" | sh -s -- -y --default-toolchain=$TRAVIS_RUST_VERSION
6+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=$TRAVIS_RUST_VERSION --profile=minimal -y
197
export PATH=$PATH:$HOME/.cargo/bin
8+
if [[ $RUN_LINT == 1 ]]; then
9+
rustup component add clippy
10+
rustup component add rustfmt
11+
fi
2012

2113
### Setup python linker flags ##################################################
22-
23-
python -c """
24-
import sysconfig
25-
cfg = sorted(sysconfig.get_config_vars().items())
26-
print('\n'.join(['{}={}'.format(*x) for x in cfg]))
27-
"""
28-
29-
export PYTHON_LIB=$(python -c "import sysconfig as s; print(s.get_config_var('LIBDIR'))")
30-
31-
# find $PYTHON_LIB
32-
export LIBRARY_PATH="$LIBRARY_PATH:$PYTHON_LIB"
33-
34-
# delete any possible empty components
35-
# https://github.com/google/pulldown-cmark/issues/122#issuecomment-364948741
36-
LIBRARY_PATH=$(echo $LIBRARY_PATH | sed -E -e 's/^:*//' -e 's/:*$//' -e 's/:+/:/g')
37-
14+
PYTHON_LIB=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
3815
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PYTHON_LIB:$HOME/rust/lib"
16+
echo ${LD_LIBRARY_PATH}

ci/travis/test.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
set -ex
44

5-
cargo build --verbose --features $FEATURES
6-
cargo test --verbose --features $FEATURES -- --test-threads=1
5+
cargo build --verbose
6+
cargo test --verbose
7+
8+
if [[ $RUN_LINT == 1 ]]; then
9+
cargo fmt --all -- --check
10+
cargo clippy --tests
11+
for example in examples/*; do (cd $$example/; cargo clippy) || exit 1; done
12+
fi
713

814
for example in examples/*; do
915
if [ $example != 'examples/linalg' ]; then

src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl<T, D> PyArray<T, D> {
225225
/// use numpy::PyArray3;
226226
/// let gil = pyo3::Python::acquire_gil();
227227
/// let arr = PyArray3::<f64>::new(gil.python(), [4, 5, 6], false);
228-
/// assert_eq!(arr.ndim(),
228+
/// assert_eq!(arr.ndim(), 3);
229229
/// ```
230230
// C API: https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_NDIM
231231
pub fn ndim(&self) -> usize {

src/lib.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,10 @@ pub use ndarray::{Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
5757
#[doc(hidden)]
5858
pub mod doc_test {
5959
macro_rules! doc_comment {
60-
($x:expr, $($tt:tt)*) => {
60+
($x: expr, $modname: ident) => {
6161
#[doc = $x]
62-
$($tt)*
62+
mod $modname {}
6363
};
6464
}
65-
macro_rules! doctest {
66-
($x: literal, $y:ident) => {
67-
doc_comment!(include_str!($x), mod $y {});
68-
};
69-
}
70-
doctest!("../README.md", readme_md);
65+
doc_comment!(include_str!("../README.md"), readme);
7166
}

0 commit comments

Comments
 (0)