17
17
toolchain : stable
18
18
profile : minimal
19
19
components : rustfmt, clippy
20
+ default : true
21
+ - uses : Swatinem/rust-cache@v1
22
+ continue-on-error : true
20
23
- env :
21
24
CLIPPYFLAGS : --deny warnings --allow clippy::needless-lifetimes
22
25
run : |
@@ -27,50 +30,67 @@ jobs:
27
30
test :
28
31
name : python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
29
32
runs-on : ${{ matrix.platform.os }}
33
+ needs : [lint, check-msrv, linalg-example]
30
34
strategy :
31
- max-parallel : 16
35
+ fail-fast : false
32
36
matrix :
33
- python-version : [3.6, 3. 7, 3.8, 3.9]
37
+ python-version : [3.7, 3.8, 3.9]
34
38
platform : [
35
39
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
36
40
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
37
41
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
38
42
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
39
43
]
44
+ include :
45
+ # NumPy does not provide pre-built wheels for PyPy on macOS and Windows
46
+ - python-version : pypy-3.7
47
+ platform : { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
48
+ - python-version : pypy-3.8
49
+ platform : { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
40
50
steps :
41
51
- uses : actions/checkout@v2
42
52
- name : Set up Python ${{ matrix.python-version }}
43
53
uses : actions/setup-python@v2
44
54
with :
45
55
python-version : ${{ matrix.python-version }}
56
+ architecture : ${{ matrix.platform.python-architecture }}
46
57
- name : Install Rust
47
58
uses : actions-rs/toolchain@v1
48
59
with :
49
60
toolchain : stable
61
+ profile : minimal
62
+ target : ${{ matrix.platform.rust-target }}
50
63
default : true
51
- - run : rustup set default-host ${{ matrix.platform.rust-target }}
64
+ - name : Install toml
65
+ run : pip install toml
66
+ - name : Edit Cargo.toml and enable new resolver
67
+ run : |
68
+ import toml
69
+ cargo_toml = toml.load("Cargo.toml")
70
+ cargo_toml["workspace"]["resolver"] = "2"
71
+ with open("Cargo.toml", "w") as f:
72
+ toml.dump(cargo_toml, f)
73
+ shell : python
52
74
- name : Build without default features
53
- run : cargo build --no-default-features --verbose
75
+ run : cargo build --no-default-features
54
76
- name : Build with default features
55
- run : cargo build --verbose
56
- - name : Install test dependencies
77
+ run : cargo build
78
+ - name : Test
57
79
run : |
58
- python -m pip install --upgrade pip
59
- pip install maturin numpy poetry
60
- - name : Run cargo test
61
- run : cargo test --verbose
62
- - name : Test Examples
80
+ pip install numpy
81
+ cargo test
82
+ # Not on PyPy, because no embedding API
83
+ if : ${{ !startsWith(matrix.python-version, 'pypy') }}
84
+ - name : Test example
63
85
run : |
64
- for example_dir in 'examples/simple-extension'; do
65
- pushd $example_dir && \
66
- poetry install && \
67
- poetry run maturin develop && \
68
- poetry run pytest && \
69
- popd
70
- done
71
- shell : bash
86
+ pip install tox
87
+ tox
88
+ working-directory : examples/simple-extension
72
89
env :
90
+ CARGO_TERM_VERBOSE : true
91
+ CARGO_BUILD_TARGET : ${{ matrix.platform.rust-target }}
73
92
RUST_BACKTRACE : 1
93
+ TOX_TESTENV_PASSENV : CARGO_BUILD_TARGET
74
94
75
95
check-msrv :
76
96
runs-on : ubuntu-latest
@@ -80,37 +100,48 @@ jobs:
80
100
uses : actions/setup-python@v2
81
101
with :
82
102
python-version : 3.8
83
- - name : Install MSRV Rust
103
+ - name : Install Rust
84
104
uses : actions-rs/toolchain@v1
85
105
with :
86
- profile : minimal
87
106
toolchain : 1.48.0
107
+ profile : minimal
88
108
default : true
89
- - name : Install maturin, poetry, and toml
90
- run : pip install maturin poetry toml
91
- - name : Create an isolated example directory
92
- run : cp -r examples/simple-extension/ ../simple-extension-msrv
93
- - name : Edit Cargo.toml and change the path of rust-numpy
109
+ - uses : Swatinem/rust-cache@v1
110
+ with :
111
+ working-directory : examples/simple-extension
112
+ continue-on-error : true
113
+ - name : Install toml
114
+ run : pip install toml
115
+ - name : Edit Cargo.toml and detach from workspace
94
116
run : |
95
117
import toml
96
118
cargo_toml = toml.load("Cargo.toml")
97
- cargo_toml["dependencies"]["numpy"]["path"] = "../rust-numpy"
98
119
cargo_toml["dependencies"]["ndarray"] = "0.13.1"
99
120
cargo_toml["dependencies"]["num-complex"] = "0.2.4"
121
+ cargo_toml["workspace"] = {}
100
122
with open("Cargo.toml", "w") as f:
101
123
toml.dump(cargo_toml, f)
102
- working-directory : .. /simple-extension-msrv
124
+ working-directory : examples /simple-extension
103
125
shell : python
104
- - name : Use ndarray 0.13.1
126
+ - name : Generate lockfile
127
+ run : cargo generate-lockfile
128
+ working-directory : examples/simple-extension
129
+ - name : Unify dependencies on ndarray to 0.13.1
105
130
run : |
106
- cargo generate-lockfile
107
- cargo update -p $(cargo pkgid -p ndarray 2>&1 >/dev/null | grep 0.15 | sed -e 's/^[ \t]*//') --precise 0.13.1
108
- working-directory : ../simple-extension-msrv
109
- - name : Test Example
131
+ import toml
132
+ import subprocess
133
+ cargo_lock = toml.load("Cargo.lock")
134
+ for pkg in cargo_lock["package"]:
135
+ if pkg["name"] == "ndarray" and pkg["version"] != "0.13.1":
136
+ pkg_id = pkg["name"] + ":" + pkg["version"]
137
+ subprocess.run(["cargo", "update", "--package", pkg_id, "--precise", "0.13.1"], check=True)
138
+ working-directory : examples/simple-extension
139
+ shell : python
140
+ - name : Test example
110
141
run : |
111
- poetry install && poetry run maturin develop && poetry run pytest
112
- working-directory : ../simple-extension-msrv
113
- shell : bash
142
+ pip install tox
143
+ tox
144
+ working-directory : examples/simple-extension
114
145
115
146
linalg-example :
116
147
runs-on : ubuntu-latest
@@ -120,18 +151,18 @@ jobs:
120
151
uses : actions/setup-python@v2
121
152
with :
122
153
python-version : 3.8
123
- - name : Install gfortran
124
- run : |
125
- sudo apt install -y gfortran
154
+ - name : Install OpenBLAS
155
+ run : sudo apt install --yes libopenblas-dev
126
156
- name : Install Rust
127
157
uses : actions-rs/toolchain@v1
128
158
with :
129
159
toolchain : stable
130
- - name : Install maturin and poetry
131
- run : pip install maturin poetry
132
- - name : Test Examples
160
+ profile : minimal
161
+ default : true
162
+ - uses : Swatinem/rust-cache@v1
163
+ continue-on-error : true
164
+ - name : Test example
133
165
run : |
134
- cd examples/linalg && \
135
- poetry install && \
136
- poetry run maturin develop && \
137
- poetry run pytest
166
+ pip install tox
167
+ tox
168
+ working-directory : examples/linalg
0 commit comments